mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-11-21 06:55:35 +00:00
ox-texinfo: Small refactoring
* lisp/ox-texinfo.el (org-texinfo--normalize-headlines): Do not set pre blanks since the value is now hard-coded. (org-texinfo-headline): Force one blank line before contents, when non empty. Refactoring. (org-texinfo-src-block): Refactor code. Comply to predicate naming.
This commit is contained in:
parent
e112f3c0df
commit
57644f7ebf
@ -414,12 +414,11 @@ is a plist used as a communication channel.
|
||||
|
||||
Make sure every headline in TREE contains a section, since those
|
||||
are required to install a menu. Also put exactly one blank line
|
||||
at the beginning and the end of each section.
|
||||
at the end of each section.
|
||||
|
||||
Return new tree."
|
||||
(org-element-map tree 'headline
|
||||
(lambda (hl)
|
||||
(org-element-put-property hl :pre-blank 1)
|
||||
(org-element-put-property hl :post-blank 1)
|
||||
(let ((contents (org-element-contents hl)))
|
||||
(when contents
|
||||
@ -798,8 +797,7 @@ holding contextual information."
|
||||
(when tags
|
||||
(format " :%s:"
|
||||
(mapconcat 'identity tags ":"))))))
|
||||
(pre-blanks
|
||||
(make-string (org-element-property :pre-blank headline) ?\n)))
|
||||
(contents (if (org-string-nw-p contents) (concat "\n" contents) "")))
|
||||
(cond
|
||||
;; Case 1: This is a footnote section: ignore it.
|
||||
((org-element-property :footnote-section-p headline) nil)
|
||||
@ -814,33 +812,23 @@ holding contextual information."
|
||||
(format
|
||||
section-fmt
|
||||
full-text
|
||||
(concat pre-blanks contents (and (org-string-nw-p contents) "\n")
|
||||
(if (member index '("cp" "fn" "ky" "pg" "tp" "vr"))
|
||||
(concat "@printindex " index))))))
|
||||
(concat contents
|
||||
(and (member index '("cp" "fn" "ky" "pg" "tp" "vr"))
|
||||
(concat "\n@printindex " index))))))
|
||||
;; Case 4: This is a deep sub-tree: export it as a list item.
|
||||
;; Also export as items headlines for which no section
|
||||
;; format has been found.
|
||||
((or (not section-fmt) (org-export-low-level-p headline info))
|
||||
;; Build the real contents of the sub-tree.
|
||||
(let ((low-level-body
|
||||
(concat
|
||||
;; If the headline is the first sibling, start a list.
|
||||
(when (org-export-first-sibling-p headline info)
|
||||
(format "@%s\n" (if numberedp 'enumerate 'itemize)))
|
||||
;; Itemize headline
|
||||
"@item\n" full-text "\n" pre-blanks contents)))
|
||||
;; If headline is not the last sibling simply return
|
||||
;; LOW-LEVEL-BODY. Otherwise, also close the list, before any
|
||||
;; blank line.
|
||||
(if (not (org-export-last-sibling-p headline info)) low-level-body
|
||||
(replace-regexp-in-string
|
||||
"[ \t\n]*\\'"
|
||||
(format "\n@end %s" (if numberedp 'enumerate 'itemize))
|
||||
low-level-body))))
|
||||
(concat (and (org-export-first-sibling-p headline info)
|
||||
(format "@%s\n" (if numberedp 'enumerate 'itemize)))
|
||||
"@item\n" full-text "\n"
|
||||
contents
|
||||
(if (org-export-last-sibling-p headline info)
|
||||
(format "@end %s" (if numberedp 'enumerate 'itemize))
|
||||
"\n")))
|
||||
;; Case 5: Standard headline. Export it as a section.
|
||||
(t
|
||||
(concat node
|
||||
(format section-fmt full-text (concat pre-blanks contents)))))))
|
||||
(t (concat node (format section-fmt full-text contents))))))
|
||||
|
||||
;;;; Inline Src Block
|
||||
|
||||
@ -1253,19 +1241,11 @@ as a communication channel."
|
||||
"Transcode a SRC-BLOCK element from Org to Texinfo.
|
||||
CONTENTS holds the contents of the item. INFO is a plist holding
|
||||
contextual information."
|
||||
(let* ((lang (org-element-property :language src-block))
|
||||
(lisp-p (string-match-p "lisp" lang))
|
||||
(src-contents (org-texinfo--sanitize-content
|
||||
(org-export-format-code-default src-block info))))
|
||||
(cond
|
||||
;; Case 1. Lisp Block
|
||||
(lisp-p
|
||||
(format "@lisp\n%s@end lisp"
|
||||
src-contents))
|
||||
;; Case 2. Other blocks
|
||||
(t
|
||||
(format "@example\n%s@end example"
|
||||
src-contents)))))
|
||||
(let ((lispp (org-string-match-p "lisp"
|
||||
(org-element-property :language src-block)))
|
||||
(code (org-texinfo--sanitize-content
|
||||
(org-export-format-code-default src-block info))))
|
||||
(format (if lispp "@lisp\n%s@end lisp" "@example\n%s@end example") code)))
|
||||
|
||||
;;;; Statistics Cookie
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user