ox-texinfo.el 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670
  1. ;;; ox-texinfo.el --- Texinfo Back-End for Org Export Engine
  2. ;; Copyright (C) 2012-2015 Free Software Foundation, Inc.
  3. ;; Author: Jonathan Leech-Pepin <jonathan.leechpepin at gmail dot com>
  4. ;; Keywords: outlines, hypermedia, calendar, wp
  5. ;; This file is part of GNU Emacs.
  6. ;; GNU Emacs is free software: you can redistribute it and/or modify
  7. ;; it under the terms of the GNU General Public License as published by
  8. ;; the Free Software Foundation, either version 3 of the License, or
  9. ;; (at your option) any later version.
  10. ;; GNU Emacs is distributed in the hope that it will be useful,
  11. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ;; GNU General Public License for more details.
  14. ;; You should have received a copy of the GNU General Public License
  15. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  16. ;;; Commentary:
  17. ;;
  18. ;; See Org manual for details.
  19. ;;; Code:
  20. (eval-when-compile (require 'cl))
  21. (require 'ox)
  22. (defvar orgtbl-exp-regexp)
  23. ;;; Define Back-End
  24. (org-export-define-backend 'texinfo
  25. '((bold . org-texinfo-bold)
  26. (center-block . org-texinfo-center-block)
  27. (clock . org-texinfo-clock)
  28. (code . org-texinfo-code)
  29. (drawer . org-texinfo-drawer)
  30. (dynamic-block . org-texinfo-dynamic-block)
  31. (entity . org-texinfo-entity)
  32. (example-block . org-texinfo-example-block)
  33. (export-block . org-texinfo-export-block)
  34. (export-snippet . org-texinfo-export-snippet)
  35. (fixed-width . org-texinfo-fixed-width)
  36. (footnote-definition . org-texinfo-footnote-definition)
  37. (footnote-reference . org-texinfo-footnote-reference)
  38. (headline . org-texinfo-headline)
  39. (inline-src-block . org-texinfo-inline-src-block)
  40. (inlinetask . org-texinfo-inlinetask)
  41. (italic . org-texinfo-italic)
  42. (item . org-texinfo-item)
  43. (keyword . org-texinfo-keyword)
  44. (line-break . org-texinfo-line-break)
  45. (link . org-texinfo-link)
  46. (node-property . org-texinfo-node-property)
  47. (paragraph . org-texinfo-paragraph)
  48. (plain-list . org-texinfo-plain-list)
  49. (plain-text . org-texinfo-plain-text)
  50. (planning . org-texinfo-planning)
  51. (property-drawer . org-texinfo-property-drawer)
  52. (quote-block . org-texinfo-quote-block)
  53. (radio-target . org-texinfo-radio-target)
  54. (section . org-texinfo-section)
  55. (special-block . org-texinfo-special-block)
  56. (src-block . org-texinfo-src-block)
  57. (statistics-cookie . org-texinfo-statistics-cookie)
  58. (subscript . org-texinfo-subscript)
  59. (superscript . org-texinfo-superscript)
  60. (table . org-texinfo-table)
  61. (table-cell . org-texinfo-table-cell)
  62. (table-row . org-texinfo-table-row)
  63. (target . org-texinfo-target)
  64. (template . org-texinfo-template)
  65. (timestamp . org-texinfo-timestamp)
  66. (verbatim . org-texinfo-verbatim)
  67. (verse-block . org-texinfo-verse-block))
  68. :export-block "TEXINFO"
  69. :filters-alist
  70. '((:filter-headline . org-texinfo--filter-section-blank-lines)
  71. (:filter-parse-tree . org-texinfo--normalize-headlines)
  72. (:filter-section . org-texinfo--filter-section-blank-lines))
  73. :menu-entry
  74. '(?i "Export to Texinfo"
  75. ((?t "As TEXI file" org-texinfo-export-to-texinfo)
  76. (?i "As INFO file" org-texinfo-export-to-info)
  77. (?o "As INFO file and open"
  78. (lambda (a s v b)
  79. (if a (org-texinfo-export-to-info t s v b)
  80. (org-open-file (org-texinfo-export-to-info nil s v b)))))))
  81. :options-alist
  82. '((:texinfo-filename "TEXINFO_FILENAME" nil nil t)
  83. (:texinfo-class "TEXINFO_CLASS" nil org-texinfo-default-class t)
  84. (:texinfo-header "TEXINFO_HEADER" nil nil newline)
  85. (:texinfo-post-header "TEXINFO_POST_HEADER" nil nil newline)
  86. (:subtitle "SUBTITLE" nil nil parse)
  87. (:subauthor "SUBAUTHOR" nil nil newline)
  88. (:texinfo-dircat "TEXINFO_DIR_CATEGORY" nil nil t)
  89. (:texinfo-dirtitle "TEXINFO_DIR_TITLE" nil nil t)
  90. (:texinfo-dirdesc "TEXINFO_DIR_DESC" nil nil t)
  91. (:texinfo-printed-title "TEXINFO_PRINTED_TITLE" nil nil t)
  92. ;; Other variables.
  93. (:texinfo-classes nil nil org-texinfo-classes)
  94. (:texinfo-format-headline-function nil nil org-texinfo-format-headline-function)
  95. (:texinfo-node-description-column nil nil org-texinfo-node-description-column)
  96. (:texinfo-active-timestamp-format nil nil org-texinfo-active-timestamp-format)
  97. (:texinfo-inactive-timestamp-format nil nil org-texinfo-inactive-timestamp-format)
  98. (:texinfo-diary-timestamp-format nil nil org-texinfo-diary-timestamp-format)
  99. (:texinfo-link-with-unknown-path-format nil nil org-texinfo-link-with-unknown-path-format)
  100. (:texinfo-tables-verbatim nil nil org-texinfo-tables-verbatim)
  101. (:texinfo-table-scientific-notation nil nil org-texinfo-table-scientific-notation)
  102. (:texinfo-def-table-markup nil nil org-texinfo-def-table-markup)
  103. (:texinfo-text-markup-alist nil nil org-texinfo-text-markup-alist)
  104. (:texinfo-format-drawer-function nil nil org-texinfo-format-drawer-function)
  105. (:texinfo-format-inlinetask-function nil nil org-texinfo-format-inlinetask-function)))
  106. ;;; User Configurable Variables
  107. (defgroup org-export-texinfo nil
  108. "Options for exporting Org mode files to Texinfo."
  109. :tag "Org Export Texinfo"
  110. :version "24.4"
  111. :package-version '(Org . "8.0")
  112. :group 'org-export)
  113. ;;;; Preamble
  114. (defcustom org-texinfo-coding-system nil
  115. "Default document encoding for Texinfo output.
  116. If `nil' it will default to `buffer-file-coding-system'."
  117. :group 'org-export-texinfo
  118. :type 'coding-system)
  119. (defcustom org-texinfo-default-class "info"
  120. "The default Texinfo class."
  121. :group 'org-export-texinfo
  122. :type '(string :tag "Texinfo class"))
  123. (defcustom org-texinfo-classes
  124. '(("info"
  125. "@documentencoding AUTO\n@documentlanguage AUTO"
  126. ("@chapter %s" . "@unnumbered %s")
  127. ("@section %s" . "@unnumberedsec %s")
  128. ("@subsection %s" . "@unnumberedsubsec %s")
  129. ("@subsubsection %s" . "@unnumberedsubsubsec %s")))
  130. "Alist of Texinfo classes and associated header and structure.
  131. If #+TEXINFO_CLASS is set in the buffer, use its value and the
  132. associated information. Here is the structure of each cell:
  133. \(class-name
  134. header-string
  135. \(numbered-section . unnumbered-section)
  136. ...)
  137. The header string
  138. -----------------
  139. The header string is inserted in the header of the generated
  140. document, right after \"@setfilename\" and \"@settitle\"
  141. commands.
  142. If it contains the special string
  143. \"@documentencoding AUTO\"
  144. \"AUTO\" will be replaced with an appropriate coding system. See
  145. `org-texinfo-coding-system' for more information. Likewise, if
  146. the string contains the special string
  147. \"@documentlanguage AUTO\"
  148. \"AUTO\" will be replaced with the language defined in the
  149. buffer, through #+LANGUAGE keyword, or globally, with
  150. `org-export-default-language', which see.
  151. The sectioning structure
  152. ------------------------
  153. The sectioning structure of the class is given by the elements
  154. following the header string. For each sectioning level, a number
  155. of strings is specified. A %s formatter is mandatory in each
  156. section string and will be replaced by the title of the section.
  157. Instead of a list of sectioning commands, you can also specify
  158. a function name. That function will be called with two
  159. parameters, the reduced) level of the headline, and a predicate
  160. non-nil when the headline should be numbered. It must return
  161. a format string in which the section title will be added."
  162. :group 'org-export-texinfo
  163. :version "24.4"
  164. :package-version '(Org . "8.2")
  165. :type '(repeat
  166. (list (string :tag "Texinfo class")
  167. (string :tag "Texinfo header")
  168. (repeat :tag "Levels" :inline t
  169. (choice
  170. (cons :tag "Heading"
  171. (string :tag " numbered")
  172. (string :tag "unnumbered"))
  173. (function :tag "Hook computing sectioning"))))))
  174. ;;;; Headline
  175. (defcustom org-texinfo-format-headline-function
  176. 'org-texinfo-format-headline-default-function
  177. "Function to format headline text.
  178. This function will be called with 5 arguments:
  179. TODO the todo keyword (string or nil).
  180. TODO-TYPE the type of todo (symbol: `todo', `done', nil)
  181. PRIORITY the priority of the headline (integer or nil)
  182. TEXT the main headline text (string).
  183. TAGS the tags as a list of strings (list of strings or nil).
  184. The function result will be used in the section format string."
  185. :group 'org-export-texinfo
  186. :type 'function
  187. :version "25.1"
  188. :package-version '(Org . "8.3"))
  189. ;;;; Node listing (menu)
  190. (defcustom org-texinfo-node-description-column 32
  191. "Column at which to start the description in the node listings.
  192. If a node title is greater than this length, the description will
  193. be placed after the end of the title."
  194. :group 'org-export-texinfo
  195. :type 'integer)
  196. ;;;; Timestamps
  197. (defcustom org-texinfo-active-timestamp-format "@emph{%s}"
  198. "A printf format string to be applied to active timestamps."
  199. :group 'org-export-texinfo
  200. :type 'string)
  201. (defcustom org-texinfo-inactive-timestamp-format "@emph{%s}"
  202. "A printf format string to be applied to inactive timestamps."
  203. :group 'org-export-texinfo
  204. :type 'string)
  205. (defcustom org-texinfo-diary-timestamp-format "@emph{%s}"
  206. "A printf format string to be applied to diary timestamps."
  207. :group 'org-export-texinfo
  208. :type 'string)
  209. ;;;; Links
  210. (defcustom org-texinfo-link-with-unknown-path-format "@indicateurl{%s}"
  211. "Format string for links with unknown path type."
  212. :group 'org-export-texinfo
  213. :type 'string)
  214. ;;;; Tables
  215. (defcustom org-texinfo-tables-verbatim nil
  216. "When non-nil, tables are exported verbatim."
  217. :group 'org-export-texinfo
  218. :type 'boolean)
  219. (defcustom org-texinfo-table-scientific-notation "%s\\,(%s)"
  220. "Format string to display numbers in scientific notation.
  221. The format should have \"%s\" twice, for mantissa and exponent
  222. \(i.e. \"%s\\\\times10^{%s}\").
  223. When nil, no transformation is made."
  224. :group 'org-export-texinfo
  225. :type '(choice
  226. (string :tag "Format string")
  227. (const :tag "No formatting" nil)))
  228. (defcustom org-texinfo-def-table-markup "@samp"
  229. "Default setting for @table environments."
  230. :group 'org-export-texinfo
  231. :type 'string)
  232. ;;;; Text markup
  233. (defcustom org-texinfo-text-markup-alist '((bold . "@strong{%s}")
  234. (code . code)
  235. (italic . "@emph{%s}")
  236. (verbatim . verb)
  237. (comment . "@c %s"))
  238. "Alist of Texinfo expressions to convert text markup.
  239. The key must be a symbol among `bold', `italic' and `comment'.
  240. The value is a formatting string to wrap fontified text with.
  241. Value can also be set to the following symbols: `verb' and
  242. `code'. For the former, Org will use \"@verb\" to
  243. create a format string and select a delimiter character that
  244. isn't in the string. For the latter, Org will use \"@code\"
  245. to typeset and try to protect special characters.
  246. If no association can be found for a given markup, text will be
  247. returned as-is."
  248. :group 'org-export-texinfo
  249. :type 'alist
  250. :options '(bold code italic verbatim comment))
  251. ;;;; Drawers
  252. (defcustom org-texinfo-format-drawer-function
  253. (lambda (name contents) contents)
  254. "Function called to format a drawer in Texinfo code.
  255. The function must accept two parameters:
  256. NAME the drawer name, like \"LOGBOOK\"
  257. CONTENTS the contents of the drawer.
  258. The function should return the string to be exported.
  259. The default function simply returns the value of CONTENTS."
  260. :group 'org-export-texinfo
  261. :version "24.4"
  262. :package-version '(Org . "8.2")
  263. :type 'function)
  264. ;;;; Inlinetasks
  265. (defcustom org-texinfo-format-inlinetask-function
  266. 'org-texinfo-format-inlinetask-default-function
  267. "Function called to format an inlinetask in Texinfo code.
  268. The function must accept six parameters:
  269. TODO the todo keyword, as a string
  270. TODO-TYPE the todo type, a symbol among `todo', `done' and nil.
  271. PRIORITY the inlinetask priority, as a string
  272. NAME the inlinetask name, as a string.
  273. TAGS the inlinetask tags, as a list of strings.
  274. CONTENTS the contents of the inlinetask, as a string.
  275. The function should return the string to be exported."
  276. :group 'org-export-texinfo
  277. :type 'function)
  278. ;;;; Compilation
  279. (defcustom org-texinfo-info-process '("makeinfo %f")
  280. "Commands to process a Texinfo file to an INFO file.
  281. This is list of strings, each of them will be given to the shell
  282. as a command. %f in the command will be replaced by the full
  283. file name, %b by the file base name (i.e without extension) and
  284. %o by the base directory of the file."
  285. :group 'org-export-texinfo
  286. :type '(repeat :tag "Shell command sequence"
  287. (string :tag "Shell command")))
  288. (defcustom org-texinfo-logfiles-extensions
  289. '("aux" "toc" "cp" "fn" "ky" "pg" "tp" "vr")
  290. "The list of file extensions to consider as Texinfo logfiles.
  291. The logfiles will be remove if `org-texinfo-remove-logfiles' is
  292. non-nil."
  293. :group 'org-export-texinfo
  294. :type '(repeat (string :tag "Extension")))
  295. (defcustom org-texinfo-remove-logfiles t
  296. "Non-nil means remove the logfiles produced by compiling a Texinfo file.
  297. By default, logfiles are files with these extensions: .aux, .toc,
  298. .cp, .fn, .ky, .pg and .tp. To define the set of logfiles to remove,
  299. set `org-texinfo-logfiles-extensions'."
  300. :group 'org-export-latex
  301. :type 'boolean)
  302. ;;; Constants
  303. (defconst org-texinfo-max-toc-depth 4
  304. "Maximum depth for creation of detailed menu listings.
  305. Beyond this depth, Texinfo will not recognize the nodes and will
  306. cause errors. Left as a constant in case this value ever
  307. changes.")
  308. (defconst org-texinfo-supported-coding-systems
  309. '("US-ASCII" "UTF-8" "ISO-8859-15" "ISO-8859-1" "ISO-8859-2" "koi8-r" "koi8-u")
  310. "List of coding systems supported by Texinfo, as strings.
  311. Specified coding system will be matched against these strings.
  312. If two strings share the same prefix (e.g. \"ISO-8859-1\" and
  313. \"ISO-8859-15\"), the most specific one has to be listed first.")
  314. (defconst org-texinfo-inline-image-rules
  315. (list (cons "file"
  316. (regexp-opt '("eps" "pdf" "png" "jpg" "jpeg" "gif" "svg"))))
  317. "Rules characterizing image files that can be inlined.")
  318. ;;; Internal Functions
  319. (defun org-texinfo--filter-section-blank-lines (headline back-end info)
  320. "Filter controlling number of blank lines after a section."
  321. (let ((blanks (make-string 2 ?\n)))
  322. (replace-regexp-in-string "\n\\(?:\n[ \t]*\\)*\\'" blanks headline)))
  323. (defun org-texinfo--normalize-headlines (tree back-end info)
  324. "Normalize headlines in TREE.
  325. BACK-END is the symbol specifying back-end used for export. INFO
  326. is a plist used as a communication channel.
  327. Make sure every headline in TREE contains a section, since those
  328. are required to install a menu. Also put exactly one blank line
  329. at the end of each section.
  330. Return new tree."
  331. (org-element-map tree 'headline
  332. (lambda (hl)
  333. (org-element-put-property hl :post-blank 1)
  334. (let ((contents (org-element-contents hl)))
  335. (when contents
  336. (let ((first (org-element-map contents '(headline section)
  337. #'identity info t)))
  338. (unless (eq (org-element-type first) 'section)
  339. (apply #'org-element-set-contents
  340. hl
  341. (cons `(section (:parent ,hl)) contents)))))))
  342. info)
  343. tree)
  344. (defun org-texinfo--find-verb-separator (s)
  345. "Return a character not used in string S.
  346. This is used to choose a separator for constructs like \\verb."
  347. (let ((ll "~,./?;':\"|!@#%^&-_=+abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ<>()[]{}"))
  348. (loop for c across ll
  349. when (not (string-match (regexp-quote (char-to-string c)) s))
  350. return (char-to-string c))))
  351. (defun org-texinfo--text-markup (text markup info)
  352. "Format TEXT depending on MARKUP text markup.
  353. INFO is a plist used as a communication channel. See
  354. `org-texinfo-text-markup-alist' for details."
  355. (let ((fmt (cdr (assq markup org-texinfo-text-markup-alist))))
  356. (cond
  357. ;; No format string: Return raw text.
  358. ((not fmt) text)
  359. ((eq 'verb fmt)
  360. (let ((separator (org-texinfo--find-verb-separator text)))
  361. (concat "@verb{" separator text separator "}")))
  362. ((eq 'code fmt)
  363. (let ((start 0)
  364. (rtn "")
  365. char)
  366. (while (string-match "[@{}]" text)
  367. (setq char (match-string 0 text))
  368. (if (> (match-beginning 0) 0)
  369. (setq rtn (concat rtn (substring text 0 (match-beginning 0)))))
  370. (setq text (substring text (1+ (match-beginning 0))))
  371. (setq char (concat "@" char)
  372. rtn (concat rtn char)))
  373. (setq text (concat rtn text)
  374. fmt "@code{%s}")
  375. (format fmt text)))
  376. ;; Else use format string.
  377. (t (format fmt text)))))
  378. (defun org-texinfo--get-node (blob info)
  379. "Return node or anchor associated to BLOB.
  380. BLOB is an element or object. INFO is a plist used as
  381. a communication channel. The function guarantees the node or
  382. anchor name is unique."
  383. (let ((cache (plist-get info :texinfo-node-cache)))
  384. (or (cdr (assq blob cache))
  385. (let ((name
  386. (org-texinfo--sanitize-node
  387. (if (eq (org-element-type blob) 'headline)
  388. (org-export-data (org-export-get-alt-title blob info) info)
  389. (org-export-get-reference blob info)))))
  390. ;; Ensure NAME is unique.
  391. (while (rassoc name cache) (setq name (concat name "x")))
  392. (plist-put info :texinfo-node-cache (cons (cons blob name) cache))
  393. name))))
  394. (defun org-texinfo--sanitize-node (title)
  395. "Bend string TITLE to node line requirements.
  396. Trim string and collapse multiple whitespace characters as they
  397. are not significant. Also remove the following characters: @
  398. { } ( ) : . ,"
  399. (replace-regexp-in-string
  400. "[:,.]" ""
  401. (replace-regexp-in-string
  402. "\\`(\\(.*)\\)" "[\\1"
  403. (org-trim (replace-regexp-in-string "[ \t]\\{2,\\}" " " title)))))
  404. (defun org-texinfo--sanitize-content (text)
  405. "Escape special characters in string TEXT.
  406. Special characters are: @ { }"
  407. (replace-regexp-in-string "[@{}]" "@\\&" text))
  408. (defun org-texinfo--wrap-float (value info &optional type label caption short)
  409. "Wrap string VALUE within a @float command.
  410. INFO is the current export state, as a plist. TYPE is float
  411. type, as a string. LABEL is the cross reference label for the
  412. float, as a string. CAPTION and SHORT are, respectively, the
  413. caption and shortcaption used for the float, as secondary
  414. strings (e.g., returned by `org-export-get-caption')."
  415. (let* ((backend
  416. (org-export-create-backend
  417. :parent 'texinfo
  418. :transcoders '((link . (lambda (object c i) c))
  419. (radio-target . (lambda (object c i) c))
  420. (target . ignore))))
  421. (short-backend
  422. (org-export-create-backend
  423. :parent 'texinfo
  424. :transcoders '((footnote-reference . ignore)
  425. (inline-src-block . ignore)
  426. (link . (lambda (object c i) c))
  427. (radio-target . (lambda (object c i) c))
  428. (target . ignore)
  429. (verbatim . ignore))))
  430. (short-str
  431. (if (and short caption)
  432. (format "@shortcaption{%s}\n"
  433. (org-export-data-with-backend short short-backend info))
  434. ""))
  435. (caption-str
  436. (if (or short caption)
  437. (format "@caption{%s}\n"
  438. (org-export-data-with-backend
  439. (or caption short)
  440. (if (equal short-str "") short-backend backend)
  441. info))
  442. "")))
  443. (format "@float %s%s\n%s\n%s%s@end float"
  444. type (if label (concat "," label) "") value caption-str short-str)))
  445. ;;; Template
  446. (defun org-texinfo-template (contents info)
  447. "Return complete document string after Texinfo conversion.
  448. CONTENTS is the transcoded contents string. INFO is a plist
  449. holding export options."
  450. (let ((title (org-export-data (plist-get info :title) info))
  451. ;; Copying data is the contents of the first headline in
  452. ;; parse tree with a non-nil copying property.
  453. (copying (org-element-map (plist-get info :parse-tree) 'headline
  454. (lambda (hl)
  455. (and (org-not-nil (org-element-property :COPYING hl))
  456. (org-element-contents hl)))
  457. info t)))
  458. (concat
  459. "\\input texinfo @c -*- texinfo -*-\n"
  460. "@c %**start of header\n"
  461. (let ((file (or (plist-get info :texinfo-filename)
  462. (let ((f (plist-get info :output-file)))
  463. (and f (concat (file-name-sans-extension f) ".info"))))))
  464. (and file (format "@setfilename %s\n" file)))
  465. (format "@settitle %s\n" title)
  466. ;; Insert class-defined header.
  467. (org-element-normalize-string
  468. (let ((header (nth 1 (assoc (plist-get info :texinfo-class)
  469. org-texinfo-classes)))
  470. (coding
  471. (catch 'coding-system
  472. (let ((case-fold-search t)
  473. (name (symbol-name (or org-texinfo-coding-system
  474. buffer-file-coding-system))))
  475. (dolist (system org-texinfo-supported-coding-systems "UTF-8")
  476. (when (org-string-match-p (regexp-quote system) name)
  477. (throw 'coding-system system))))))
  478. (language (plist-get info :language))
  479. (case-fold-search nil))
  480. ;; Auto coding system.
  481. (replace-regexp-in-string
  482. "^@documentencoding \\(AUTO\\)$"
  483. coding
  484. (replace-regexp-in-string
  485. "^@documentlanguage \\(AUTO\\)$" language header t nil 1) t nil 1)))
  486. ;; Additional header options set by #+TEXINFO_HEADER.
  487. (let ((texinfo-header (plist-get info :texinfo-header)))
  488. (and texinfo-header (org-element-normalize-string texinfo-header)))
  489. "@c %**end of header\n\n"
  490. ;; Additional options set by #+TEXINFO_POST_HEADER.
  491. (let ((texinfo-post-header (plist-get info :texinfo-post-header)))
  492. (and texinfo-post-header
  493. (org-element-normalize-string texinfo-post-header)))
  494. ;; Copying.
  495. (and copying
  496. (format "@copying\n%s@end copying\n\n"
  497. (org-element-normalize-string
  498. (org-export-data copying info))))
  499. ;; Info directory information. Only supply if both title and
  500. ;; category are provided.
  501. (let ((dircat (plist-get info :texinfo-dircat))
  502. (dirtitle
  503. (let ((title (plist-get info :texinfo-dirtitle)))
  504. (and title
  505. (string-match "^\\(?:\\* \\)?\\(.*?\\)\\(\\.\\)?$" title)
  506. (format "* %s." (match-string 1 title))))))
  507. (when (and dircat dirtitle)
  508. (concat "@dircategory " dircat "\n"
  509. "@direntry\n"
  510. (let ((dirdesc
  511. (let ((desc (plist-get info :texinfo-dirdesc)))
  512. (cond ((not desc) nil)
  513. ((org-string-match-p "\\.$" desc) desc)
  514. (t (concat desc "."))))))
  515. (if dirdesc (format "%-23s %s" dirtitle dirdesc) dirtitle))
  516. "\n"
  517. "@end direntry\n\n")))
  518. ;; Title
  519. "@finalout\n"
  520. "@titlepage\n"
  521. (when (plist-get info :with-title)
  522. (concat
  523. (format "@title %s\n" (or (plist-get info :texinfo-printed-title) title ""))
  524. (let ((subtitle (plist-get info :subtitle)))
  525. (when subtitle
  526. (format "@subtitle %s\n"
  527. (org-export-data subtitle info))))))
  528. (when (plist-get info :with-author)
  529. (concat
  530. ;; Primary author.
  531. (let ((author (org-string-nw-p
  532. (org-export-data (plist-get info :author) info)))
  533. (email (and (plist-get info :with-email)
  534. (org-string-nw-p
  535. (org-export-data (plist-get info :email) info)))))
  536. (cond ((and author email)
  537. (format "@author %s (@email{%s})\n" author email))
  538. (author (format "@author %s\n" author))
  539. (email (format "@author @email{%s}\n" email))))
  540. ;; Other authors.
  541. (let ((subauthor (plist-get info :subauthor)))
  542. (and subauthor
  543. (org-element-normalize-string
  544. (replace-regexp-in-string "^" "@author " subauthor))))))
  545. (and copying "@page\n@vskip 0pt plus 1filll\n@insertcopying\n")
  546. "@end titlepage\n\n"
  547. ;; Table of contents.
  548. (and (plist-get info :with-toc) "@contents\n\n")
  549. ;; Configure Top Node when not for Tex
  550. "@ifnottex\n"
  551. "@node Top\n"
  552. (format "@top %s\n" title)
  553. (and copying "@insertcopying\n")
  554. "@end ifnottex\n\n"
  555. ;; Menu.
  556. (org-texinfo-make-menu (plist-get info :parse-tree) info 'master)
  557. "\n"
  558. ;; Document's body.
  559. contents "\n"
  560. ;; Creator.
  561. (and (plist-get info :with-creator)
  562. (concat (plist-get info :creator) "\n"))
  563. ;; Document end.
  564. "@bye")))
  565. ;;; Transcode Functions
  566. ;;;; Bold
  567. (defun org-texinfo-bold (bold contents info)
  568. "Transcode BOLD from Org to Texinfo.
  569. CONTENTS is the text with bold markup. INFO is a plist holding
  570. contextual information."
  571. (org-texinfo--text-markup contents 'bold info))
  572. ;;;; Center Block
  573. (defun org-texinfo-center-block (center-block contents info)
  574. "Transcode a CENTER-BLOCK element from Org to Texinfo.
  575. CONTENTS holds the contents of the block. INFO is a plist used
  576. as a communication channel."
  577. contents)
  578. ;;;; Clock
  579. (defun org-texinfo-clock (clock contents info)
  580. "Transcode a CLOCK element from Org to Texinfo.
  581. CONTENTS is nil. INFO is a plist holding contextual
  582. information."
  583. (concat
  584. "@noindent"
  585. (format "@strong{%s} " org-clock-string)
  586. (format (plist-get info :texinfo-inactive-timestamp-format)
  587. (concat (org-timestamp-translate (org-element-property :value clock))
  588. (let ((time (org-element-property :duration clock)))
  589. (and time (format " (%s)" time)))))
  590. "@*"))
  591. ;;;; Code
  592. (defun org-texinfo-code (code contents info)
  593. "Transcode a CODE object from Org to Texinfo.
  594. CONTENTS is nil. INFO is a plist used as a communication
  595. channel."
  596. (org-texinfo--text-markup (org-element-property :value code) 'code info))
  597. ;;;; Drawer
  598. (defun org-texinfo-drawer (drawer contents info)
  599. "Transcode a DRAWER element from Org to Texinfo.
  600. CONTENTS holds the contents of the block. INFO is a plist
  601. holding contextual information."
  602. (let* ((name (org-element-property :drawer-name drawer))
  603. (output (funcall (plist-get info :texinfo-format-drawer-function)
  604. name contents)))
  605. output))
  606. ;;;; Dynamic Block
  607. (defun org-texinfo-dynamic-block (dynamic-block contents info)
  608. "Transcode a DYNAMIC-BLOCK element from Org to Texinfo.
  609. CONTENTS holds the contents of the block. INFO is a plist
  610. holding contextual information."
  611. contents)
  612. ;;;; Entity
  613. (defun org-texinfo-entity (entity contents info)
  614. "Transcode an ENTITY object from Org to Texinfo.
  615. CONTENTS are the definition itself. INFO is a plist holding
  616. contextual information."
  617. (let ((ent (org-element-property :latex entity)))
  618. (if (org-element-property :latex-math-p entity) (format "@math{%s}" ent) ent)))
  619. ;;;; Example Block
  620. (defun org-texinfo-example-block (example-block contents info)
  621. "Transcode an EXAMPLE-BLOCK element from Org to Texinfo.
  622. CONTENTS is nil. INFO is a plist holding contextual
  623. information."
  624. (format "@verbatim\n%s@end verbatim"
  625. (org-export-format-code-default example-block info)))
  626. ;;; Export Block
  627. (defun org-texinfo-export-block (export-block contents info)
  628. "Transcode a EXPORT-BLOCK element from Org to Texinfo.
  629. CONTENTS is nil. INFO is a plist holding contextual information."
  630. (when (string= (org-element-property :type export-block) "TEXINFO")
  631. (org-remove-indentation (org-element-property :value export-block))))
  632. ;;; Export Snippet
  633. (defun org-texinfo-export-snippet (export-snippet contents info)
  634. "Transcode a EXPORT-SNIPPET object from Org to Texinfo.
  635. CONTENTS is nil. INFO is a plist holding contextual information."
  636. (when (eq (org-export-snippet-backend export-snippet) 'texinfo)
  637. (org-element-property :value export-snippet)))
  638. ;;;; Fixed Width
  639. (defun org-texinfo-fixed-width (fixed-width contents info)
  640. "Transcode a FIXED-WIDTH element from Org to Texinfo.
  641. CONTENTS is nil. INFO is a plist holding contextual information."
  642. (format "@example\n%s\n@end example"
  643. (org-remove-indentation
  644. (org-texinfo--sanitize-content
  645. (org-element-property :value fixed-width)))))
  646. ;;;; Footnote Reference
  647. (defun org-texinfo-footnote-reference (footnote contents info)
  648. "Create a footnote reference for FOOTNOTE.
  649. FOOTNOTE is the footnote to define. CONTENTS is nil. INFO is a
  650. plist holding contextual information."
  651. (let ((def (org-export-get-footnote-definition footnote info)))
  652. (format "@footnote{%s}"
  653. (org-trim (org-export-data def info)))))
  654. ;;;; Headline
  655. (defun org-texinfo-headline (headline contents info)
  656. "Transcode a HEADLINE element from Org to Texinfo.
  657. CONTENTS holds the contents of the headline. INFO is a plist
  658. holding contextual information."
  659. (let* ((class (plist-get info :texinfo-class))
  660. (level (org-export-get-relative-level headline info))
  661. (numberedp (org-export-numbered-headline-p headline info))
  662. (class-sectioning (assoc class (plist-get info :texinfo-classes)))
  663. ;; Find the index type, if any.
  664. (index (org-element-property :INDEX headline))
  665. ;; Create node info, to insert it before section formatting.
  666. ;; Use custom menu title if present.
  667. (node (format "@node %s\n" (org-texinfo--get-node headline info)))
  668. ;; Section formatting will set two placeholders: one for the
  669. ;; title and the other for the contents.
  670. (section-fmt
  671. (if (org-not-nil (org-element-property :APPENDIX headline))
  672. "@appendix %s\n%s"
  673. (let ((sec (if (and (symbolp (nth 2 class-sectioning))
  674. (fboundp (nth 2 class-sectioning)))
  675. (funcall (nth 2 class-sectioning) level numberedp)
  676. (nth (1+ level) class-sectioning))))
  677. (cond
  678. ;; No section available for that LEVEL.
  679. ((not sec) nil)
  680. ;; Section format directly returned by a function.
  681. ((stringp sec) sec)
  682. ;; (numbered-section . unnumbered-section)
  683. ((not (consp (cdr sec)))
  684. (concat (if (or index (not numberedp)) (cdr sec) (car sec))
  685. "\n%s"))))))
  686. (todo
  687. (and (plist-get info :with-todo-keywords)
  688. (let ((todo (org-element-property :todo-keyword headline)))
  689. (and todo (org-export-data todo info)))))
  690. (todo-type (and todo (org-element-property :todo-type headline)))
  691. (tags (and (plist-get info :with-tags)
  692. (org-export-get-tags headline info)))
  693. (priority (and (plist-get info :with-priority)
  694. (org-element-property :priority headline)))
  695. (text (org-export-data (org-element-property :title headline) info))
  696. (full-text (funcall (plist-get info :texinfo-format-headline-function)
  697. todo todo-type priority text tags))
  698. (contents (if (org-string-nw-p contents) (concat "\n" contents) "")))
  699. (cond
  700. ;; Case 1: This is a footnote section: ignore it.
  701. ((org-element-property :footnote-section-p headline) nil)
  702. ;; Case 2: This is the `copying' section: ignore it
  703. ;; This is used elsewhere.
  704. ((org-not-nil (org-element-property :COPYING headline)) nil)
  705. ;; Case 3: An index. If it matches one of the known indexes,
  706. ;; print it as such following the contents, otherwise
  707. ;; print the contents and leave the index up to the user.
  708. (index
  709. (concat node
  710. (format
  711. section-fmt
  712. full-text
  713. (concat contents
  714. (and (member index '("cp" "fn" "ky" "pg" "tp" "vr"))
  715. (concat "\n@printindex " index))))))
  716. ;; Case 4: This is a deep sub-tree: export it as a list item.
  717. ;; Also export as items headlines for which no section
  718. ;; format has been found.
  719. ((or (not section-fmt) (org-export-low-level-p headline info))
  720. ;; Build the real contents of the sub-tree.
  721. (concat (and (org-export-first-sibling-p headline info)
  722. (format "@%s\n" (if numberedp 'enumerate 'itemize)))
  723. "@item\n" full-text "\n"
  724. contents
  725. (if (org-export-last-sibling-p headline info)
  726. (format "@end %s" (if numberedp 'enumerate 'itemize))
  727. "\n")))
  728. ;; Case 5: Standard headline. Export it as a section.
  729. (t (concat node (format section-fmt full-text contents))))))
  730. (defun org-texinfo-format-headline-default-function
  731. (todo todo-type priority text tags)
  732. "Default format function for a headline.
  733. See `org-texinfo-format-headline-function' for details."
  734. (concat (when todo (format "@strong{%s} " todo))
  735. (when priority (format "@emph{#%s} " priority))
  736. text
  737. (when tags (format " :%s:" (mapconcat 'identity tags ":")))))
  738. ;;;; Inline Src Block
  739. (defun org-texinfo-inline-src-block (inline-src-block contents info)
  740. "Transcode an INLINE-SRC-BLOCK element from Org to Texinfo.
  741. CONTENTS holds the contents of the item. INFO is a plist holding
  742. contextual information."
  743. (let* ((code (org-element-property :value inline-src-block))
  744. (separator (org-texinfo--find-verb-separator code)))
  745. (concat "@verb{" separator code separator "}")))
  746. ;;;; Inlinetask
  747. (defun org-texinfo-inlinetask (inlinetask contents info)
  748. "Transcode an INLINETASK element from Org to Texinfo.
  749. CONTENTS holds the contents of the block. INFO is a plist
  750. holding contextual information."
  751. (let ((title (org-export-data (org-element-property :title inlinetask) info))
  752. (todo (and (plist-get info :with-todo-keywords)
  753. (let ((todo (org-element-property :todo-keyword inlinetask)))
  754. (and todo (org-export-data todo info)))))
  755. (todo-type (org-element-property :todo-type inlinetask))
  756. (tags (and (plist-get info :with-tags)
  757. (org-export-get-tags inlinetask info)))
  758. (priority (and (plist-get info :with-priority)
  759. (org-element-property :priority inlinetask))))
  760. (funcall (plist-get info :texinfo-format-inlinetask-function)
  761. todo todo-type priority title tags contents)))
  762. (defun org-texinfo-format-inlinetask-default-function
  763. (todo todo-type priority title tags contents)
  764. "Default format function for a inlinetasks.
  765. See `org-texinfo-format-inlinetask-function' for details."
  766. (let ((full-title
  767. (concat (when todo (format "@strong{%s} " todo))
  768. (when priority (format "#%c " priority))
  769. title
  770. (when tags (format ":%s:" (mapconcat #'identity tags ":"))))))
  771. (format "@center %s\n\n%s\n" full-title contents)))
  772. ;;;; Italic
  773. (defun org-texinfo-italic (italic contents info)
  774. "Transcode ITALIC from Org to Texinfo.
  775. CONTENTS is the text with italic markup. INFO is a plist holding
  776. contextual information."
  777. (org-texinfo--text-markup contents 'italic info))
  778. ;;;; Item
  779. (defun org-texinfo-item (item contents info)
  780. "Transcode an ITEM element from Org to Texinfo.
  781. CONTENTS holds the contents of the item. INFO is a plist holding
  782. contextual information."
  783. (format "@item%s\n%s"
  784. (let ((tag (org-element-property :tag item)))
  785. (if tag (concat " " (org-export-data tag info)) ""))
  786. (or contents "")))
  787. ;;;; Keyword
  788. (defun org-texinfo-keyword (keyword contents info)
  789. "Transcode a KEYWORD element from Org to Texinfo.
  790. CONTENTS is nil. INFO is a plist holding contextual information."
  791. (let ((key (org-element-property :key keyword))
  792. (value (org-element-property :value keyword)))
  793. (cond
  794. ((string= key "TEXINFO") value)
  795. ((string= key "CINDEX") (format "@cindex %s" value))
  796. ((string= key "FINDEX") (format "@findex %s" value))
  797. ((string= key "KINDEX") (format "@kindex %s" value))
  798. ((string= key "PINDEX") (format "@pindex %s" value))
  799. ((string= key "TINDEX") (format "@tindex %s" value))
  800. ((string= key "VINDEX") (format "@vindex %s" value))
  801. ((string= key "TOC")
  802. (cond ((org-string-match-p "\\<tables\\>" value)
  803. (concat "@listoffloats "
  804. (org-export-translate "Table" :utf-8 info)))
  805. ((org-string-match-p "\\<listings\\>" value)
  806. (concat "@listoffloats "
  807. (org-export-translate "Listing" :utf-8 info))))))))
  808. ;;;; Line Break
  809. (defun org-texinfo-line-break (line-break contents info)
  810. "Transcode a LINE-BREAK object from Org to Texinfo.
  811. CONTENTS is nil. INFO is a plist holding contextual information."
  812. "@*\n")
  813. ;;;; Link
  814. (defun org-texinfo-link (link desc info)
  815. "Transcode a LINK object from Org to Texinfo.
  816. DESC is the description part of the link, or the empty string.
  817. INFO is a plist holding contextual information. See
  818. `org-export-data'."
  819. (let* ((type (org-element-property :type link))
  820. (raw-path (org-element-property :path link))
  821. ;; Ensure DESC really exists, or set it to nil.
  822. (desc (and (not (string= desc "")) desc))
  823. (path (cond
  824. ((member type '("http" "https" "ftp"))
  825. (concat type ":" raw-path))
  826. ((string= type "file") (org-export-file-uri raw-path))
  827. (t raw-path))))
  828. (cond
  829. ((org-export-custom-protocol-maybe link desc 'texinfo))
  830. ((org-export-inline-image-p link org-texinfo-inline-image-rules)
  831. (org-texinfo--inline-image link info))
  832. ((equal type "radio")
  833. (let ((destination (org-export-resolve-radio-link link info)))
  834. (if (not destination) desc
  835. (format "@ref{%s,,%s}"
  836. (org-texinfo--get-node destination info)
  837. desc))))
  838. ((member type '("custom-id" "id" "fuzzy"))
  839. (let ((destination
  840. (if (equal type "fuzzy")
  841. (org-export-resolve-fuzzy-link link info)
  842. (org-export-resolve-id-link link info))))
  843. (case (org-element-type destination)
  844. ((nil)
  845. (format org-texinfo-link-with-unknown-path-format
  846. (org-texinfo--sanitize-content path)))
  847. ;; Id link points to an external file.
  848. (plain-text
  849. (if desc (format "@uref{file://%s,%s}" destination desc)
  850. (format "@uref{file://%s}" destination)))
  851. (headline
  852. (format "@ref{%s,%s}"
  853. (org-texinfo--get-node destination info)
  854. (cond
  855. (desc)
  856. ((org-export-numbered-headline-p destination info)
  857. (org-export-data
  858. (org-element-property :title destination) info))
  859. (t
  860. (mapconcat
  861. #'number-to-string
  862. (org-export-get-headline-number destination info) ".")))))
  863. (otherwise
  864. (let ((topic
  865. (or desc
  866. (if (and (eq (org-element-type destination) 'headline)
  867. (not (org-export-numbered-headline-p
  868. destination info)))
  869. (org-export-data
  870. (org-element-property :title destination) info))
  871. (let ((n (org-export-get-ordinal destination info)))
  872. (cond
  873. ((not n) nil)
  874. ((integerp n) n)
  875. (t (mapconcat #'number-to-string n ".")))))))
  876. (when topic
  877. (format "@ref{%s,,%s}"
  878. (org-texinfo--get-node destination info)
  879. topic)))))))
  880. ((equal type "info")
  881. (let* ((info-path (split-string path "[:#]"))
  882. (info-manual (car info-path))
  883. (info-node (or (cadr info-path) "top"))
  884. (title (or desc "")))
  885. (format "@ref{%s,%s,,%s,}" info-node title info-manual)))
  886. ((string= type "mailto")
  887. (format "@email{%s}"
  888. (concat (org-texinfo--sanitize-content path)
  889. (and desc (concat "," desc)))))
  890. ;; External link with a description part.
  891. ((and path desc) (format "@uref{%s,%s}" path desc))
  892. ;; External link without a description part.
  893. (path (format "@uref{%s}" path))
  894. ;; No path, only description. Try to do something useful.
  895. (t
  896. (format (plist-get info :texinfo-link-with-unknown-path-format) desc)))))
  897. (defun org-texinfo--inline-image (link info)
  898. "Return Texinfo code for an inline image.
  899. LINK is the link pointing to the inline image. INFO is the
  900. current state of the export, as a plist."
  901. (let* ((parent (org-export-get-parent-element link))
  902. (label (and (org-element-property :name parent)
  903. (org-texinfo--get-node parent info)))
  904. (caption (org-export-get-caption parent))
  905. (shortcaption (org-export-get-caption parent t))
  906. (path (org-element-property :path link))
  907. (filename
  908. (file-name-sans-extension
  909. (if (file-name-absolute-p path) (expand-file-name path) path)))
  910. (extension (file-name-extension path))
  911. (attributes (org-export-read-attribute :attr_texinfo parent))
  912. (height (or (plist-get attributes :height) ""))
  913. (width (or (plist-get attributes :width) ""))
  914. (alt (or (plist-get attributes :alt) ""))
  915. (image (format "@image{%s,%s,%s,%s,%s}"
  916. filename width height alt extension)))
  917. (cond ((or caption shortcaption)
  918. (org-texinfo--wrap-float image
  919. info
  920. (org-export-translate "Figure" :utf-8 info)
  921. label
  922. caption
  923. shortcaption))
  924. (label (concat "@anchor{" label "}\n" image))
  925. (t image))))
  926. ;;;; Menu
  927. (defun org-texinfo-make-menu (scope info &optional master)
  928. "Create the menu for inclusion in the Texinfo document.
  929. SCOPE is a headline or a full parse tree. INFO is the
  930. communication channel, as a plist.
  931. When optional argument MASTER is non-nil, generate a master menu,
  932. including detailed node listing."
  933. (let ((menu (org-texinfo--build-menu scope info)))
  934. (when (org-string-nw-p menu)
  935. (org-element-normalize-string
  936. (format
  937. "@menu\n%s@end menu"
  938. (concat menu
  939. (when master
  940. (let ((detailmenu
  941. (org-texinfo--build-menu
  942. scope info
  943. (let ((toc-depth (plist-get info :with-toc)))
  944. (if (wholenump toc-depth) toc-depth
  945. org-texinfo-max-toc-depth)))))
  946. (when (org-string-nw-p detailmenu)
  947. (concat "\n@detailmenu\n"
  948. "--- The Detailed Node Listing ---\n\n"
  949. detailmenu
  950. "@end detailmenu\n"))))))))))
  951. (defun org-texinfo--build-menu (scope info &optional level)
  952. "Build menu for entries within SCOPE.
  953. SCOPE is a headline or a full parse tree. INFO is a plist
  954. containing contextual information. When optional argument LEVEL
  955. is an integer, build the menu recursively, down to this depth."
  956. (cond
  957. ((not level)
  958. (org-texinfo--format-entries (org-texinfo--menu-entries scope info) info))
  959. ((zerop level) nil)
  960. (t
  961. (org-element-normalize-string
  962. (mapconcat
  963. (lambda (h)
  964. (let ((entries (org-texinfo--menu-entries h info)))
  965. (when entries
  966. (concat
  967. (format "%s\n\n%s\n"
  968. (org-export-data (org-export-get-alt-title h info) info)
  969. (org-texinfo--format-entries entries info))
  970. (org-texinfo--build-menu h info (1- level))))))
  971. (org-texinfo--menu-entries scope info) "")))))
  972. (defun org-texinfo--format-entries (entries info)
  973. "Format all direct menu entries in SCOPE, as a string.
  974. SCOPE is either a headline or a full Org document. INFO is
  975. a plist containing contextual information."
  976. (org-element-normalize-string
  977. (mapconcat
  978. (lambda (h)
  979. (let* ((title (org-export-data
  980. (org-export-get-alt-title h info) info))
  981. (node (org-texinfo--get-node h info))
  982. (entry (concat "* " title ":"
  983. (if (string= title node) ":"
  984. (concat " " node ". "))))
  985. (desc (org-element-property :DESCRIPTION h)))
  986. (if (not desc) entry
  987. (format (format "%%-%ds %%s" org-texinfo-node-description-column)
  988. entry desc))))
  989. entries "\n")))
  990. (defun org-texinfo--menu-entries (scope info)
  991. "List direct children in SCOPE needing a menu entry.
  992. SCOPE is a headline or a full parse tree. INFO is a plist
  993. holding contextual information."
  994. (let* ((cache (or (plist-get info :texinfo-entries-cache)
  995. (plist-get (plist-put info :texinfo-entries-cache
  996. (make-hash-table :test #'eq))
  997. :texinfo-entries-cache)))
  998. (cached-entries (gethash scope cache 'no-cache)))
  999. (if (not (eq cached-entries 'no-cache)) cached-entries
  1000. (puthash scope
  1001. (org-element-map (org-element-contents scope) 'headline
  1002. (lambda (h)
  1003. (and (not (org-not-nil (org-element-property :COPYING h)))
  1004. (not (org-element-property :footnote-section-p h))
  1005. (not (org-export-low-level-p h info))
  1006. h))
  1007. info nil 'headline)
  1008. cache))))
  1009. ;;;; Node Property
  1010. (defun org-texinfo-node-property (node-property contents info)
  1011. "Transcode a NODE-PROPERTY element from Org to Texinfo.
  1012. CONTENTS is nil. INFO is a plist holding contextual
  1013. information."
  1014. (format "%s:%s"
  1015. (org-element-property :key node-property)
  1016. (let ((value (org-element-property :value node-property)))
  1017. (if value (concat " " value) ""))))
  1018. ;;;; Paragraph
  1019. (defun org-texinfo-paragraph (paragraph contents info)
  1020. "Transcode a PARAGRAPH element from Org to Texinfo.
  1021. CONTENTS is the contents of the paragraph, as a string. INFO is
  1022. the plist used as a communication channel."
  1023. contents)
  1024. ;;;; Plain List
  1025. (defun org-texinfo-plain-list (plain-list contents info)
  1026. "Transcode a PLAIN-LIST element from Org to Texinfo.
  1027. CONTENTS is the contents of the list. INFO is a plist holding
  1028. contextual information."
  1029. (let* ((attr (org-export-read-attribute :attr_texinfo plain-list))
  1030. (indic (or (plist-get attr :indic)
  1031. (plist-get info :texinfo-def-table-markup)))
  1032. (table-type (plist-get attr :table-type))
  1033. (type (org-element-property :type plain-list))
  1034. (list-type (cond
  1035. ((eq type 'ordered) "enumerate")
  1036. ((eq type 'unordered) "itemize")
  1037. ((member table-type '("ftable" "vtable")) table-type)
  1038. (t "table"))))
  1039. (format "@%s\n%s@end %s"
  1040. (if (eq type 'descriptive) (concat list-type " " indic) list-type)
  1041. contents
  1042. list-type)))
  1043. ;;;; Plain Text
  1044. (defun org-texinfo-plain-text (text info)
  1045. "Transcode a TEXT string from Org to Texinfo.
  1046. TEXT is the string to transcode. INFO is a plist holding
  1047. contextual information."
  1048. ;; First protect @, { and }.
  1049. (let ((output (org-texinfo--sanitize-content text)))
  1050. ;; Activate smart quotes. Be sure to provide original TEXT string
  1051. ;; since OUTPUT may have been modified.
  1052. (when (plist-get info :with-smart-quotes)
  1053. (setq output
  1054. (org-export-activate-smart-quotes output :texinfo info text)))
  1055. ;; LaTeX into @LaTeX{} and TeX into @TeX{}
  1056. (let ((case-fold-search nil)
  1057. (start 0))
  1058. (while (string-match "\\(\\(?:La\\)?TeX\\)" output start)
  1059. (setq output (replace-match
  1060. (format "@%s{}" (match-string 1 output)) nil t output)
  1061. start (match-end 0))))
  1062. ;; Convert special strings.
  1063. (when (plist-get info :with-special-strings)
  1064. (while (string-match (regexp-quote "...") output)
  1065. (setq output (replace-match "@dots{}" nil t output))))
  1066. ;; Handle break preservation if required.
  1067. (when (plist-get info :preserve-breaks)
  1068. (setq output (replace-regexp-in-string
  1069. "\\(\\\\\\\\\\)?[ \t]*\n" " @*\n" output)))
  1070. ;; Return value.
  1071. output))
  1072. ;;;; Planning
  1073. (defun org-texinfo-planning (planning contents info)
  1074. "Transcode a PLANNING element from Org to Texinfo.
  1075. CONTENTS is nil. INFO is a plist holding contextual
  1076. information."
  1077. (concat
  1078. "@noindent"
  1079. (mapconcat
  1080. 'identity
  1081. (delq nil
  1082. (list
  1083. (let ((closed (org-element-property :closed planning)))
  1084. (when closed
  1085. (concat
  1086. (format "@strong{%s} " org-closed-string)
  1087. (format (plist-get info :texinfo-inactive-timestamp-format)
  1088. (org-timestamp-translate closed)))))
  1089. (let ((deadline (org-element-property :deadline planning)))
  1090. (when deadline
  1091. (concat
  1092. (format "@strong{%s} " org-deadline-string)
  1093. (format (plist-get info :texinfo-active-timestamp-format)
  1094. (org-timestamp-translate deadline)))))
  1095. (let ((scheduled (org-element-property :scheduled planning)))
  1096. (when scheduled
  1097. (concat
  1098. (format "@strong{%s} " org-scheduled-string)
  1099. (format (plist-get info :texinfo-active-timestamp-format)
  1100. (org-timestamp-translate scheduled)))))))
  1101. " ")
  1102. "@*"))
  1103. ;;;; Property Drawer
  1104. (defun org-texinfo-property-drawer (property-drawer contents info)
  1105. "Transcode a PROPERTY-DRAWER element from Org to Texinfo.
  1106. CONTENTS holds the contents of the drawer. INFO is a plist
  1107. holding contextual information."
  1108. (and (org-string-nw-p contents)
  1109. (format "@verbatim\n%s@end verbatim" contents)))
  1110. ;;;; Quote Block
  1111. (defun org-texinfo-quote-block (quote-block contents info)
  1112. "Transcode a QUOTE-BLOCK element from Org to Texinfo.
  1113. CONTENTS holds the contents of the block. INFO is a plist
  1114. holding contextual information."
  1115. (let* ((title (org-element-property :name quote-block))
  1116. (start-quote (concat "@quotation"
  1117. (if title
  1118. (format " %s" title)))))
  1119. (format "%s\n%s@end quotation" start-quote contents)))
  1120. ;;;; Radio Target
  1121. (defun org-texinfo-radio-target (radio-target text info)
  1122. "Transcode a RADIO-TARGET object from Org to Texinfo.
  1123. TEXT is the text of the target. INFO is a plist holding
  1124. contextual information."
  1125. (format "@anchor{%s}%s"
  1126. (org-export-get-reference radio-target info)
  1127. text))
  1128. ;;;; Section
  1129. (defun org-texinfo-section (section contents info)
  1130. "Transcode a SECTION element from Org to Texinfo.
  1131. CONTENTS holds the contents of the section. INFO is a plist
  1132. holding contextual information."
  1133. (concat contents
  1134. (let ((parent (org-export-get-parent-headline section)))
  1135. (and parent (org-texinfo-make-menu parent info)))))
  1136. ;;;; Special Block
  1137. (defun org-texinfo-special-block (special-block contents info)
  1138. "Transcode a SPECIAL-BLOCK element from Org to Texinfo.
  1139. CONTENTS holds the contents of the block. INFO is a plist used
  1140. as a communication channel."
  1141. (let ((type (org-element-property :type special-block)))
  1142. (format "@%s\n%s@end %s" type contents type)))
  1143. ;;;; Src Block
  1144. (defun org-texinfo-src-block (src-block contents info)
  1145. "Transcode a SRC-BLOCK element from Org to Texinfo.
  1146. CONTENTS holds the contents of the item. INFO is a plist holding
  1147. contextual information."
  1148. (let* ((lisp (org-string-match-p "lisp"
  1149. (org-element-property :language src-block)))
  1150. (code (org-texinfo--sanitize-content
  1151. (org-export-format-code-default src-block info)))
  1152. (value (format
  1153. (if lisp "@lisp\n%s@end lisp" "@example\n%s@end example")
  1154. code))
  1155. (caption (org-export-get-caption src-block))
  1156. (shortcaption (org-export-get-caption src-block t)))
  1157. (if (not (or caption shortcaption)) value
  1158. (org-texinfo--wrap-float value
  1159. info
  1160. (org-export-translate "Listing" :utf-8 info)
  1161. (org-element-property :name src-block)
  1162. caption
  1163. shortcaption))))
  1164. ;;;; Statistics Cookie
  1165. (defun org-texinfo-statistics-cookie (statistics-cookie contents info)
  1166. "Transcode a STATISTICS-COOKIE object from Org to Texinfo.
  1167. CONTENTS is nil. INFO is a plist holding contextual information."
  1168. (org-element-property :value statistics-cookie))
  1169. ;;;; Subscript
  1170. (defun org-texinfo-subscript (subscript contents info)
  1171. "Transcode a SUBSCRIPT object from Org to Texinfo.
  1172. CONTENTS is the contents of the object. INFO is a plist holding
  1173. contextual information."
  1174. (format "@math{_%s}" contents))
  1175. ;;;; Superscript
  1176. (defun org-texinfo-superscript (superscript contents info)
  1177. "Transcode a SUPERSCRIPT object from Org to Texinfo.
  1178. CONTENTS is the contents of the object. INFO is a plist holding
  1179. contextual information."
  1180. (format "@math{^%s}" contents))
  1181. ;;;; Table
  1182. (defun org-texinfo-table (table contents info)
  1183. "Transcode a TABLE element from Org to Texinfo.
  1184. CONTENTS is the contents of the table. INFO is a plist holding
  1185. contextual information."
  1186. (if (eq (org-element-property :type table) 'table.el)
  1187. (format "@verbatim\n%s@end verbatim"
  1188. (org-element-normalize-string
  1189. (org-element-property :value table)))
  1190. (let* ((col-width (org-export-read-attribute :attr_texinfo table :columns))
  1191. (columns
  1192. (if col-width (format "@columnfractions %s" col-width)
  1193. (org-texinfo-table-column-widths table info)))
  1194. (caption (org-export-get-caption table))
  1195. (shortcaption (org-export-get-caption table t))
  1196. (table-str (format "@multitable %s\n%s@end multitable"
  1197. columns
  1198. contents)))
  1199. (if (not (or caption shortcaption)) table-str
  1200. (org-texinfo--wrap-float table-str
  1201. info
  1202. (org-export-translate "Table" :utf-8 info)
  1203. (org-element-property :name table)
  1204. caption
  1205. shortcaption)))))
  1206. (defun org-texinfo-table-column-widths (table info)
  1207. "Determine the largest table cell in each column to process alignment.
  1208. TABLE is the table element to transcode. INFO is a plist used as
  1209. a communication channel."
  1210. (let ((widths (make-vector (cdr (org-export-table-dimensions table info)) 0)))
  1211. (org-element-map table 'table-row
  1212. (lambda (row)
  1213. (let ((idx 0))
  1214. (org-element-map row 'table-cell
  1215. (lambda (cell)
  1216. ;; Length of the cell in the original buffer is only an
  1217. ;; approximation of the length of the cell in the
  1218. ;; output. It can sometimes fail (e.g. it considers
  1219. ;; "/a/" being larger than "ab").
  1220. (let ((w (- (org-element-property :contents-end cell)
  1221. (org-element-property :contents-begin cell))))
  1222. (aset widths idx (max w (aref widths idx))))
  1223. (incf idx))
  1224. info)))
  1225. info)
  1226. (format "{%s}" (mapconcat (lambda (w) (make-string w ?a)) widths "} {"))))
  1227. ;;;; Table Cell
  1228. (defun org-texinfo-table-cell (table-cell contents info)
  1229. "Transcode a TABLE-CELL element from Org to Texinfo.
  1230. CONTENTS is the cell contents. INFO is a plist used as
  1231. a communication channel."
  1232. (concat
  1233. (let ((scientific-notation
  1234. (plist-get info :texinfo-table-scientific-notation)))
  1235. (if (and contents
  1236. scientific-notation
  1237. (string-match orgtbl-exp-regexp contents))
  1238. ;; Use appropriate format string for scientific notation.
  1239. (format scientific-notation
  1240. (match-string 1 contents)
  1241. (match-string 2 contents))
  1242. contents))
  1243. (when (org-export-get-next-element table-cell info) "\n@tab ")))
  1244. ;;;; Table Row
  1245. (defun org-texinfo-table-row (table-row contents info)
  1246. "Transcode a TABLE-ROW element from Org to Texinfo.
  1247. CONTENTS is the contents of the row. INFO is a plist used as
  1248. a communication channel."
  1249. ;; Rules are ignored since table separators are deduced from
  1250. ;; borders of the current row.
  1251. (when (eq (org-element-property :type table-row) 'standard)
  1252. (let ((rowgroup-tag
  1253. (if (and (= 1 (org-export-table-row-group table-row info))
  1254. (org-export-table-has-header-p
  1255. (org-export-get-parent-table table-row) info))
  1256. "@headitem "
  1257. "@item ")))
  1258. (concat rowgroup-tag contents "\n"))))
  1259. ;;;; Target
  1260. (defun org-texinfo-target (target contents info)
  1261. "Transcode a TARGET object from Org to Texinfo.
  1262. CONTENTS is nil. INFO is a plist holding contextual
  1263. information."
  1264. (format "@anchor{%s}" (org-export-get-reference target info)))
  1265. ;;;; Timestamp
  1266. (defun org-texinfo-timestamp (timestamp contents info)
  1267. "Transcode a TIMESTAMP object from Org to Texinfo.
  1268. CONTENTS is nil. INFO is a plist holding contextual
  1269. information."
  1270. (let ((value (org-texinfo-plain-text
  1271. (org-timestamp-translate timestamp) info)))
  1272. (case (org-element-property :type timestamp)
  1273. ((active active-range)
  1274. (format (plist-get info :texinfo-active-timestamp-format) value))
  1275. ((inactive inactive-range)
  1276. (format (plist-get info :texinfo-inactive-timestamp-format) value))
  1277. (t (format (plist-get info :texinfo-diary-timestamp-format) value)))))
  1278. ;;;; Verbatim
  1279. (defun org-texinfo-verbatim (verbatim contents info)
  1280. "Transcode a VERBATIM object from Org to Texinfo.
  1281. CONTENTS is nil. INFO is a plist used as a communication
  1282. channel."
  1283. (org-texinfo--text-markup
  1284. (org-element-property :value verbatim) 'verbatim info))
  1285. ;;;; Verse Block
  1286. (defun org-texinfo-verse-block (verse-block contents info)
  1287. "Transcode a VERSE-BLOCK element from Org to Texinfo.
  1288. CONTENTS is verse block contents. INFO is a plist holding
  1289. contextual information."
  1290. (format "@display\n%s@end display" contents))
  1291. ;;; Interactive functions
  1292. (defun org-texinfo-export-to-texinfo
  1293. (&optional async subtreep visible-only body-only ext-plist)
  1294. "Export current buffer to a Texinfo file.
  1295. If narrowing is active in the current buffer, only export its
  1296. narrowed part.
  1297. If a region is active, export that region.
  1298. A non-nil optional argument ASYNC means the process should happen
  1299. asynchronously. The resulting file should be accessible through
  1300. the `org-export-stack' interface.
  1301. When optional argument SUBTREEP is non-nil, export the sub-tree
  1302. at point, extracting information from the headline properties
  1303. first.
  1304. When optional argument VISIBLE-ONLY is non-nil, don't export
  1305. contents of hidden elements.
  1306. When optional argument BODY-ONLY is non-nil, only write code
  1307. between \"\\begin{document}\" and \"\\end{document}\".
  1308. EXT-PLIST, when provided, is a property list with external
  1309. parameters overriding Org default settings, but still inferior to
  1310. file-local settings.
  1311. Return output file's name."
  1312. (interactive)
  1313. (let ((outfile (org-export-output-file-name ".texi" subtreep))
  1314. (org-export-coding-system org-texinfo-coding-system))
  1315. (org-export-to-file 'texinfo outfile
  1316. async subtreep visible-only body-only ext-plist)))
  1317. (defun org-texinfo-export-to-info
  1318. (&optional async subtreep visible-only body-only ext-plist)
  1319. "Export current buffer to Texinfo then process through to INFO.
  1320. If narrowing is active in the current buffer, only export its
  1321. narrowed part.
  1322. If a region is active, export that region.
  1323. A non-nil optional argument ASYNC means the process should happen
  1324. asynchronously. The resulting file should be accessible through
  1325. the `org-export-stack' interface.
  1326. When optional argument SUBTREEP is non-nil, export the sub-tree
  1327. at point, extracting information from the headline properties
  1328. first.
  1329. When optional argument VISIBLE-ONLY is non-nil, don't export
  1330. contents of hidden elements.
  1331. When optional argument BODY-ONLY is non-nil, only write code
  1332. between \"\\begin{document}\" and \"\\end{document}\".
  1333. EXT-PLIST, when provided, is a property list with external
  1334. parameters overriding Org default settings, but still inferior to
  1335. file-local settings.
  1336. When optional argument PUB-DIR is set, use it as the publishing
  1337. directory.
  1338. Return INFO file's name."
  1339. (interactive)
  1340. (let ((outfile (org-export-output-file-name ".texi" subtreep))
  1341. (org-export-coding-system org-texinfo-coding-system))
  1342. (org-export-to-file 'texinfo outfile
  1343. async subtreep visible-only body-only ext-plist
  1344. (lambda (file) (org-texinfo-compile file)))))
  1345. ;;;###autoload
  1346. (defun org-texinfo-publish-to-texinfo (plist filename pub-dir)
  1347. "Publish an org file to Texinfo.
  1348. FILENAME is the filename of the Org file to be published. PLIST
  1349. is the property list for the given project. PUB-DIR is the
  1350. publishing directory.
  1351. Return output file name."
  1352. (org-publish-org-to 'texinfo filename ".texi" plist pub-dir))
  1353. ;;;###autoload
  1354. (defun org-texinfo-convert-region-to-texinfo ()
  1355. "Assume the current region has org-mode syntax, and convert it to Texinfo.
  1356. This can be used in any buffer. For example, you can write an
  1357. itemized list in org-mode syntax in an Texinfo buffer and use
  1358. this command to convert it."
  1359. (interactive)
  1360. (org-export-replace-region-by 'texinfo))
  1361. (defun org-texinfo-compile (file)
  1362. "Compile a texinfo file.
  1363. FILE is the name of the file being compiled. Processing is
  1364. done through the command specified in `org-texinfo-info-process'.
  1365. Return INFO file name or an error if it couldn't be produced."
  1366. (let* ((base-name (file-name-sans-extension (file-name-nondirectory file)))
  1367. (full-name (file-truename file))
  1368. (out-dir (file-name-directory file))
  1369. ;; Properly set working directory for compilation.
  1370. (default-directory (if (file-name-absolute-p file)
  1371. (file-name-directory full-name)
  1372. default-directory))
  1373. errors)
  1374. (message (format "Processing Texinfo file %s..." file))
  1375. (save-window-excursion
  1376. ;; Replace %b, %f and %o with appropriate values in each command
  1377. ;; before applying it. Output is redirected to "*Org INFO
  1378. ;; Texinfo Output*" buffer.
  1379. (let ((outbuf (get-buffer-create "*Org INFO Texinfo Output*")))
  1380. (with-current-buffer outbuf (compilation-mode))
  1381. (dolist (command org-texinfo-info-process)
  1382. (shell-command
  1383. (replace-regexp-in-string
  1384. "%b" (shell-quote-argument base-name)
  1385. (replace-regexp-in-string
  1386. "%f" (shell-quote-argument full-name)
  1387. (replace-regexp-in-string
  1388. "%o" (shell-quote-argument out-dir) command t t) t t) t t)
  1389. outbuf))
  1390. ;; Collect standard errors from output buffer.
  1391. (setq errors (org-texinfo-collect-errors outbuf)))
  1392. (let ((infofile (concat out-dir base-name ".info")))
  1393. ;; Check for process failure. Provide collected errors if
  1394. ;; possible.
  1395. (if (not (file-exists-p infofile))
  1396. (error (concat (format "INFO file %s wasn't produced" infofile)
  1397. (when errors (concat ": " errors))))
  1398. ;; Else remove log files, when specified, and signal end of
  1399. ;; process to user, along with any error encountered.
  1400. (when org-texinfo-remove-logfiles
  1401. (dolist (ext org-texinfo-logfiles-extensions)
  1402. (let ((file (concat out-dir base-name "." ext)))
  1403. (when (file-exists-p file) (delete-file file)))))
  1404. (message (concat "Process completed"
  1405. (if (not errors) "."
  1406. (concat " with errors: " errors)))))
  1407. ;; Return output file name.
  1408. infofile))))
  1409. (defun org-texinfo-collect-errors (buffer)
  1410. "Collect some kind of errors from \"makeinfo\" command output.
  1411. BUFFER is the buffer containing output.
  1412. Return collected error types as a string, or nil if there was
  1413. none."
  1414. (with-current-buffer buffer
  1415. (save-excursion
  1416. (goto-char (point-min))
  1417. ;; Find final "makeinfo" run.
  1418. (when t
  1419. (let ((case-fold-search t)
  1420. (errors ""))
  1421. (when (save-excursion
  1422. (re-search-forward "perhaps incorrect sectioning?" nil t))
  1423. (setq errors (concat errors " [incorrect sectioning]")))
  1424. (when (save-excursion
  1425. (re-search-forward "missing close brace" nil t))
  1426. (setq errors (concat errors " [syntax error]")))
  1427. (when (save-excursion
  1428. (re-search-forward "Unknown command" nil t))
  1429. (setq errors (concat errors " [undefined @command]")))
  1430. (when (save-excursion
  1431. (re-search-forward "No matching @end" nil t))
  1432. (setq errors (concat errors " [block incomplete]")))
  1433. (when (save-excursion
  1434. (re-search-forward "requires a sectioning" nil t))
  1435. (setq errors (concat errors " [invalid section command]")))
  1436. (when (save-excursion
  1437. (re-search-forward "\\[unexpected\]" nil t))
  1438. (setq errors (concat errors " [unexpected error]")))
  1439. (when (save-excursion
  1440. (re-search-forward "misplaced " nil t))
  1441. (setq errors (concat errors " [syntax error]")))
  1442. (and (org-string-nw-p errors) (org-trim errors)))))))
  1443. (provide 'ox-texinfo)
  1444. ;; Local variables:
  1445. ;; generated-autoload-file: "org-loaddefs.el"
  1446. ;; End:
  1447. ;;; ox-texinfo.el ends here