Max Nikulin writes: >>> 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. > > It is unsafe to use such command. Variable expansion, etc. is performed > inside here document blocks. Try > > cat << EOF > \[f(i), \text{where $i \ne 10$}\] > EOF I did non know this. Thanks for the info. > That is why I proposed to use stdin in the case of missed %i. > > `org-latex-to-html-convert-command' should be set to something like > "latexmlc --profile=math --preload=siunitx.sty - 2>/dev/null" > this case. I decided not to introduce stdin. User can always use echo %i | ... instead. >> 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. > > What you calls backward compatibility is actually a means to get strange > results in the case of complex math. It is better to force users to > update configuration (I hope, it actually will not be necessary) and to > ensure safe command without pitfalls related to missed parts of equations. Agree. This breaking change cannot be avoided, unfortunately. Even stripping quotes is unreliable when we use the example from docstring: 'literal:%i'. So, we have to bite the bullet. >> test2.html is rendered *incorrectly* as in the attached screenshot. > > Looks like missed inside > ... Exporting Org document using (setq org-html-with-latex 'html) (setq org-latex-to-html-convert-command "latexmlc 'literal:%i' --profile=math --preload=siunitx.sty 2>/dev/null") renders just fine, so these caveats appear to be terminal-specific. Not our problem. Attaching tentative patch that fixes the problem.