mirror of
https://github.com/vale981/emacs-jupyter
synced 2025-03-05 07:41:37 -05:00
Be more intelligent when parsing LaTeX
It seems `org-element-latex-fragment-parser` expects that a latex fragment can really be parsed because there were false positives when it was called trying to parse a latex environment such as `\begin{equation*}...\end{equation*}`. It would consider `\begin{equation*}` as the fragment.
This commit is contained in:
parent
e378103db1
commit
8e534edad0
1 changed files with 15 additions and 8 deletions
|
@ -568,14 +568,21 @@ As an example, if DATA only contains the mimetype
|
|||
&optional _metadata)
|
||||
(if (member "raw" (alist-get :result-params params))
|
||||
(with-temp-buffer
|
||||
(save-excursion (insert data))
|
||||
(or (save-excursion (org-element-latex-fragment-parser))
|
||||
(let ((env (ignore-errors
|
||||
(org-element-latex-environment-parser
|
||||
(point-max) nil))))
|
||||
(if (eq (org-element-type env) 'latex-environment) env
|
||||
(jupyter-org-latex-environment
|
||||
(concat "\
|
||||
(insert data)
|
||||
(goto-char (point-min))
|
||||
;; Try to determine if we are in an environment or fragment
|
||||
(if (save-excursion
|
||||
(forward-char 2)
|
||||
(org-inside-LaTeX-fragment-p))
|
||||
(org-element-latex-fragment-parser)
|
||||
;; If we are not in a fragment, try to parse an environment
|
||||
(let ((env (ignore-errors
|
||||
(org-element-latex-environment-parser
|
||||
(point-max) nil))))
|
||||
(if (eq (org-element-type env) 'latex-environment) env
|
||||
;; If all else fails, wrap DATA in a minipage environment
|
||||
(jupyter-org-latex-environment
|
||||
(concat "\
|
||||
\\begin{minipage}{\\textwidth}
|
||||
\\begin{flushright}\n" data "\n\\end{flushright}
|
||||
\\end{minipage}\n"))))))
|
||||
|
|
Loading…
Add table
Reference in a new issue