forked from mirrors/org-mode
element: Fix parsing of inline footnotes
* lisp/org-element.el (org-element--pair-round-table): (org-element--pair-square-table): (org-element--pair-curly-table): De-activate all but one pair of parenthesis. * testing/lisp/test-org-element.el (test-org-element/footnote-reference-parser): Add test. Reported-by: Greg Minshall <minshall@umich.edu> <http://lists.gnu.org/r/emacs-orgmode/2022-02/msg00369.html>
This commit is contained in:
parent
33543d2aa8
commit
bafeaf161c
|
@ -396,31 +396,25 @@ still has an entry since one of its properties (`:title') does.")
|
|||
"Alist between element types and locations of secondary values.")
|
||||
|
||||
(defconst org-element--pair-round-table
|
||||
(let ((table (make-syntax-table)))
|
||||
(let ((table (make-char-table 'syntax-table '(2))))
|
||||
(modify-syntax-entry ?\( "()" table)
|
||||
(modify-syntax-entry ?\) ")(" table)
|
||||
(dolist (char '(?\{ ?\} ?\[ ?\] ?\< ?\>) table)
|
||||
(modify-syntax-entry char " " table)))
|
||||
"Table used internally to pair only round brackets.
|
||||
Other brackets are treated as spaces.")
|
||||
table)
|
||||
"Table used internally to pair only round brackets.")
|
||||
|
||||
(defconst org-element--pair-square-table
|
||||
(let ((table (make-syntax-table)))
|
||||
(let ((table (make-char-table 'syntax-table '(2))))
|
||||
(modify-syntax-entry ?\[ "(]" table)
|
||||
(modify-syntax-entry ?\] ")[" table)
|
||||
(dolist (char '(?\{ ?\} ?\( ?\) ?\< ?\>) table)
|
||||
(modify-syntax-entry char " " table)))
|
||||
"Table used internally to pair only square brackets.
|
||||
Other brackets are treated as spaces.")
|
||||
table)
|
||||
"Table used internally to pair only square brackets.")
|
||||
|
||||
(defconst org-element--pair-curly-table
|
||||
(let ((table (make-syntax-table)))
|
||||
(let ((table (make-char-table 'syntax-table '(2))))
|
||||
(modify-syntax-entry ?\{ "(}" table)
|
||||
(modify-syntax-entry ?\} "){" table)
|
||||
(dolist (char '(?\[ ?\] ?\( ?\) ?\< ?\>) table)
|
||||
(modify-syntax-entry char " " table)))
|
||||
"Table used internally to pair only curly brackets.
|
||||
Other brackets are treated as spaces.")
|
||||
table)
|
||||
"Table used internally to pair only curly brackets.")
|
||||
|
||||
(defun org-element--parse-paired-brackets (char)
|
||||
"Parse paired brackets at point.
|
||||
|
|
|
@ -1161,6 +1161,15 @@ Some other text
|
|||
(org-test-with-temp-text "Text[fn::def]"
|
||||
(org-element-map
|
||||
(org-element-parse-buffer) 'footnote-reference 'identity)))
|
||||
;; Parse inline references with syntax loaded characters.
|
||||
(should
|
||||
(eq 'footnote-reference
|
||||
(org-test-with-temp-text "Text[fn<point>::(def]"
|
||||
(org-element-type (org-element-context)))))
|
||||
(should
|
||||
(eq 'footnote-reference
|
||||
(org-test-with-temp-text "Text[fn<point>::\"def]"
|
||||
(org-element-type (org-element-context)))))
|
||||
;; Parse nested footnotes.
|
||||
(should
|
||||
(= 2
|
||||
|
|
Loading…
Reference in New Issue