emacs-orgmode
[Top][All Lists]
Advanced

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

[PATCH] [BUG] Support attr_html in source code and fixed-width blocks


From: Suhail Singh
Subject: [PATCH] [BUG] Support attr_html in source code and fixed-width blocks
Date: Mon, 17 Jun 2024 22:55:28 -0400
User-agent: Gnus/5.13 (Gnus v5.13)

Unlike example blocks, source code and fixed-width blocks don't support
the attr_html keyword.  Contrast these outputs:

#+begin_src emacs-lisp :results value replace :wrap src html
  (require 'org)
  (require 'ox-html)

  (org-export-string-as
   "#+attr_html: :class foo
  ,#+begin_src sh :exports code
    pwd
  ,#+end_src"
   'html t)
#+end_src

#+RESULTS:
#+begin_src html
<div class="org-src-container">
<pre class="src src-sh"><span style="color: #e090d7;">pwd</span>
</pre>
</div>
#+end_src

#+begin_src emacs-lisp :results value replace :wrap src html
  (require 'org)
  (require 'ox-html)

  (org-export-string-as
   "#+attr_html: :class foo
  ,#+RESULTS:
  : blah"
   'html t)
#+end_src

#+RESULTS:
#+begin_src html
<pre class="example">
blah
</pre>
#+end_src


With the output for example blocks:

#+begin_src emacs-lisp :results value replace :wrap src html
  (require 'org)
  (require 'ox-html)

  (org-export-string-as
   "#+attr_html: :class foo
  ,#+begin_example
    hello world!
  ,#+end_example"
   'html t)
#+end_src

#+RESULTS:
#+begin_src html
<pre class="example foo" id="org2d25618">
hello world!
</pre>
#+end_src


The attached patches are a straight-forward copy-paste of relevant code
from org-html-example-block.  It may be better to refactor this logic
and ensure that it is applied on all relevant AST nodes (others are
probably affected as well).

Attachment: 0001-ox-html-Add-support-for-attr_html-for-source-code-bl.patch
Description: Text Data

Attachment: 0002-ox-html-Add-support-for-attr_html-in-fixed-width-blo.patch
Description: Text Data


Suhail (2):
  ox-html: Add support for attr_html for source code blocks
  ox-html: Add support for attr_html in fixed-width blocks

 lisp/ox-html.el | 34 +++++++++++++++++++++++++++-------
 1 file changed, 27 insertions(+), 7 deletions(-)


base-commit: e666660c7d9fa3a74a7f5246d72e6020ab33cfd2
-- 
2.45.2


reply via email to

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