Function: org-element-latex-fragment-parser
org-element-latex-fragment-parser is a byte-compiled function defined
in org-element.el.gz.
Signature
(org-element-latex-fragment-parser)
Documentation
Parse LaTeX fragment at point, if any.
When at a LaTeX fragment, return a list whose car is
latex-fragment and cdr a plist with :value, :begin, :end,
and :post-blank as keywords. Otherwise, return nil.
Assume point is at the beginning of the LaTeX fragment.
Source Code
;; Defined in /usr/src/emacs/lisp/org/org-element.el.gz
;;;; LaTeX Fragment
(defun org-element-latex-fragment-parser ()
"Parse LaTeX fragment at point, if any.
When at a LaTeX fragment, return a list whose car is
`latex-fragment' and cdr a plist with `:value', `:begin', `:end',
and `:post-blank' as keywords. Otherwise, return nil.
Assume point is at the beginning of the LaTeX fragment."
(catch 'no-object
(save-excursion
(let* ((begin (point))
(after-fragment
(cond
((not (eq ?$ (char-after)))
(pcase (char-after (1+ (point)))
(?\( (search-forward "\\)" nil t))
(?\[ (search-forward "\\]" nil t))
(_
;; Macro.
(and (looking-at "\\\\[a-zA-Z]+\\*?\\(\\(\\[[^][\n{}]*\\]\\)\
\\|\\({[^{}\n]*}\\)\\)*")
(match-end 0)))))
((eq ?$ (char-after (1+ (point))))
(search-forward "$$" nil t 2))
(t
(and (not (eq ?$ (char-before)))
(not (memq (char-after (1+ (point)))
'(?\s ?\t ?\n ?, ?. ?\;)))
(search-forward "$" nil t 2)
(not (memq (char-before (match-beginning 0))
'(?\s ?\t ?\n ?, ?.)))
(looking-at-p
"\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|'\\|$\\)")
(point)))))
(post-blank
(if (not after-fragment) (throw 'no-object nil)
(goto-char after-fragment)
(skip-chars-forward " \t")))
(end (point)))
(list 'latex-fragment
(list :value (buffer-substring-no-properties begin after-fragment)
:begin begin
:end end
:post-blank post-blank))))))