GNU bug report logs - #72945
29.4; Org: ox-html: attr_html not supported in source code and fixed-width blocks during HTML export

Previous Next

Package: emacs;

Reported by: "Suhail Singh" <suhailsingh247 <at> gmail.com>

Date: Mon, 2 Sep 2024 01:34:02 UTC

Severity: normal

Found in version 29.4

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 72945 <at> debbugs.gnu.org (full text, mbox):

From: "Suhail Singh" <suhailsingh247 <at> gmail.com>
To: 72945 <at> debbugs.gnu.org
Subject: [PATCH 1/2] ox-html: Add support for attr_html for source code blocks
Date: Sun, 01 Sep 2024 21:56:39 -0400
* lisp/ox-html.el (org-html-src-block): Add org-src-container class to
any class attributes specified via the attr_html keyword.

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 446698758..3e83f02e2 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 "<div class=\"org-src-container\">\n%s%s\n</div>"
+      (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 "<div%s>\n%s%s\n</div>"
+              (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) ""

base-commit: 3428b522fb83c793d0915d63a30601eb993e2b30
-- 
2.46.0





This bug report was last modified 312 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.