From 1f7c31899a3928799855c95e4c5b56dea0004827 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Mon, 17 May 2021 17:03:12 -0700 Subject: [PATCH] Fix dash spacer for nested quotes and other indented blocks. --- voussoir.net/writing/vmarkdown.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/voussoir.net/writing/vmarkdown.py b/voussoir.net/writing/vmarkdown.py index 8238d37..230fd52 100644 --- a/voussoir.net/writing/vmarkdown.py +++ b/voussoir.net/writing/vmarkdown.py @@ -130,10 +130,13 @@ class VoussoirInlineGrammar(mistune.InlineGrammar): footnote_text = re.compile(r'\[footnote_text\]') subreddit = re.compile(r'\/r\/[A-Za-z0-9_]+') redditor = re.compile(r'\/u\/[A-Za-z0-9_]+') + dash_spacer = re.compile(r'^\s*-$', re.MULTILINE) # This `text` override is based on this article: # https://ana-balica.github.io/2015/12/21/mistune-custom-lexers-we-are-going-deeper/ # in which we have to keep adding characters to the recognized list every - # time we make a new rule. My additions so far are \- and \^. + # time we make a new rule. My additions so far are: + # \- for -- + # \^ for superscript text = re.compile(r'^[\s\S]+?(?=[\\{m.group(0)}' + def output_dash_spacer(self, m): + return '' + class VoussoirBlockGrammar(mistune.BlockGrammar): - dash_spacer = re.compile(r'^-$', re.MULTILINE) + # The single hyphen is used to create a split between elements that + # would normally merge together, such as block quotes. + dash_spacer = re.compile(r'^\s*-$', re.MULTILINE) class VoussoirBlock(mistune.BlockLexer): default_rules = copy.copy(mistune.BlockLexer.default_rules)