Relocate Org zero-width space stripping code

This commit is contained in:
TEC 2024-03-08 17:12:39 +08:00
parent 99155e6c85
commit 9830d78e28
Signed by: tec
SSH Key Fingerprint: SHA256:eobz41Mnm0/iYWBvWThftS0ElEs1ftBr6jamutnXc/A
1 changed files with 16 additions and 11 deletions

View File

@ -8243,22 +8243,13 @@ or put a currency symbol immediately before an inline source block.
There is a solution to this, it just sounds slightly hacky --- zero width spaces.
Because this is Emacs, we can make this feel much less hacky by making a minor
addition to the Org key map 🙂.
#+begin_src emacs-lisp
(map! :map org-mode-map
:nie "M-SPC M-SPC" (cmd! (insert "\u200B")))
#+end_src
We then want to stop the space from being included in exports, which can be done
with a little filter.
#+begin_src emacs-lisp
(defun +org-export-remove-zero-width-space (text _backend _info)
"Remove zero width spaces from TEXT."
(unless (org-export-derived-backend-p 'org)
(replace-regexp-in-string "\u200B" "" text)))
(after! ox
(add-to-list 'org-export-filter-final-output-functions #'+org-export-remove-zero-width-space t))
#+end_src
We then want to stop the space from being included in exports, which is done [[*Strip zero width spaces][here]].
***** List bullet sequence
@ -10122,6 +10113,20 @@ TODO abstract backend implementations."
(setq org-latex-format-headline-function #'org-latex-format-headline-acronymised)
#+end_src
**** Strip zero width spaces
Zero width spaces are handy as a semantic separator, but not something we want
passed through to the exports.
#+begin_src emacs-lisp
(defun +org-export-remove-zero-width-space (text _backend _info)
"Remove zero width spaces from TEXT."
(unless (org-export-derived-backend-p 'org)
(replace-regexp-in-string "\u200B" "" text)))
(add-to-list 'org-export-filter-final-output-functions #'+org-export-remove-zero-width-space t)
#+end_src
**** Exporting Org code
With all our Org config and hooks, exporting an Org code block when using