Fix escaping of carets by overriding escape pattern.

This commit is contained in:
voussoir 2021-06-10 19:08:01 -07:00
parent 63324ca824
commit 63309cbc82
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB

View file

@ -138,6 +138,10 @@ class VoussoirInlineGrammar(mistune.InlineGrammar):
# \- for -- # \- for --
# \^ for superscript # \^ for superscript
text = re.compile(r'^[\s\S]+?(?=[\\<!\[_*`~\-\^\/]|https?:\/\/| {2,}\n|$)') text = re.compile(r'^[\s\S]+?(?=[\\<!\[_*`~\-\^\/]|https?:\/\/| {2,}\n|$)')
# This `escape` override is first taken from the mistune source.
# My additions so far are:
# ^ for escaping supers
escape = re.compile(r'^\\([\\`*\^{}\[\]()#+\-.!_>~|])')
class VoussoirInline(mistune.InlineLexer): class VoussoirInline(mistune.InlineLexer):
default_rules = copy.copy(mistune.InlineLexer.default_rules) default_rules = copy.copy(mistune.InlineLexer.default_rules)