From 7a61bb6a7c7e1122199232a1c01885fb270dd370 Mon Sep 17 00:00:00 2001 From: Suhail Date: Mon, 17 Jun 2024 21:04:18 -0400 Subject: [PATCH 1/2] ox-html: Add support for attr_html for source code blocks * lisp/ox-html.el (org-html-src-block): Handle attr_html in a manner similar to example blocks. TINYCHANGE --- lisp/ox-html.el | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index d1687cf5a..675d85ffe 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -3667,14 +3667,24 @@ (defun org-html-src-block contextual information." (if (org-export-read-attribute :attr_html src-block :textarea) (org-html--textarea-block src-block) - (let* ((lang (org-element-property :language src-block)) + (let* ((attributes (org-export-read-attribute :attr_html src-block)) + (lang (org-element-property :language src-block)) (code (org-html-format-code src-block info)) (label (let ((lbl (org-html--reference src-block info t))) (if lbl (format " id=\"%s\"" lbl) ""))) (klipsify (and (plist-get info :html-klipsify-src) (member lang '("javascript" "js" "ruby" "scheme" "clojure" "php" "html"))))) - (format "
\n%s%s\n
" + (if-let ((class-val (plist-get attributes :class))) + (setq attributes (plist-put attributes :class (concat "org-src-container " class-val))) + (setq attributes (plist-put attributes :class "org-src-container"))) + (format "\n%s%s\n" + (let* ((reference (org-html--reference src-block info)) + (a (org-html--make-attribute-string + (if (or (not reference) (plist-member attributes :id)) + attributes + (plist-put attributes :id reference))))) + (if (org-string-nw-p a) (concat " " a) "")) ;; Build caption. (let ((caption (org-export-get-caption src-block))) (if (not caption) "" -- 2.45.2