diff options
| author | Ihor Radchenko <yantar92@posteo.net> | 2023-12-16 15:00:42 +0100 |
|---|---|---|
| committer | Ihor Radchenko <yantar92@posteo.net> | 2023-12-16 15:10:29 +0100 |
| commit | d2ce1c6ec1b52fcf03f08103f18f228763eae88a (patch) | |
| tree | 0faaefd2d8e729117eaa6fb6c34a61230ca690e7 | |
| parent | 8fd21d04ce222ba2caeaafb2c7b9484bfbb7c8d8 (diff) | |
| download | org-mode-d2ce1c6ec.tar.gz | |
lisp/ox-texinfo.el: Fix @menu in headlines without contents
* lisp/ox-texinfo.el (org-texinfo--normalize-headlines): Do not rely
upon undocumented implementation side-effects in `org-element-create'
that have been changed.
*
testing/lisp/test-ox-texinfo.el (test-ox-texinfo/normalize-headlines):
New test.
Reported-by: Jonas Bernoulli <jonas@bernoul.li>
Link: https://orgmode.org/list/87zfybnqwf.fsf@bernoul.li
| -rw-r--r-- | lisp/ox-texinfo.el | 4 | ||||
| -rw-r--r-- | testing/lisp/test-ox-texinfo.el | 21 |
2 files changed, 24 insertions, 1 deletions
diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el index b8d95c9..f99a3e0 100644 --- a/lisp/ox-texinfo.el +++ b/lisp/ox-texinfo.el @@ -503,7 +503,9 @@ Return new tree." (let ((first (org-element-map contents '(headline section) #'identity info t))) (unless (org-element-type-p first 'section) - (org-element-create 'section nil contents)))))) + (apply #'org-element-set-contents + hl + (org-element-create 'section `(:parent ,hl)) contents)))))) info) tree) diff --git a/testing/lisp/test-ox-texinfo.el b/testing/lisp/test-ox-texinfo.el index 3839550..f69b2ad 100644 --- a/testing/lisp/test-ox-texinfo.el +++ b/testing/lisp/test-ox-texinfo.el @@ -324,5 +324,26 @@ nil nil nil nil nil #'texinfo-mode))))) + +;;; Filters + +(ert-deftest test-ox-texinfo/normalize-headlines () + "Test adding empty sections to headlines without one." + (org-test-with-temp-text + "* only subsections, no direct content +** sub 1 +body +** sub 2 +body +" + (let ((tree (org-element-parse-buffer))) + (setq tree (org-texinfo--normalize-headlines tree nil nil)) + (let* ((first-heading (car (org-element-contents tree))) + (section (car (org-element-contents first-heading)))) + (should (org-element-type-p first-heading 'headline)) + (should (org-element-type-p section 'section)) + (should-not (org-element-contents section)) + (should (eq first-heading (org-element-parent section))))))) + (provide 'test-ox-texinfo) ;;; test-ox-texinfo.el end here |
