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:
Ihor Radchenko 2023-01-16 13:04:01 +03:00
parent d98ca046cc
commit 77a1cfb9a4
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 26 additions and 26 deletions

View File

@ -3616,7 +3616,6 @@ 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)))
@ -3634,14 +3633,15 @@ contextual information."
;; 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 ; lang being nil is OK.
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 label code))))))) ;; Lang being nil is OK.
lang label code))))))
;;;; Statistics Cookie ;;;; Statistics Cookie