Re: {.quotelead} strings in markdown2html messages
Hi! On Wed, Jun 30, 2021 at 08:26:56AM +1000, Cameron Simpson wrote: > > [] > Try hacking the script to change this: > > ret.append(f'{{.quotelead}}{cur.strip()}') > ret.append(f'{{.quotelead}}{cur.strip()}') > > That might make for ugly HTML rendering, but would at least the litter > will be gone. your response was very insightful, thanks! It turns out that the solution doesn't quite work, as the '{.quotelead}' gets converted to HTML as '{.quotelead}', which doesn't match. So I removed the '' part in the replace statement (line 194), which now reads ret = html.replace('{.quotelead}', '') For completion, here is the patch that resulves the issue. If nobody complains, I'll open an issue in the gilab to fix the bug. thanks! diff --git a/contrib/markdown2html b/contrib/markdown2html index 8b7a3f09..fc2b72d1 100644 --- a/contrib/markdown2html +++ b/contrib/markdown2html @@ -191,7 +191,7 @@ 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('{.quotelead}', '') +ret = html.replace('{.quotelead}', '') ret = re.sub(r'\n((?:\n)*)(?:\{\.quote(\w+)\})', r'\n\g<1>', ret, flags=re.MULTILINE) return ret
Re: {.quotelead} strings in markdown2html messages
On 29Jun2021 20:36, Aitor Soroa 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('{.quotelead}', '') ret = re.sub(r'\n((?:\n)*)(?:\{\.quote(\w+)\})', r'\n\g<1>', ret, flags=re.MULTILINE) return ret The issue is that it is looking for this: {.quotelead} to replace it with this: 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'{{.quotelead}}{cur.strip()}') That might make for ugly HTML rendering, but would at least the litter will be gone. Cheers, Cameron Simpson
{.quotelead} strings in markdown2html messages
Hi, I'm using mutt 2.1 on an ubuntu 20.04 distribution. 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! So, say I have this message - From: Bob To: Alice Cc: Bcc: Subject: Re: messages Reply-To: On Mon, Jun 14, 2021 at 02:10:49PM +0200, Bob wrote: > This seems to work ok so far. > > On Mon, Jun 14, 2021 at 02:08:47PM +0200, Alice wrote: > > This is the first reply. > > > > On Mon, Jun 14, 2021 at 02:08:07PM +0200, Bob wrote: > > > This is the first message. > > > > > > best, > > > > -- > > keep cool > > bob > > -- > keep cool > alice -- keep cool bob - which I feed to markdown2html via $ cat msg.txt | python3 ~/src/mutt/contrib/markdown2html And I obtain the following html output. Note the "{.quotelead}" strings in the output. - text/html HTML E-Mail From: Bob mailto:b...@mail.com";>b...@mail.com To: Alice mailto:al...@mail.com";>al...@mail.com Cc: Bcc: Subject: Re: messages Reply-To: On Mon, Jun 14, 2021 at 02:10:49PM +0200, Aitor Soroa wrote: This seems to work ok so far. > On Mon, Jun 14, 2021 at 02:08:47PM +0200, Alice wrote: This is the first reply. > {.quotelead}> > On Mon, Jun 14, 2021 at 02:08:07PM +0200, Bob wrote: Thsi is the first message. > > > > best, > > -- > keep cool > bob -- keep cool alice -- keep kool bob -