Skip to content

Commit

Permalink
Number `Listing' (source code block) captions in pandoc export.
Browse files Browse the repository at this point in the history
Overrides the exporter for source code blocks to add the org-mode
standard numbered label ("Listing %d:") before any caption text. As with
the Table and Figure caption labels, this is passed through org-mode's
standard language translators to convert the label to the local language.
  • Loading branch information
Lixin Chin committed Dec 9, 2016
1 parent 62ff8e3 commit 9876d59
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion ox-pandoc.el
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@
(link . org-pandoc-link)
(table . org-pandoc-table)
(template . org-pandoc-template)
(paragraph . org-pandoc-paragraph))
(paragraph . org-pandoc-paragraph)
(src-block . org-pandoc-src-block))
;; :export-block "PANDOC"
:menu-entry
`(?p "export via pandoc"
Expand Down Expand Up @@ -1411,6 +1412,15 @@ the plist used as a communication channel."
;; preserves #+ATTR_* tags in the output.
(org-export-expand paragraph contents t))

(defun org-pandoc-src-block (src-block contents info)
"Transcode a SRC-BLOCK element from Org to Pandoc.
CONTENTS is the contents of the table. INFO is a plist holding
contextual information."
(org-pandoc-set-caption-title src-block info "Listing %d:"
#'org-pandoc--has-caption-p)
;; Export the src-block with it's modified caption
(org-export-expand src-block contents t))

(defun org-pandoc-identity (blob contents _info)
"Transcode BLOB element or object back into Org syntax.
CONTENTS is its contents, as a string or nil. INFO is ignored.
Expand Down

0 comments on commit 9876d59

Please sign in to comment.