From: Daniel Radetsky <dradetsky@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Adding a class to the auto-inserted <br> elements
Date: Sun, 25 Aug 2024 16:23:49 -0700 [thread overview]
Message-ID: <CABLa6CS+K_RL2dRUM72cn92Gtgw-Mbc4vuNGU6cN47gwqK9eTg@mail.gmail.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 855 bytes --]
So I was exporting an Org doc to html the other day, and I was trying to
follow this guide to make the list elements appear as a comma-separated list
https://markheath.net/post/css-comma-separated-list
It didn't work, and I discovered this was because Org adds a <br> element
to the <li> element if the <li> element is created from an Org headline
element. The easiest way to fix this and allow the aforementioned guide to
work is by ensuring that all those <br> elements have `display: none` set
via CSS. To make this easier and/or reduce the risk of accidentally
removing other elements, we can add a class name to those <br>'s the way we
do to other elements.
I have included an example change. This is just the simplest possible
solution. Obviously if someone thinks a more complicated/featureful
solution is required, we can do more stuff.
--dmr
[-- Attachment #1.2: Type: text/html, Size: 1560 bytes --]
[-- Attachment #2: 0001-lisp-ox-html.el-Add-class-to-auto-inserted-br-tag.patch --]
[-- Type: text/x-patch, Size: 1044 bytes --]
From e35e1468c087ea09bbf9a2d6991401d2c5bbac39 Mon Sep 17 00:00:00 2001
From: Daniel Radetsky <dradetsky@gmail.com>
Date: Sun, 25 Aug 2024 16:11:15 -0700
Subject: [PATCH] lisp/ox-html.el: Add class to auto inserted br tag
Adds .org-heading-li-br to the br inserted at the end of li if the li is
exported from a headline. This allows the user to match those specific
elements with css selectors to style/disable them.
---
lisp/ox-html.el | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 95b154dc5..3e2894c98 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -2967,7 +2967,7 @@ symbols `on', `off', or `trans'. INFO is the info plist."
(symbol-name checkbox)) ""))
(checkbox (concat (org-html-checkbox checkbox info)
(and checkbox " ")))
- (br (org-html-close-tag "br" nil info))
+ (br (org-html-close-tag "br" "class=\"org-heading-li-br\"" info))
(extra-newline (if (and (org-string-nw-p contents) headline) "\n" "")))
(concat
(pcase type
--
2.45.2
next reply other threads:[~2024-08-29 8:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-25 23:23 Daniel Radetsky [this message]
2024-09-01 16:31 ` Adding a class to the auto-inserted <br> elements Ihor Radchenko
2024-09-01 22:23 ` Daniel Radetsky
2024-09-02 2:20 ` Suhail Singh
2024-09-09 17:13 ` [POLL] Mark all the tags in HTML export with unique class (was: Adding a class to the auto-inserted <br> elements) Ihor Radchenko
2024-11-09 14:31 ` Ihor Radchenko
2024-11-09 21:25 ` plain list noexport Samuel Wales
2024-11-16 18:19 ` Ihor Radchenko
2024-11-17 1:34 ` Samuel Wales
2024-09-09 17:16 ` Adding a class to the auto-inserted <br> elements Ihor Radchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CABLa6CS+K_RL2dRUM72cn92Gtgw-Mbc4vuNGU6cN47gwqK9eTg@mail.gmail.com \
--to=dradetsky@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).