emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* (no subject)
@ 2022-09-20 16:30 Joshua Honeycutt
  2022-10-09  3:28 ` Bug: org-html-example-block can produce multiple class attributes [9.4 (9.4-dist @/usr/share/emacs/site-lisp/elpa/org-9.4/)] Ihor Radchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Joshua Honeycutt @ 2022-09-20 16:30 UTC (permalink / raw)
  To: emacs-orgmode

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-02-03 14:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-20 16:30 Joshua Honeycutt
2022-10-09  3:28 ` Bug: org-html-example-block can produce multiple class attributes [9.4 (9.4-dist @/usr/share/emacs/site-lisp/elpa/org-9.4/)] Ihor Radchenko
2024-02-03 14:10   ` Ihor Radchenko

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).