forked from mirrors/org-mode
NOPUSH org: Don't fill displayed equations in text
* list/org.el (org-fill-element): If a displayed equation (\[ ... \]) starts on its own line, it should not be filled into the rest of the text. I.e., some nice text \[ 1+1=2 \] more text. should not become, some nice text \[ 1+1=3 \] more text. While the above example may not look bad, with non-trivial equations this can become quite messy.
This commit is contained in:
parent
43ccf588f5
commit
464982dab4
11
lisp/org.el
11
lisp/org.el
|
@ -19401,12 +19401,23 @@ a footnote definition, try to fill the first paragraph within."
|
|||
(save-excursion
|
||||
(goto-char beg)
|
||||
(let ((cuts (list beg)))
|
||||
;; Cut fill on line breaks.
|
||||
(while (re-search-forward "\\\\\\\\[ \t]*\n" end t)
|
||||
(when (org-element-type-p
|
||||
(save-excursion (backward-char)
|
||||
(org-element-context))
|
||||
'line-break)
|
||||
(push (point) cuts)))
|
||||
;; Cut fill on displayed equations.
|
||||
(while (re-search-forward "^[ \t]*\\\\\\[" end t)
|
||||
(let ((el (org-element-context)))
|
||||
(when (eq 'latex-fragment (org-element-type el))
|
||||
(setf cuts (append
|
||||
(list (org-element-property :end el)
|
||||
(- (org-element-property :end el) 2)
|
||||
(+ (org-element-property :begin el) 2)
|
||||
(org-element-property :begin el))
|
||||
cuts)))))
|
||||
(dolist (c (delq end cuts))
|
||||
(fill-region-as-paragraph c end justify)
|
||||
(setq end c))))
|
||||
|
|
Loading…
Reference in New Issue