I am trying to export org-mode file to HTML. Because I am exportig the same file also to LaTeX format, I am having in the org-mode file a few LaTeX commands, for example \LaTeX command.
For HTML export I would like to replace this command with its transcript in normal letters, simply "LaTeX." I am also using Doom Emacs and running org-mode export in --batch
mode (or with -nv
flag), to run emacs export commands non-interactively (and via makefile
).
Using this filter function written in exportConfig.el
file:
(with-eval-after-load 'ox
(with-eval-after-load 'ox-html
(with-eval-after-load 'htmlize
(defun my-latex-filter-example (text backend info)
"Replace \LaTeX with \"LaTeX\" in HTML output."
(when (org-export-derived-backend-p backend 'html)
(replace-regexp-in-string "\\\\LaTeX" "LaTeX" text)))
(add-to-list 'org-export-filter-latex-fragment-functions
'my-latex-filter-example))
))
(those with-eval-after-load
functions might be redundant because of -nw
emacs start flag.)
But in the resulting exported HTML I still get \LaTeX sequences converted to regular strings. I also tried to add the filter function to org-export-filter-plain-tex-functions
alist, but that did not work either.
How can I correctly replace simple LaTeX commands like this for org-mode export to HTML?
EDIT:
Command I am using is:
emacs main.org -nw -l exportConfig.el -f org-html-export-to-html --kill
Previously I have misspelled the emacs start flag to -nv
, I have corrected that. I am using approach recommended here: Using htmlize in batch mode
Yes, I want to replace "\LaTeX" command in org-mode source with simple "LaTeX" string for HTML export.
Currently, my-latex-filter-example
function doesnt replace it, so the exported HTML contains string "\LaTeX" in multiple places.
\LaTeX
toLaTeX
in the HTML output - correct?