forked from mirrors/org-mode
ox-texinfo: Fix `org-texinfo-classes'
* lisp/ox-texinfo.el (org-texinfo-classes): Change default value. Update docstring. (org-texinfo-template): Insert header string from current class after "@settitle" command. Always provide "\input texinfo" at the beginning of the output. Header string in the class was inserted before "@setfilename". Texinfo ignores anything between "\input texinfo" and that command, making any value besides the default one useless.
This commit is contained in:
parent
3ff46fdbff
commit
4b6f9b25b8
|
@ -162,19 +162,42 @@ If `nil' it will default to `buffer-file-coding-system'."
|
||||||
|
|
||||||
(defcustom org-texinfo-classes
|
(defcustom org-texinfo-classes
|
||||||
'(("info"
|
'(("info"
|
||||||
"\\input texinfo @c -*- texinfo -*-"
|
"@documentencoding AUTO\n@documentlanguage AUTO"
|
||||||
("@chapter %s" . "@unnumbered %s")
|
("@chapter %s" . "@unnumbered %s")
|
||||||
("@section %s" . "@unnumberedsec %s")
|
("@section %s" . "@unnumberedsec %s")
|
||||||
("@subsection %s" . "@unnumberedsubsec %s")
|
("@subsection %s" . "@unnumberedsubsec %s")
|
||||||
("@subsubsection %s" . "@unnumberedsubsubsec %s")))
|
("@subsubsection %s" . "@unnumberedsubsubsec %s")))
|
||||||
"Alist of Texinfo classes and associated header and structure.
|
"Alist of Texinfo classes and associated header and structure.
|
||||||
If #+Texinfo_CLASS is set in the buffer, use its value and the
|
If #+TEXINFO_CLASS is set in the buffer, use its value and the
|
||||||
associated information. Here is the structure of each cell:
|
associated information. Here is the structure of each cell:
|
||||||
|
|
||||||
\(class-name
|
\(class-name
|
||||||
header-string
|
header-string
|
||||||
\(numbered-section . unnumbered-section\)
|
\(numbered-section . unnumbered-section)
|
||||||
...\)
|
...)
|
||||||
|
|
||||||
|
|
||||||
|
The header string
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
The header string is inserted in the header of the generated
|
||||||
|
document, right after \"@setfilename\" and \"@settitle\"
|
||||||
|
commands.
|
||||||
|
|
||||||
|
If it contains the special string
|
||||||
|
|
||||||
|
\"@documentencoding AUTO\"
|
||||||
|
|
||||||
|
\"AUTO\" will be replaced with an appropriate coding system. See
|
||||||
|
`org-texinfo-coding-system' for more information. Likewise, if
|
||||||
|
the string contains the special string
|
||||||
|
|
||||||
|
\"@documentlanguage AUTO\"
|
||||||
|
|
||||||
|
\"AUTO\" will be replaced with the language defined in the
|
||||||
|
buffer, through #+LANGUAGE keyword, or globally, with
|
||||||
|
`org-export-default-language', which see.
|
||||||
|
|
||||||
|
|
||||||
The sectioning structure
|
The sectioning structure
|
||||||
------------------------
|
------------------------
|
||||||
|
@ -186,10 +209,12 @@ section string and will be replaced by the title of the section.
|
||||||
|
|
||||||
Instead of a list of sectioning commands, you can also specify
|
Instead of a list of sectioning commands, you can also specify
|
||||||
a function name. That function will be called with two
|
a function name. That function will be called with two
|
||||||
parameters, the \(reduced) level of the headline, and a predicate
|
parameters, the reduced) level of the headline, and a predicate
|
||||||
non-nil when the headline should be numbered. It must return
|
non-nil when the headline should be numbered. It must return
|
||||||
a format string in which the section title will be added."
|
a format string in which the section title will be added."
|
||||||
:group 'org-export-texinfo
|
:group 'org-export-texinfo
|
||||||
|
:version "24.4"
|
||||||
|
:package-version '(Org . "8.2")
|
||||||
:type '(repeat
|
:type '(repeat
|
||||||
(list (string :tag "Texinfo class")
|
(list (string :tag "Texinfo class")
|
||||||
(string :tag "Texinfo header")
|
(string :tag "Texinfo header")
|
||||||
|
@ -682,8 +707,6 @@ holding export options."
|
||||||
(info-filename (or (plist-get info :texinfo-filename)
|
(info-filename (or (plist-get info :texinfo-filename)
|
||||||
(file-name-nondirectory
|
(file-name-nondirectory
|
||||||
(org-export-output-file-name ".info"))))
|
(org-export-output-file-name ".info"))))
|
||||||
(header (nth 1 (assoc (plist-get info :texinfo-class)
|
|
||||||
org-texinfo-classes)))
|
|
||||||
;; Copying data is the contents of the first headline in
|
;; Copying data is the contents of the first headline in
|
||||||
;; parse tree with a non-nil copying property.
|
;; parse tree with a non-nil copying property.
|
||||||
(copying (org-element-map (plist-get info :parse-tree) 'headline
|
(copying (org-element-map (plist-get info :parse-tree) 'headline
|
||||||
|
@ -692,24 +715,31 @@ holding export options."
|
||||||
(org-element-contents hl)))
|
(org-element-contents hl)))
|
||||||
info t)))
|
info t)))
|
||||||
(concat
|
(concat
|
||||||
;; Header
|
"\\input texinfo @c -*- texinfo -*-\n"
|
||||||
header "\n"
|
|
||||||
"@c %**start of header\n"
|
"@c %**start of header\n"
|
||||||
;; Filename and Title
|
|
||||||
"@setfilename " info-filename "\n"
|
"@setfilename " info-filename "\n"
|
||||||
(format "@settitle %s\n" title)
|
(format "@settitle %s\n" title)
|
||||||
;; Coding system.
|
;; Insert class-defined header.
|
||||||
(format
|
(org-element-normalize-string
|
||||||
"@documentencoding %s\n"
|
(let ((header (nth 1 (assoc (plist-get info :texinfo-class)
|
||||||
(catch 'coding-system
|
org-texinfo-classes)))
|
||||||
(let ((case-fold-search t)
|
(coding
|
||||||
(name (symbol-name (or org-texinfo-coding-system
|
(catch 'coding-system
|
||||||
buffer-file-coding-system))))
|
(let ((case-fold-search t)
|
||||||
(dolist (system org-texinfo-supported-coding-systems "UTF-8")
|
(name (symbol-name (or org-texinfo-coding-system
|
||||||
(when (org-string-match-p (regexp-quote system) name)
|
buffer-file-coding-system))))
|
||||||
(throw 'coding-system system))))))
|
(dolist (system org-texinfo-supported-coding-systems "UTF-8")
|
||||||
;; Language.
|
(when (org-string-match-p (regexp-quote system) name)
|
||||||
(format "@documentlanguage %s\n" (plist-get info :language))
|
(throw 'coding-system system))))))
|
||||||
|
(language (plist-get info :language))
|
||||||
|
(case-fold-search nil))
|
||||||
|
;; Auto coding system.
|
||||||
|
(replace-regexp-in-string
|
||||||
|
"^@documentencoding \\(AUTO\\)$"
|
||||||
|
coding
|
||||||
|
(replace-regexp-in-string
|
||||||
|
"^@documentlanguage \\(AUTO\\)$" language header nil nil 1)
|
||||||
|
nil nil 1)))
|
||||||
;; Additional header options set by #+TEXINFO_HEADER.
|
;; Additional header options set by #+TEXINFO_HEADER.
|
||||||
(let ((texinfo-header (plist-get info :texinfo-header)))
|
(let ((texinfo-header (plist-get info :texinfo-header)))
|
||||||
(and texinfo-header (org-element-normalize-string texinfo-header)))
|
(and texinfo-header (org-element-normalize-string texinfo-header)))
|
||||||
|
|
Loading…
Reference in New Issue