Skip to content

Add support for rich text rendering

Abhilash Raj requested to merge maxking/hyperkitty:rich-text-render into master

This is a rewrite of !160 (closed) that uses mistune v2.0.0rc1 for better future compatability. There are a bunch of other changes, more specifically, any additional parsing is done using mistune plugins instead of custom parsers.

Currently included plugins are:

  • Signature plugin - This recognizes email signatures at the bottom (regex of ^-- \n[\s\S]+) and makes the text muted.
  • URL plugin - This truncates the length of the url text to 76 characters
  • PGP Signature plugin - This is just snip_pgp function from old parsing converted to a mistune plugin
  • Disable markdown plugin - This plugin disables all the markdown parsing rules. It is meant to use mistune to do above three tasks without the markdown rendering.

The rendering has been customized a bit as well.

  • Add markers to emphasis and strong. This is because many times we will see **kwargs or __call__ being used without code fences being used in email, which would convert the text into emphasis or strong. We simply add back those markers, also applying the actual rule (strong or emphasis) so that we don't swallow any text.
  • Disable header parsing. We disable the parsing of the # Header, --- header or ==== headers. This is because we often see these markers used in email without the intention of it being an actual header. This prevents us from ever actually using a heading, but that's just fine for now.

Requires follow up changes: &2

Edited by Abhilash Raj

Merge request reports

Loading