Hello!

Summary:

The variables opening-re and closing-re in
org-element--parse-generic-emphasis are hard-coded, and this is not what
is expected by the user who has modified the value of
org-emphasis-regexp-components.

Background and details:

One convenient trick to apply emphasis to parts of a word is to separate
that part with zero-width non-breaking spaces. This allows us to draw
attention to puns like "the ex_cite_ment one feels when one's work is
getting cited" by underlining the "cite" part of the word
"excitement".[1]

Org doesn't support this out of the box but by adding the zero-width
non-breaking space to org-emphasis-regexp-components we can get this to
work.

However! Once we export that Org document, the partial emphasis no
longer carries through. This is because ox uses org-element, which
defines its own emphasis regex in org-element--parse-generic-emphasis.
(The variables are opening-re and closing-re.)

Maybe it's reasonable for org-element to do its own thing and not rely
on Org mode buffer content, but this particular thing should be easier
to tailor. The way the code is written now, we can't even advise around
the function to customise which characters are allowed around emphasised
text – the only workaround I can think of is to literally copy-and-paste
the entire function and add the characters desired to the corresponding
regexen.

I noticed this breakage at some point in the last few years, but only
now was I bothered enough to investigate. It seems like this was a
semi-deliberate choice made in late 2021, commit 2bbac43 with title
"Remove dependency on ’org-emph-re’".

[1]: Sorry about the awful example. My actual usecase is a little
contrived and would distract from understanding the bug itself.

Emacs  : GNU Emacs 29.4 (build 1, x86_64-redhat-linux-gnu, X toolkit, cairo 
version 1.18.0, Xaw3d scroll bars)
 of 2024-07-16
Package: Org mode version 9.8-pre (release_9.7.10-127-g07dd3b @ 
/home/kqr/.emacs.d/straight/build/org/)

Reply via email to