emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]


From: Joshua Honeycutt
Date: Tue, 20 Sep 2022 11:30:04 -0500

To: emacs-orgmode@gnu.org
Subject: Bug: org-html-example-block can produce multiple class attributes [9.4 
(9.4-dist @ /usr/share/emacs/site-lisp/elpa/org-9.4/)]
From: Joshua Honeycutt <coweater@chaos.honeycutt>
--text follows this line--

Emacs  : GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.24, 
cairo version 1.16.0)
 of 2021-03-27, modified by Debian
Package: Org mode version 9.4 (9.4-dist @ 
/usr/share/emacs/site-lisp/elpa/org-9.4/)

I added a class attribute to an example block as in:

  #+ATTR_HTML :class cmdout
  #+BEGIN_EXAMPLE
  text text text
  #+END_EXAMPLE

I expected this to produce a html tag like:

  <pre class="cmdout example">

but the output was instead:

  <pre class="example" class="cmdout">

In my browser this second class assignment was ignored.

org-html-example-block could instead add the 'example' class to other
attributes which get placed in the <pre> tag. I modified it to achieve
this outcome like this (from be2246a550b444560ec1718c11185ac7bfcfa646):

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 9024701aa..7036f44cd 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -2546,8 +2546,11 @@ information."
   (let ((attributes (org-export-read-attribute :attr_html example-block)))
     (if (plist-get attributes :textarea)
        (org-html--textarea-block example-block)
-      (format "<pre class=\"example\"%s>\n%s</pre>"
+      (format "<pre%s>\n%s</pre>"
              (let* ((reference (org-html--reference example-block info))
+                    (class (plist-get attributes :class))
+                    (attributes (plist-put attributes :class
+                                   (if class (concat class " example") 
"example")))
                     (a (org-html--make-attribute-string
                         (if (or (not reference) (plist-member attributes :id))
                             attributes



reply via email to

[Prev in Thread] Current Thread [Next in Thread]