;; $Id: tex.xdy,v 1.3 2010/06/11 11:01:46 jschrod Exp $
;;------------------------------------------------------------

;;;
;;; TeX conventions
;;;

;; Discard leading and trailing white space. Collapse multiple white
;; space characters to blank.
;;
;; FIXME: How do I specify tabs in that regexp? [ \t] does *not* work,
;; it is taken as blank and t.
;;
;; FIXME: Definition of these rules should be postponed until we start
;; with the actual work. Then they should be only issued if module
;; keep-blanks is not loaded. Module keep-blanks would set a flag, and
;; this code would check for it. We will need a hook in the kernel, to
;; achieve that goal.

(merge-rule "^ +" "" :eregexp)
(merge-rule " +$" "" :eregexp)
(merge-rule "  +" " " :eregexp)


;;
;; Handle TeX markup
;;


;; First, some markup that produces output and that we want to keep.
;; If this module is required, similar merge-rules for other markup
;; that shall be kept must be defined first. Otherwise it will be
;; discarded, by the default rule below.

(merge-rule "\\([{}$%&#])" "\1" :eregexp)
(merge-rule "~~" " ")
(merge-rule "---?" "-")
(merge-rule "\\TeX *" "TeX" :eregexp :again)
(merge-rule "\\LaTeX *" "LaTeX" :eregexp :again)
(merge-rule "\\MF *" "METAFONT" :eregexp :again)
(merge-rule "\\MP *" "METAPOST" :eregexp :again)

;; Ignore TeX commands by default. Some macros are known to be written
;; to index files where the arguments must be ignored as well. Our
;; argument parsing code is optimistic -- it will be possible to break
;; it. Let's wait for an error report and repair it then... ;-)

(merge-rule "\\discretionary *\{[^}]*\}\{[^}]*\}" "" :eregexp)
(merge-rule "\\kern *[-\.0-9a-z]* ?" "" :eregexp)

(merge-rule "\\[a-zA-Z@]+ *" "" :eregexp)
(merge-rule "\\[^a-zA-Z@]" "" :eregexp)
(merge-rule "[{}$]" "" :eregexp)



;;======================================================================
;;
;; $Log: tex.xdy,v $
;; Revision 1.3  2010/06/11 11:01:46  jschrod
;;     New 2.4 ordrules supports regexps with start-anchored matches.
;; Thus we can activate the leading blank processing rule. The
;; parenthesis-discard rule must trigger everywhere, not just at the
;; start of the index key.
;;     The blank suppression clause got optimized, it now triggers only
;; if there are multiple blanks and not for each appearing blank.
;;
;; Revision 1.2  2005/05/09 20:21:11  jschrod
;;     Support handling of some common macros for logos; ignore all other
;; TeX commands.
;;
;; Revision 1.1  2004/05/24 21:53:27  jschrod
;;     Standard modules, introduced in "LaTeX Companion Release".
;;
