diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2016-12-07 00:45:52 +0100 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2016-12-07 00:45:52 +0100 |
commit | c797cc0f8786493d097675e0c74f4cfdde42831c (patch) | |
tree | 872b5eaf572db900c9d150303054a2989df219cf | |
parent | 6ed3fc8010bd81b49f68b467b464b4365a55cf70 (diff) | |
download | org-mode-c797cc0f8786493d097675e0c74f4cfdde42831c.tar.gz |
ox-latex: Do not generate nested sub/superscripts
* lisp/ox-latex.el (org-latex--wrap-latex-math-block): Do not wrap
consecutive sub or super-scripts within the same block.
Reported-by: Scott Otterson <scotto@sharpleaf.org>
<http://permalink.gmane.org/gmane.emacs.orgmode/110589>
-rw-r--r-- | lisp/ox-latex.el | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index aecbb32..4d65922 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -2698,22 +2698,23 @@ channel." DATA is a parse tree or a secondary string. INFO is a plist containing export options. Modify DATA by side-effect and return it." (let ((valid-object-p - ;; Non-nil when OBJ can be added to the latex math block. - (lambda (obj) + ;; Non-nil when OBJ can be added to the latex math block B. + (lambda (obj b) (pcase (org-element-type obj) (`entity (org-element-property :latex-math-p obj)) (`latex-fragment (let ((value (org-element-property :value obj))) (or (string-prefix-p "\\(" value) (string-match-p "\\`\\$[^$]" value)))) - ((or `subscript `superscript) t))))) + ((and type (or `subscript `superscript)) + (not (org-element-map b type #'identity info t))))))) (org-element-map data '(entity latex-fragment subscript superscript) (lambda (object) ;; Skip objects already wrapped. (when (and (not (eq (org-element-type (org-element-property :parent object)) 'latex-math-block)) - (funcall valid-object-p object)) + (funcall valid-object-p object nil)) (let ((math-block (list 'latex-math-block nil)) (next-elements (org-export-get-next-element object info t)) (last object)) @@ -2725,16 +2726,17 @@ containing export options. Modify DATA by side-effect and return it." ;; MATH-BLOCK swallows consecutive math objects. (catch 'exit (dolist (next next-elements) - (if (not (funcall valid-object-p next)) (throw 'exit nil) - (org-element-extract-element next) - (org-element-adopt-elements math-block next) - ;; Eschew the case: \beta$x$ -> \(\betax\). - (unless (memq (org-element-type next) - '(subscript superscript)) - (org-element-put-property last :post-blank 1)) - (setq last next) - (when (> (or (org-element-property :post-blank next) 0) 0) - (throw 'exit nil)))))) + (unless (funcall valid-object-p next math-block) + (throw 'exit nil)) + (org-element-extract-element next) + (org-element-adopt-elements math-block next) + ;; Eschew the case: \beta$x$ -> \(\betax\). + (unless (memq (org-element-type next) + '(subscript superscript)) + (org-element-put-property last :post-blank 1)) + (setq last next) + (when (> (or (org-element-property :post-blank next) 0) 0) + (throw 'exit nil))))) (org-element-put-property math-block :post-blank (org-element-property :post-blank last))))) info nil '(subscript superscript latex-math-block) t) |