On Sun, Sep 04, 2022 at 08:37:21PM +1000, Cameron Simpson <c...@cskk.id.au> 
wrote:

> On 04Sep2022 15:34, raf via Mutt-users <mutt-users@mutt.org> wrote:
> > On Sun, Sep 04, 2022 at 01:51:25PM +1000, Cameron Simpson <c...@cskk.id.au> 
> > wrote:
> [...]
> > > So I've revisited the manual and found the
> > > `$send_multipart_alternative`
> > > option and its friend `$send_multipart_alternative_filter`. They work 
> > > well!
> > > 
> > > So now I have a mechanism to send: `format=flowed` MarkDown with a 
> > > aparallel
> > > HTML alternative. The HTML should render in a "paragraphy" way for the 
> > > HTML
> > > people, and the MarkDown keeps me happy.
> > > 
> > > My default setting is now:
> > > 
> > >     set send_multipart_alternative=no
> > >     set send_multipart_alternative_filter='echo text/html; echo; exec 
> > > md2html'
> > > 
> > > which is the inactive form, and I've added:
> > > 
> > >     message-hook . 'set send_multipart_alternative=no'
> > >     message-hook '%f htmlees' 'set send_multipart_alternative=no'
> > 
> > Oops. That should be =yes above.
> 
> Whoops indeed. I just sketched this out this morning. Thanks for the catch.
> fix applied.
> 
> > > The `md2html` script is my personal script, which wraps `pandoc` and
> > > post
> > > munges the HTML to indent the code blocks, which `pandoc`'s HTML does not
> > > please my eye. It's here:
> > > https://github.com/cameron-simpson/css/blob/main/bin-cs/md2html
> > > if anyone wants a starting point.
> > 
> > Thanks, Cameron. It's odd that there isn't an md2html
> > program out there already. I had to create one too
> > (using python's markdown module).
> 
> Ah, that might be easier to customise. I just tried a few markdown
> converters and ended up with pandoc.
> 
> > I like your indenting of code blocks, but it seems to
> > put an additional blank line after each code block.
> > That might not be intentional.
> 
> Not intentional. I just wanted to keep the 4 space indent used to trigger a
> code block for the same visual effect, since I use that instead of the
> triple backticks usually. Pandoc tosses those spaces.

That's correct behaviour for markdown. If you want the
output to be indented four spaces, the markdown source
needs to be indented eight spaces. But for email use,
it's a nice idea to do what you're doing.

If you want to prevent the extra line, the sed command
can be changed to remove theindenyt before the closing
line of the code block:

  sed '
      s/^\(<pre><code>\)\(.*<\/code><\/pre>\)$/\1    \2/
      t post_pre_code
      /^<pre><code>/,/<\/code><\/pre>$/{
          s/^/    /
          s/^    \(<pre><code>\)/\1    /
          s/^    \(<\/code><\/pre>\)/\1/
      }
      :post_pre_code
      '

> Pandoc's conversion is a bit clunky (but better than discount and the other
> tool I tried).
> 
> > And it looks like it
> > doesn't do titles (which default to "-"). I guess that
> > doesn't matter for email use, except that pandoc
> > whinges about it on stderr.
> 
> Aye, annoying. There's no context for a title (eg the subject header), I may
> just have to provide something to shut it up. Or shift sideways to the
> Python module, particularly if that does a better job.
> 
> > Do you have any advice for automating spaces at the end
> > of non-final paragraph lines for format=flowed in vim?
> 
> I use these settings:
> https://github.com/cameron-simpson/css/blob/main/bin/vim-flowed
> which autowraps and leaves trailing spaces automatically.
> 
> > Perhaps I could just post-process messages with perl
> > in my mutt-editor wrapper script.
> 
> Vim can do 99% of it for you on the fly :-)

Thanks again.

> Cheers,
> Cameron Simpson <c...@cskk.id.au>

cheers,
raf

Reply via email to