all messages for Emacs-related lists mirrored at yhetil.org
 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

* Re: Bug: org-html-example-block can produce multiple class attributes [9.4 (9.4-dist @/usr/share/emacs/site-lisp/elpa/org-9.4/)]
  2022-09-20 16:30 Joshua Honeycutt
@ 2022-10-09  3:28 ` Ihor Radchenko
  2024-02-03 14:10   ` Ihor Radchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Ihor Radchenko @ 2022-10-09  3:28 UTC (permalink / raw)
  To: Joshua Honeycutt; +Cc: emacs-orgmode

Joshua Honeycutt <joshua.honeycutt@gmail.com> writes:

> 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):

Thanks for reporting!
Would you mind creating a proper patch under your name?
See https://orgmode.org/worg/org-contribute.html#first-patch

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

Confirmed.


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

* Re: Bug: org-html-example-block can produce multiple class attributes [9.4 (9.4-dist @/usr/share/emacs/site-lisp/elpa/org-9.4/)]
  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
  0 siblings, 0 replies; 3+ messages in thread
From: Ihor Radchenko @ 2024-02-03 14:10 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Joshua Honeycutt, emacs-orgmode

Ihor Radchenko <yantar92@gmail.com> writes:

> Joshua Honeycutt <joshua.honeycutt@gmail.com> writes:
>
>> 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">

Fixed, on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=5cb52f379

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.