Hi all,

I started playing with HyperLaTeX a few days ago, and only checked out
the mailing list just now.  I hope to use it to create course
materials that are as beautifully typeset on paper as they are
well-designed and navigable online.

One of the first things I hacked in was generating proper left and
right quotes from TeX's  `` and '' as  well as em and en dashes from
--- and --.  (Only afterwards did I see Harald Soleng's post for this
feature request.)

Unfortunately, I did this by hacking it into hyperlatex.el, before I
discovered that \HlxEval could probably do the trick within a .hlx
extension package.  At any rate, I'll post the diff to hyperlatex.el
here, if someone wants to try it.  At some point later, I will try to
re-implement it as a .hlx, if you think that's more appropriate.

Best wishes,
Chris

--- orig/hyperlatex.el  2004-11-12 11:54:28.000000000 -0500
+++ hyperlatex.el       2004-12-22 12:12:06.000000000 -0500
@@ -283,7 +283,7 @@
 ;  (concat "\\\\%{}]\\|\n[ ]*\r?\n\\|---?\\|``\\|''\\|\\?`\\|!`\\|"
 ;        hyperlatex-meta-|))
 (defvar hyperlatex-special-chars-basic-regexp
-  (concat "\\\\%{}]\\|---?\\|``\\|''\\|\\?`\\|!`\\|"
+  (concat "\\\\%{}]\\|---?\\|``?\\|''?\\|\\?`\\|!`\\|"
          hyperlatex-meta-|))
 
 (defvar hyperlatex-purify-regexp
@@ -739,7 +739,7 @@
 ;;; "Active" characters
 ;;;
 
-(put '-  'hyperlatex-active 'hyperlatex-format-ignore)
+(put '-  'hyperlatex-active 'hyperlatex-active-dash)
 (put '\` 'hyperlatex-active 'hyperlatex-active-backquote)
 (put '\' 'hyperlatex-active 'hyperlatex-active-quote)
 (put '%  'hyperlatex-active 'hyperlatex-active-percent)
@@ -758,19 +758,36 @@
 (defun hyperlatex-active-tilde ()
   (hyperlatex-gensym "nbsp"))
 
+(defun hyperlatex-active-dash ()
+  (let ((prechar (char-before (1- (point)))))
+    (cond ((= prechar ?-)
+           (delete-char -2)
+           (hyperlatex-gensym "mdash"))
+          (t
+           (delete-char -1)
+           (hyperlatex-gensym "ndash")))))
+
 (defun hyperlatex-active-quote ()
-  (delete-char -1)
-  (insert "\""))
+  (let ((prechar (preceding-char)))
+    (cond ((= prechar ?')
+           (delete-char -1)
+           (hyperlatex-gensym "#8221"))
+          (t
+           (hyperlatex-gensym "#8217")))))
 
 (defun hyperlatex-active-backquote ()
   (let ((prechar (preceding-char)))
-    (delete-char -1)
     (cond ((= prechar ?`)
-          (insert "\""))
+           (delete-char -1)
+           (hyperlatex-gensym "#8220"))
          ((= prechar ??)
+           (delete-char -1)
           (hyperlatex-gensym "#191"))
          ((= prechar ?!)
-          (hyperlatex-gensym "#161")))))
+           (delete-char -1)
+          (hyperlatex-gensym "#161"))
+          (t
+           (hyperlatex-gensym "#8216")))))
 
 ;;;
 ;;; ----------------------------------------------------------------------

Reply via email to