org-element-export-snippet-parser: Fix when no closing @@

* lisp/org-element.el (org-element-export-snippet-parser): Return nil
when there is no closing @@.
* testing/lisp/test-org-element.el (test-org-element/context): Add
test.

Reported-by: Tom Alexander <tom@fizz.buzz>
Link: https://orgmode.org/list/fb61ea28-f004-4c25-adf7-69fc55683ed4@app.fastmail.com
This commit is contained in:
Ihor Radchenko 2023-08-15 11:37:37 +03:00
parent b89bc55867
commit e340dde63e
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
2 changed files with 15 additions and 8 deletions

View File

@ -3328,13 +3328,14 @@ Assume point is at the beginning of the snippet."
(- contents-end begin))))
(post-blank (skip-chars-forward " \t"))
(end (point)))
(org-element-create
'export-snippet
(list :back-end backend
:value value
:begin begin
:end end
:post-blank post-blank))))))
(when contents-end ; No match when no trailing "@@".
(org-element-create
'export-snippet
(list :back-end backend
:value value
:begin begin
:end end
:post-blank post-blank)))))))
(defun org-element-export-snippet-interpreter (export-snippet _)
"Interpret EXPORT-SNIPPET object as Org syntax."

View File

@ -4607,7 +4607,13 @@ Text
(should
(eq 'link
(org-test-with-temp-text "* Headline :file<point>:tags: :real:tag:"
(org-element-type (org-element-context))))))
(org-element-type (org-element-context)))))
;; Do not parse partial export snippets.
(should-not
(eq 'export-snippet
(org-test-with-temp-text
"<point>@@latex:\n\nparagraph\n\n@@"
(org-element-type (org-element-context))))))