{.quotelead} strings in markdown2html messages
Cameron Simpson
cs at cskk.id.au
Tue Jun 29 22:26:56 UTC 2021
On 29Jun2021 20:36, Aitor Soroa <aitors2005 at gmail.com> wrote:
>I am a big fan of the markdown2html script (in contrib), which allows
>me to write messages in markdown format. The script converts the message into html
>and mutt sends them as attachments.
>
>However, lately the script writes strange `{.quotelead}` strings, as can be
>seen in the recipe below. I'd rather get rid of those, but unfortunately
>i don't know how. Any help in this regard would be much appreciated!
Just looking at my local copy of this script (which don't use), it has a
pretty obvious bug.
The string quotelead occurs in 3 places:
In some CSS included with the message:
.quotelead {
font-style: italic;
margin-bottom: -1em;
color: #999;
font-size: 80%;
}
In the generate_lines_with_context function, which has this little
snippet:
for prev, cur, nxt in generate_lines_with_context(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('>'):
ret.append(f'{{.quotelead}}{cur.strip()}')
# pandoc needs an empty line before the blockquote, so
# we enter one for the purpose of HTML rendition:
ret.append('')
continue
and in some post processing:
def _reformat_quotes(html):
'''
Earlier in the pipeline, we marked email quoting, using markers, which we
now need to turn into HTML classes, so that we can use CSS to style them.
'''
ret = html.replace('<p>{.quotelead}', '<p class="quotelead">')
ret = re.sub(r'<blockquote>\n((?:<blockquote>\n)*)<p>(?:\{\.quote(\w+)\})',
r'<blockquote class="quote \g<2>">\n\g<1><p>', ret, flags=re.MULTILINE)
return ret
The issue is that it is looking for this:
<p>{.quotelead}
to replace it with this:
<p class="quotelead">
to access the CSS, but the generated text just puts:
{.quotelead}stripped-line-of-text
into the message. So no match.
Try hacking the script to change this:
ret.append(f'{{.quotelead}}{cur.strip()}')
ret.append(f'<p>{{.quotelead}}{cur.strip()}')
That might make for ugly HTML rendering, but would at least the litter
will be gone.
Cheers,
Cameron Simpson <cs at cskk.id.au>
More information about the Mutt-users
mailing list