Blockquote
if we restrict multi-line tokens to block-tokens only
So, to achieve this, the re.compile should not be done with the re.DOTALL
flag, instead it would be something like this:
tag_re = re.compile(r"(\{%\s*[\s\S]*?\s*%\}|{{.*?}}|{#.*?#})")
which matches single line comment tokens and variable tokens, and multiline block-tokens.