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)
|
||||
(member lang '("javascript" "js"
|
||||
"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>"
|
||||
;; Build caption.
|
||||
(let ((caption (org-export-get-caption src-block)))
|
||||
(if (not caption) ""
|
||||
(let ((listing-number
|
||||
(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.
|
||||
(if klipsify
|
||||
(format "<pre><code class=\"src src-%s\"%s%s>%s</code></pre>"
|
||||
lang
|
||||
label
|
||||
(if (string= lang "html")
|
||||
" data-editor-type=\"html\""
|
||||
"")
|
||||
code)
|
||||
(format "<pre class=\"src src-%s\"%s>%s</pre>"
|
||||
lang label code)))))))
|
||||
(format "<div class=\"org-src-container\">\n%s%s\n</div>"
|
||||
;; Build caption.
|
||||
(let ((caption (org-export-get-caption src-block)))
|
||||
(if (not caption) ""
|
||||
(let ((listing-number
|
||||
(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.
|
||||
(if klipsify
|
||||
(format "<pre><code class=\"src src-%s\"%s%s>%s</code></pre>"
|
||||
lang ; lang being nil is OK.
|
||||
label
|
||||
(if (string= lang "html")
|
||||
" data-editor-type=\"html\""
|
||||
"")
|
||||
code)
|
||||
(format "<pre class=\"src src-%s\"%s>%s</pre>"
|
||||
;; Lang being nil is OK.
|
||||
lang label code))))))
|
||||
|
||||
;;;; Statistics Cookie
|
||||
|
||||
|
|
Loading…
Reference in New Issue