Wrap "words separated by space characters" groups in LaTeX commands
This commit is contained in:
parent
5974a1c84a
commit
1011bba04e
36
README.org
36
README.org
@ -2262,24 +2262,24 @@ configuration.
|
|||||||
#'engrave-faces-latex--protect-content-mathescape
|
#'engrave-faces-latex--protect-content-mathescape
|
||||||
#'engrave-faces-latex--protect-content)
|
#'engrave-faces-latex--protect-content)
|
||||||
content)))
|
content)))
|
||||||
(if (string-match-p "\\`[\n[:space:]]+\\'" content)
|
;; Wrap "words separated by space characters" groups in LaTeX commands.
|
||||||
protected-content
|
;; Do not wrap newlines and other whitespace separating those groups.
|
||||||
;; Move newlines with whitespace outside the engrave face commands.
|
(let ((regexp (rx (or (group-n 1 (+ graph ) (* (*? print) (+ graph)))
|
||||||
(let ((regexp "\\(?1:[^\n]+\\)\\|\\(?2:\n[[:space:]]*\\)")
|
(group-n 2 (+ (any "\n" space))))))
|
||||||
(slug (when (and style
|
(slug (when (and style
|
||||||
(eq engrave-faces-latex-output-style 'preset))
|
(eq engrave-faces-latex-output-style 'preset))
|
||||||
(plist-get (cdr style) :slug)))
|
(plist-get (cdr style) :slug)))
|
||||||
(start 0)
|
(start 0)
|
||||||
(stack))
|
(stack))
|
||||||
(while (string-match regexp protected-content start)
|
(while (string-match regexp protected-content start)
|
||||||
(setq start (match-end 0))
|
(setq start (match-end 0))
|
||||||
(when-let ((pc (match-string 1 protected-content)))
|
(when-let ((pc (match-string 1 protected-content)))
|
||||||
(if (stringp slug)
|
(if (stringp slug)
|
||||||
(push (concat "\\EF" slug "{" pc "}") stack)
|
(push (concat "\\EF" slug "{" pc "}") stack)
|
||||||
(push (engrave-faces-latex-face-apply faces pc) stack)))
|
(push (engrave-faces-latex-face-apply faces pc) stack)))
|
||||||
(when-let ((pc (match-string 2 protected-content)))
|
(when-let ((pc (match-string 2 protected-content)))
|
||||||
(push pc stack)))
|
(push pc stack)))
|
||||||
(apply #'concat (nreverse stack)))))))
|
(apply #'concat (nreverse stack))))))
|
||||||
|
|
||||||
(with-eval-after-load 'emacs
|
(with-eval-after-load 'emacs
|
||||||
(defun toggle-engrave-faces-latex-face-mapper-override ()
|
(defun toggle-engrave-faces-latex-face-mapper-override ()
|
||||||
|
Loading…
Reference in New Issue
Block a user