ox-texinfo: Handle listings with captions and list of listings

* lisp/ox-texinfo.el (org-texinfo-keyword): Handle "#+TOC: listings".
(org-texinfo-src-block): Wrap listings with captions within @float.
This commit is contained in:
Nicolas Goaziou 2015-05-26 10:02:36 +02:00
parent e36139ea02
commit 4049c680fb
2 changed files with 32 additions and 5 deletions

View File

@ -932,7 +932,10 @@ CONTENTS is nil. INFO is a plist holding contextual information."
((string= key "TOC")
(cond ((org-string-match-p "\\<tables\\>" value)
(concat "@listoffloats "
(org-export-translate "Table" :utf-8 info))))))))
(org-export-translate "Table" :utf-8 info)))
((org-string-match-p "\\<listings\\>" value)
(concat "@listoffloats "
(org-export-translate "Listing" :utf-8 info))))))))
;;;; Line Break
@ -1305,11 +1308,22 @@ 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 ((lispp (org-string-match-p "lisp"
(let* ((lisp (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)))
(code (org-texinfo--sanitize-content
(org-export-format-code-default src-block info)))
(value (format
(if lisp "@lisp\n%s@end lisp" "@example\n%s@end example")
code))
(caption (org-export-get-caption src-block))
(shortcaption (org-export-get-caption src-block t)))
(if (not (or caption shortcaption)) value
(org-texinfo--wrap-float value
info
(org-export-translate "Listing" :utf-8 info)
(org-element-property :name src-block)
caption
shortcaption))))
;;;; Statistics Cookie

View File

@ -5460,6 +5460,19 @@ them."
:utf-8 "Список таблиц")
("sv" :default "Tabeller")
("zh-CN" :html "&#34920;&#26684;&#30446;&#24405;" :utf-8 "表格目录"))
("Listing"
("da" :default "Program")
("de" :default "Programmlisting")
("es" :default "Listado de programa")
("et" :default "Loend")
("fr" :default "Programme" :html "Programme")
("ja" :default "ソースコード")
("no" :default "Dataprogram")
("nb" :default "Dataprogram")
("pt_BR" :default "Listagem")
("ru" :html "&#1056;&#1072;&#1089;&#1087;&#1077;&#1095;&#1072;&#1090;&#1082;&#1072;"
:utf-8 "Распечатка")
("zh-CN" :html "&#20195;&#30721;" :utf-8 "代码"))
("Listing %d:"
("da" :default "Program %d")
("de" :default "Programmlisting %d")