Skip to content
Snippets Groups Projects

Add support for rich text rendering

Merged 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
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Abhilash Raj resolved all threads

    resolved all threads

  • Abhilash Raj added 1 commit

    added 1 commit

    • 2a8156a4 - Apply 1 suggestion(s) to 1 file(s)

    Compare with previous version

  • Abhilash Raj
  • Abhilash Raj
  • Abhilash Raj
  • Abhilash Raj
  • Abhilash Raj resolved all threads

    resolved all threads

  • Abhilash Raj resolved all threads

    resolved all threads

  • Abhilash Raj added 1 commit

    added 1 commit

    • 408cad11 - Apply 4 suggestion(s) to 2 file(s)

    Compare with previous version

  • Abhilash Raj added 2 commits

    added 2 commits

    Compare with previous version

  • Abhilash Raj added 1 commit

    added 1 commit

    • a48cc8fb - Add a fix for a bug where URLs with @ are converted to mailto links.

    Compare with previous version

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading