Max Nikulin writes: > (let ((org-latex-to-html-convert-command > "printf '%%s' '%i'")) > (org-format-latex-as-html "$f' = df/dx$")) > "/bin/bash: -c: line 1: unexpected EOF while looking for matching `'' > " > > Something weird may be executed in the case of sufficiently complex > equations. > It should be more reliable to pass fragment to command stdin. It can be > done if %i is missed in `org-latex-to-html-convert-command'. I agree that it will be more reliable to shell-escape argument. However, I am concerned that escaping may break certain uses like somecommand << EOF %i EOF In the above scenario, escaping will break things. That's why I prefer to add a new replacement, not change the meaning of %i. We might even remove %i from the docstring, keeping support in the code for backwards-compatibility. Also, I just looked closer into the example with latexml we provide in the docstring and played around with it. I noticed that with (defun org-format-latex-as-html (latex-fragment) "Convert LATEX-FRAGMENT to HTML. This uses `org-latex-to-html-convert-command', which see." (let ((cmd (format-spec org-latex-to-html-convert-command `((?i . ,latex-fragment) (?I . ,(shell-quote-argument latex-fragment)))))) (message "Running %s" cmd) (shell-command-to-string cmd))) (with-temp-file "/tmp/test2.html" (let ((org-latex-to-html-convert-command "latexmlc literal:%I --profile=math --preload=siunitx.sty 2>/dev/null")) (insert (org-format-latex-as-html "$f' = df/dx$")))) test2.html is rendered *incorrectly* as in the attached screenshot. In contrast, manually providing output file as latexmlc literal:\$f\'\ =\ df/dx\$ --profile=math --preload=siunitx.sty --output /tmp/test3.html yields correct rendering.