From a83d50d5a64488deb3796bbd0ca0a03b0516cc77 Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Mon, 13 Sep 2021 11:56:00 +1200 Subject: [PATCH 1/1] Fix matching of blockquotes Thanks to Tomas Janousek for the patch. --- .mutt/markdown2html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.mutt/markdown2html b/.mutt/markdown2html index dccecf2..487d3db 100755 --- a/.mutt/markdown2html +++ b/.mutt/markdown2html @@ -178,7 +178,7 @@ def _identify_quotes_for_later(mdwn): # The lead-in to a quote is a single line immediately preceding the # quote, and ending with ':'. Note that there could be multiple of # these: - if re.match(r'^.+:\s*$', cur) and nxt.startswith('>'): + if re.match(r'^[^>]+.*:\s*$', cur) and nxt.startswith('>'): ret.append(f'{{.quotelead}}{cur.strip()}') # pandoc needs an empty line before the blockquote, so # we enter one for the purpose of HTML rendition: @@ -187,13 +187,13 @@ def _identify_quotes_for_later(mdwn): # The first blockquote after such a lead-in gets marked as the # "initial" quote: - elif prev and re.match(r'^.+:\s*$', prev) and cur.startswith('>'): + elif prev and re.match(r'^[^>]+.*:\s*$', prev) and cur.startswith('>'): ret.append(re.sub(r'^(\s*>\s*)+(.+)', r'\g<1>{.quoteinitial}\g<2>', cur, flags=re.MULTILINE)) # All other occurrences of blockquotes get the "subsequent" marker: - elif cur.startswith('>') and prev and not prev.startswith('>'): + elif cur.startswith('>') and prev is not None and not prev.startswith('>'): ret.append(re.sub(r'^((?:\s*>\s*)+)(.+)', r'\g<1>{.quotesubsequent}\g<2>', cur, flags=re.MULTILINE)) -- 2.39.5