I'm trying to template a LaTeX file using Node with node-latex and mustache, where the data for templating is stored in JSON files.
Unfortunately, some of the characters are not playing nicely in the conversion between node json input and LaTeX syntax.
For example, if I have the string foo/bar
in my JSON, then Node seems to want to URL-encode the slash as foo/bar
--- which is obviously not acceptable, because &
is a reserved character in LaTeX.
This happens regardless of if I parse the JSON with const foo = require('./data/foo.json');
or const foo = JSON.parse(fs.readFileSync('./data/foo.json', "utf8"));
I suppose I could beat this kind of behavior down just with a string replacement, but I'm working with a bunch of fields in various objects, and it would be a lot of work to either for me to make sure I sanitize every string, or, presumably, for the computer if I just write some kind of aggressive recursive object de-encoder... there has to be a better way!
via Paul Gowder
No comments:
Post a Comment