On 23/02/2024 19:46, Ihor Radchenko wrote:
Max Nikulin <maniku...@gmail.com> writes:

On 19/02/2024 02:36, Martin Edström wrote:
+Since this is a shell-command, remember to use single-quotes
+around \\='%i\\=', not double-quotes!  Else a math fragment such
+as \"$y = 200$\" gets butchered into only \" = 200\"."

I am afraid, the code, not the docstring must be fixed. I have not tried
it, but I expect an issue with

      Test \(f' = df/dx\)

So `shell-quote-argument' is necessary and quotes around %i must be
stripped similar to %s in mailcap entries in `org-open-file'.

That would be backwards-incompatible.
What about introducing %e replacement that will be shell-escaped?

Ihor, it is just a bug and its manifestation depends on content of .org files more than on user configuration. Do you really want to allow part of equations be executed as shell commands for the sake of miracle backward compatibility?

To minimize user annoyance my suggestion is to strip quotes in words like
- '%i'
- "%i"
- 'something%i'
- "something%i"
- something='%i'
- something="%i"
before calling `format-spec' with `shell-quote-argument' result.

Please, revert the commit that added a misleading recommendation.

By the way, single quotes have no special meaning in cmd.exe on windows.

Example of silent error resulting in incorrect equation:

(let ((org-latex-to-html-convert-command
       "printf '%%s' '%i'"))
  (org-format-latex-as-html "$f'' = df/dx$"))
"$f = df/dx$"

Random parts of math becomes part of shell command:

(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'.

Reply via email to