mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-11-24 07:20:29 +00:00
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
This commit is contained in:
parent
8fd21d04ce
commit
d2ce1c6ec1
@ -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)
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user