* lisp/org-element.el (org-element-subscript-parser): Fix edge case
Fix when both subscript and underline object match in `org-element--object-lex'. * testing/lisp/test-org-element.el (test-org-element/underline-parser): Add new test. Reported-by: Tom Alexander <tom@fizz.buzz> Link: https://orgmode.org/list/dad964f5-c764-4dd5-9829-ca38e3fbeb0d@app.fastmail.com
This commit is contained in:
parent
ad07b2982f
commit
fe23bec607
|
@ -4087,24 +4087,25 @@ nil.
|
|||
|
||||
Assume point is at the underscore."
|
||||
(save-excursion
|
||||
(unless (bolp) (backward-char))
|
||||
(when (looking-at org-match-substring-regexp)
|
||||
(let ((bracketsp (if (match-beginning 4) t nil))
|
||||
(begin (match-beginning 2))
|
||||
(contents-begin (or (match-beginning 4)
|
||||
(match-beginning 3)))
|
||||
(contents-end (or (match-end 4) (match-end 3)))
|
||||
(post-blank (progn (goto-char (match-end 0))
|
||||
(skip-chars-forward " \t")))
|
||||
(end (point)))
|
||||
(org-element-create
|
||||
'subscript
|
||||
(list :begin begin
|
||||
:end end
|
||||
:use-brackets-p bracketsp
|
||||
:contents-begin contents-begin
|
||||
:contents-end contents-end
|
||||
:post-blank post-blank))))))
|
||||
(unless (bolp)
|
||||
(backward-char)
|
||||
(when (looking-at org-match-substring-regexp)
|
||||
(let ((bracketsp (if (match-beginning 4) t nil))
|
||||
(begin (match-beginning 2))
|
||||
(contents-begin (or (match-beginning 4)
|
||||
(match-beginning 3)))
|
||||
(contents-end (or (match-end 4) (match-end 3)))
|
||||
(post-blank (progn (goto-char (match-end 0))
|
||||
(skip-chars-forward " \t")))
|
||||
(end (point)))
|
||||
(org-element-create
|
||||
'subscript
|
||||
(list :begin begin
|
||||
:end end
|
||||
:use-brackets-p bracketsp
|
||||
:contents-begin contents-begin
|
||||
:contents-end contents-end
|
||||
:post-blank post-blank)))))))
|
||||
|
||||
(defun org-element-subscript-interpreter (subscript contents)
|
||||
"Interpret SUBSCRIPT object as Org syntax.
|
||||
|
|
|
@ -3219,7 +3219,13 @@ Outside list"
|
|||
(org-test-with-temp-text "_first line\nsecond line_"
|
||||
(org-element-map
|
||||
(org-element-parse-buffer) 'underline #'identity nil t)))
|
||||
'("first line\nsecond line"))))
|
||||
'("first line\nsecond line")))
|
||||
;; Nested underlines.
|
||||
(should
|
||||
(= 2
|
||||
(org-test-with-temp-text "__test__"
|
||||
(length
|
||||
(org-element-map (org-element-parse-buffer) 'underline 'identity))))))
|
||||
|
||||
|
||||
;;;; Verbatim
|
||||
|
|
Loading…
Reference in New Issue