jgm / djot.lua

Lua parser for the djot light markup language
MIT License
58 stars 9 forks source link

Use `"\\%0"` as replacement string to escape chars in Lua rather than function #16

Open bpj opened 6 months ago

bpj commented 6 months ago

https://github.com/jgm/djot.lua/blob/a0583ef8270d025b3e86ef521b35f7397cf7215b/djot-writer.lua#L17

It is probably more efficient to use "\\%0" as the replacement rather than a function. In a replacement string %0 gets replaced with the whole match, %1 with the first capture group and so on up to %9.

jgm commented 6 months ago

True. Feel free to submit a PR.