Closed tetrapharmakon closed 5 years ago
Ok, so after scouring the code of both Jekyll, Liquid and Kramdown I found the culprit: me. https://github.com/paolobrasolin/jekyll-antex/blob/974d68b2afdb36383fa0e60f9a99dfaaf8577721/lib/jekyll/antex/dealiaser.rb#L51
Concretely, what happens is
'x'.sub('x', "\\\\")
# => "\\"
WAT
Why? Because https://stackoverflow.com/a/4149087
The problem is that when using sub (and gsub), without a block, ruby interprets special character sequences in the replacement parameter. Unfortunately, sub uses the backslash as the escape character for these:
\& (the entire regex) \+ (the last group) \` (pre-match string) \' (post-match string) \0 (same as \&) \1 (first captured group) \2 (second captured group) \\ (a backslash)
In fact,
'x'.sub('x') { "\\\\" }
# => "\\\\"
Will fix soon.
does not work. You need to write