From 8c832d374066bbba430dc21a6b4fb098361c44a9 Mon Sep 17 00:00:00 2001 Message-Id: <8c832d374066bbba430dc21a6b4fb098361c44a9.1673863743.git.yantar92@posteo.net> In-Reply-To: References: From: Ihor Radchenko Date: Mon, 16 Jan 2023 13:04:01 +0300 Subject: [PATCH 2/2] org-html-src-block: Treat code blocks without LANG equally MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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ö Link: https://orgmode.org/list/87zgb90win.fsf@localhost --- lisp/ox-html.el | 52 ++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 7b79c57d4..5e58ccba3 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -3616,32 +3616,32 @@ (defun org-html-src-block (src-block _contents info) (klipsify (and (plist-get info :html-klipsify-src) (member lang '("javascript" "js" "ruby" "scheme" "clojure" "php" "html"))))) - (if (not lang) (format "
\n%s
" label code) - (format "
\n%s%s\n
" - ;; Build caption. - (let ((caption (org-export-get-caption src-block))) - (if (not caption) "" - (let ((listing-number - (format - "%s " - (format - (org-html--translate "Listing %d:" info) - (org-export-get-ordinal - src-block info nil #'org-html--has-caption-p))))) - (format "" - listing-number - (org-trim (org-export-data caption info)))))) - ;; Contents. - (if klipsify - (format "
%s
" - lang - label - (if (string= lang "html") - " data-editor-type=\"html\"" - "") - code) - (format "
%s
" - lang label code))))))) + (format "
\n%s%s\n
" + ;; Build caption. + (let ((caption (org-export-get-caption src-block))) + (if (not caption) "" + (let ((listing-number + (format + "%s " + (format + (org-html--translate "Listing %d:" info) + (org-export-get-ordinal + src-block info nil #'org-html--has-caption-p))))) + (format "" + listing-number + (org-trim (org-export-data caption info)))))) + ;; Contents. + (if klipsify + (format "
%s
" + lang ; lang being nil is OK. + label + (if (string= lang "html") + " data-editor-type=\"html\"" + "") + code) + (format "
%s
" + ;; Lang being nil is OK. + lang label code)))))) ;;;; Statistics Cookie -- 2.39.0