Ah yes. My custom Node script (which I hope it's OK to paste below) strips the beginnings and ends of the input. I suppose that it could be done already on the Elisp side, which would take care of interpreting the $-signs as envvars too. const katex = require('katex') let input = process.argv[2].trim() let disp = true if (input.slice(0, 2) === '\\[' || input.slice(0, 2) === '$$') { input = input.slice(2, -2) } else if (input.slice(0, 2) === '\\(') { input = input.slice(2, -2) disp = false } else if (input.slice(0, 1) === '$') { input = input.slice(1, -1) disp = false } else { console.error("Did you quote the input correctly?") process.exit(1) } console.log(katex.renderToString( input, { displayMode: disp, output: 'mathml', trust: true, strict: false, throwOnError: false, } )) On Wed, Feb 21, 2024 at 15:38 Max Nikulin wrote: > 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'. > > Notice that dollar-math $x = y$ is not recommended and considered as > obsolete syntax. Use \(x = y\) or \[x = y\] (the latter for display math). >