Skip to content
Myr

Fix literal \ characters at the end of a string

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Given a statement like `{% set sep = '\\' %}`, the syntax highlighter was considering the literal `'\\'` to be a literal quote inside the string by matching `\'` and thus highlighting the rest of the entire document as a string. This change fixes that issue by adding some regex to ensure that an escaped quote is preceded by an uneven number of slashes (that is, `'\\\\\''` would accept the literal string `\\'` without issues). A`"` quoted string is modified the same way.

authored by highlyunavailable · committed by highlyunavailable · parent 1b7a7f4 · Browse files · 1 file+2 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+2 added−2 removed

  • other:+2 added−2 removed

1 file+2 added−2 removed

modified:ext/Vim/jinja.vim+2 added-2 removed
57 unmodified lines
58syn match jinjaFunction contained /[a-zA-Z_][a-zA-Z0-9_]*/59syn match jinjaBlockName contained /[a-zA-Z_][a-zA-Z0-9_]*/6061" Jinja template constants62syn region jinjaString containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained start=/"/ skip=/\\"/ end=/"/63syn region jinjaString containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained start=/'/ skip=/\\'/ end=/'/62syn region jinjaString containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained start=/"/ skip=/\(\\\)\@<!\(\(\\\\\)\@>\)*\\"/ end=/"/63syn region jinjaString containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained start=/'/ skip=/\(\\\)\@<!\(\(\\\\\)\@>\)*\\'/ end=/'/64syn match jinjaNumber containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained /[0-9]\+\(\.[0-9]\+\)\?/6566" Operators67syn match jinjaOperator containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained /[+\-*\/<>=!,:]/
68 unmodified lines