0

This is a follow-up question from this: Replace \LaTeX command in HTML export

Consider following org-mode file:

* Text about exporting from org-mode to \LaTeX

text

* Text about exporting from org-mode to HTML

another text

If I export this file to HTML and also use filter to replace "\LaTeX" in heading with simple "LaTeX", I end up with table of contents entries that still contain "\LaTeX" as a string, instead of the replacement "LaTeX."

I should also add that I am using Doom Emacs and I am running Emacs in non-interactive session through makefile (I am doing multiple exports to multiple export formats).

Looking to org-manual about TOC, I could use property ALT_TITLE (org TOC), but because I am exporting also to LaTeX, that would mean I would lost formatting in there.

I reused filter fom linked question:

(require 'ox)
(require 'ox-html)

(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-link-functions
             'my-latex-filter-example)

According to optons listed in manual: Advanced Export I have also tryied plain-text and options org-export-filter-functions, but none were able to remove string "\LaTeX" from HTML table of contents.

Is there a way to target with filter functions links generated by TOC in HTML?

1

You can use a macro that expands differently in the two cases:

#+MACRO: latex @@latex:\LaTeX@@ @@html:LaTeX@@

* Something about {{{latex}}}
  {{{latex}}} is cool.

Check out the section in the manual on macros with C-h i g (org)macro and the various sections on quoting constructs, e.g. C-h i g (org)quoting latex for latex and similar ones for the other exporters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.