mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-27 11:30:57 +00:00
ox-html: Number source blocks with listings
* lisp/ox-html.el (org-html-src-block): Number source block if it has a caption. Numbering is done among source blocks with a caption, only. Suggested-by: Clément Pit--Claudel <clement.pit@gmail.com> <http://permalink.gmane.org/gmane.emacs.orgmode/108808>
This commit is contained in:
parent
908b3b05cd
commit
579569cc84
|
@ -189,6 +189,11 @@ If the block has a =#+NAME:= attribute assigned, then the HTML element
|
||||||
will have an ~id~ attribute with that name in the HTML export. This
|
will have an ~id~ attribute with that name in the HTML export. This
|
||||||
enables one to create links to these elements in other places, e.g.,
|
enables one to create links to these elements in other places, e.g.,
|
||||||
~<a href="#name">text</a>~.
|
~<a href="#name">text</a>~.
|
||||||
|
**** Listings with captions are now numbered in HTML export
|
||||||
|
The class associated to the numbering is "listing-number". If you
|
||||||
|
don't want these blocks to be numbered, as it was the case until now,
|
||||||
|
You may want to add ~.listing-number { display: none; }~ to the CSS
|
||||||
|
used.
|
||||||
**** Line Numbering in SRC/EXAMPLE blocks support arbitrary start number
|
**** Line Numbering in SRC/EXAMPLE blocks support arbitrary start number
|
||||||
The ~-n~ option to ~SRC~ and ~EXAMPLE~ blocks can now take a numeric
|
The ~-n~ option to ~SRC~ and ~EXAMPLE~ blocks can now take a numeric
|
||||||
argument to specify the staring line number for the source or example
|
argument to specify the staring line number for the source or example
|
||||||
|
|
|
@ -3319,18 +3319,28 @@ contextual information."
|
||||||
(if (org-export-read-attribute :attr_html src-block :textarea)
|
(if (org-export-read-attribute :attr_html src-block :textarea)
|
||||||
(org-html--textarea-block src-block)
|
(org-html--textarea-block src-block)
|
||||||
(let ((lang (org-element-property :language src-block))
|
(let ((lang (org-element-property :language src-block))
|
||||||
(caption (org-export-get-caption src-block))
|
|
||||||
(code (org-html-format-code src-block info))
|
(code (org-html-format-code src-block info))
|
||||||
(label (let ((lbl (and (org-element-property :name src-block)
|
(label (let ((lbl (and (org-element-property :name src-block)
|
||||||
(org-export-get-reference src-block info))))
|
(org-export-get-reference src-block info))))
|
||||||
(if lbl (format " id=\"%s\"" lbl) ""))))
|
(if lbl (format " id=\"%s\"" lbl) ""))))
|
||||||
(if (not lang) (format "<pre class=\"example\"%s>\n%s</pre>" label code)
|
(if (not lang) (format "<pre class=\"example\"%s>\n%s</pre>" label code)
|
||||||
(format
|
(format "<div class=\"org-src-container\">\n%s%s\n</div>"
|
||||||
"<div class=\"org-src-container\">\n%s%s\n</div>"
|
;; Build caption.
|
||||||
(if (not caption) ""
|
(let ((caption (org-export-get-caption src-block)))
|
||||||
(format "<label class=\"org-src-name\">%s</label>"
|
(if (not caption) ""
|
||||||
(org-export-data caption info)))
|
(let ((listing-number
|
||||||
(format "\n<pre class=\"src src-%s\"%s>%s</pre>" lang label code))))))
|
(format
|
||||||
|
"<span class=\"listing-number\">%s </span>"
|
||||||
|
(format
|
||||||
|
(org-html--translate "Listing %d:" info)
|
||||||
|
(org-export-get-ordinal
|
||||||
|
src-block info nil #'org-html--has-caption-p)))))
|
||||||
|
(format "<label class=\"org-src-name\">%s%s</label>"
|
||||||
|
listing-number
|
||||||
|
(org-trim (org-export-data caption info))))))
|
||||||
|
;; Contents.
|
||||||
|
(format "<pre class=\"src src-%s\"%s>%s</pre>"
|
||||||
|
lang label code))))))
|
||||||
|
|
||||||
;;;; Statistics Cookie
|
;;;; Statistics Cookie
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue