org-html-src-block: Treat code blocks without LANG equally
* lisp/ox-html.el (org-html-src-block): Do not treat src blocks without LANG as example blocks. Instead, export them using "nil" language. This way, such src blocks will get captions, unlike example blocks. The new behavior is consistent with ox-latex and ox-ascii. Reported-by: Johan Bolmsjö <org-mode@johan.bitmaster.se> Link: https://orgmode.org/list/87zgb90win.fsf@localhost
This commit is contained in:
parent
d98ca046cc
commit
77a1cfb9a4
|
@ -3616,32 +3616,32 @@ contextual information."
|
||||||
(klipsify (and (plist-get info :html-klipsify-src)
|
(klipsify (and (plist-get info :html-klipsify-src)
|
||||||
(member lang '("javascript" "js"
|
(member lang '("javascript" "js"
|
||||||
"ruby" "scheme" "clojure" "php" "html")))))
|
"ruby" "scheme" "clojure" "php" "html")))))
|
||||||
(if (not lang) (format "<pre class=\"example\"%s>\n%s</pre>" label code)
|
(format "<div class=\"org-src-container\">\n%s%s\n</div>"
|
||||||
(format "<div class=\"org-src-container\">\n%s%s\n</div>"
|
;; Build caption.
|
||||||
;; Build caption.
|
(let ((caption (org-export-get-caption src-block)))
|
||||||
(let ((caption (org-export-get-caption src-block)))
|
(if (not caption) ""
|
||||||
(if (not caption) ""
|
(let ((listing-number
|
||||||
(let ((listing-number
|
(format
|
||||||
(format
|
"<span class=\"listing-number\">%s </span>"
|
||||||
"<span class=\"listing-number\">%s </span>"
|
(format
|
||||||
(format
|
(org-html--translate "Listing %d:" info)
|
||||||
(org-html--translate "Listing %d:" info)
|
(org-export-get-ordinal
|
||||||
(org-export-get-ordinal
|
src-block info nil #'org-html--has-caption-p)))))
|
||||||
src-block info nil #'org-html--has-caption-p)))))
|
(format "<label class=\"org-src-name\">%s%s</label>"
|
||||||
(format "<label class=\"org-src-name\">%s%s</label>"
|
listing-number
|
||||||
listing-number
|
(org-trim (org-export-data caption info))))))
|
||||||
(org-trim (org-export-data caption info))))))
|
;; Contents.
|
||||||
;; Contents.
|
(if klipsify
|
||||||
(if klipsify
|
(format "<pre><code class=\"src src-%s\"%s%s>%s</code></pre>"
|
||||||
(format "<pre><code class=\"src src-%s\"%s%s>%s</code></pre>"
|
lang ; lang being nil is OK.
|
||||||
lang
|
label
|
||||||
label
|
(if (string= lang "html")
|
||||||
(if (string= lang "html")
|
" data-editor-type=\"html\""
|
||||||
" data-editor-type=\"html\""
|
"")
|
||||||
"")
|
code)
|
||||||
code)
|
(format "<pre class=\"src src-%s\"%s>%s</pre>"
|
||||||
(format "<pre class=\"src src-%s\"%s>%s</pre>"
|
;; Lang being nil is OK.
|
||||||
lang label code)))))))
|
lang label code))))))
|
||||||
|
|
||||||
;;;; Statistics Cookie
|
;;;; Statistics Cookie
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue