To allow exact code to be generated in different scenarios, we should provide different kinds of escapes for templates to choose. Here is a tentative list of escapes we need:
HTML escape ( now available as {{tag}} )
No escape ( now available as {{{tag}}} )
Backslash escape (there are two variants: JS and commonmark).
JS string escape appears to be used in quotes inside Nunjucks tags (verification still to be done).
The most noted difference of the escapes are about whether to escape "\n".
AsciiDoctor appears to have backslash escape that "aren't very reliable" (words quoted from section 12.5 of Asciidoctor user manual). I guess commonmark escapes do well there.
To allow exact code to be generated in different scenarios, we should provide different kinds of escapes for templates to choose. Here is a tentative list of escapes we need:
HTML escape ( now available as
{{tag}}
)No escape ( now available as
{{{tag}}}
)Backslash escape (there are two variants: JS and commonmark). JS string escape appears to be used in quotes inside Nunjucks tags (verification still to be done). The most noted difference of the escapes are about whether to escape "\n". AsciiDoctor appears to have backslash escape that "aren't very reliable" (words quoted from section 12.5 of Asciidoctor user manual). I guess commonmark escapes do well there.
URI escape (for use in
<a href="...">
)