1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-21 06:55:35 +00:00

ox-texinfo: Fix edge case with - Variable: nil:: definition

* lisp/ox-texinfo.el (org-texinfo--split-definition): Do not store
definition options as :attr_texinfo read by
`org-export-read-attribute'.  `org-export-read-attribute' is incapable
of reading literal nil.  Instead, store the options literally, as is,
in a special non-standard syntax node property.
(org-texinfo-special-block): Make use of syntax node property used by
`org-texinfo--split-definition', when present.
* testing/lisp/test-ox-texinfo.el (test-ox-texinfo/definition): New
test.

Reported-by: 8dcc <8dcc.git@gmail.com>
Link: https://orgmode.org/list/87plo98a8g.fsf@gmail.com
This commit is contained in:
Ihor Radchenko 2024-10-14 20:39:47 +02:00
parent 90945e16aa
commit da0f6eff75
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
2 changed files with 51 additions and 2 deletions

View File

@ -680,7 +680,11 @@ specified by CMD and ARGS."
(org-element-insert-before
(apply #'org-element-create 'special-block
(list :type cmd
:attr_texinfo (list (format ":options %s" args))
:ox-texinfo--options args
;; Option can be nil that cannot be recorgnized
;; literally by `org-export-read-attribute', so we
;; use dedicated property instead
;; :attr_texinfo (list (format ":options %s" args))
:post-blank (if contents 1 0))
(mapc #'org-element-extract contents))
plain-list))
@ -1689,7 +1693,10 @@ holding contextual information."
"Transcode a SPECIAL-BLOCK element from Org to Texinfo.
CONTENTS holds the contents of the block. INFO is a plist used
as a communication channel."
(let ((opt (org-export-read-attribute :attr_texinfo special-block :options))
(let ((opt (or
;; See `org-texinfo--split-definition'
(org-element-property :ox-texinfo--options special-block)
(org-export-read-attribute :attr_texinfo special-block :options)))
(type (org-element-property :type special-block)))
(format "@%s%s\n%s@end %s"
type

View File

@ -403,5 +403,47 @@ body
(re-search-forward
"^@chapter Heading 2 (@ref{Heading 1, , Heading 1})$")))))))
;;; Definitions
(ert-deftest test-ox-texinfo/definition ()
"Test definitions."
(should
(org-test-with-temp-text
(string-join
(list "- Variable: name ::"
" Description")
"\n")
(let ((export-buffer "*Test Texinfo Export*")
(org-export-show-temporary-export-buffer nil))
(org-export-to-buffer 'texinfo export-buffer
nil nil nil nil nil
#'texinfo-mode)
(with-current-buffer export-buffer
(goto-char (point-min))
(and
(re-search-forward "@defvar name")
(re-search-forward "Description")
(re-search-forward "@end defvar"))))))
;; Edge case: Variable name = nil
(should
(org-test-with-temp-text
(string-join
(list "- Variable: nil ::"
" Description")
"\n")
(let ((export-buffer "*Test Texinfo Export*")
(org-export-show-temporary-export-buffer nil))
(org-export-to-buffer 'texinfo export-buffer
nil nil nil nil nil
#'texinfo-mode)
(with-current-buffer export-buffer
(goto-char (point-min))
(and
(re-search-forward "@defvar nil")
(re-search-forward "Description")
(re-search-forward "@end defvar")))))))
(provide 'test-ox-texinfo)
;;; test-ox-texinfo.el end here