0.0.3 • Published 3 years ago

@backhq/mrkdwn-parse v0.0.3

Weekly downloads
40
License
MIT
Repository
-
Last release
3 years ago

slack-parse

Based on @tagplay/slack-parse, which was originally based on remark-parse, modified to parse Slack's not-Markdown.

It assumes some simple transformations have been made beforehand, for sanity:

  • converting Slack's special links into regular Markdown links according to Slack's instructions
  • since this means we'll be parsing regular Markdown link syntax, any square brackets in the actual message should be rendered as [ and ] beforehand
  • as Slack returns angle brackets not involved in its link syntax as HTML entities, including those that are meant to be parsed as Markdown syntax, those should be decoded before parsing
  • if an exclamation mark directly precedes a Slack link, it must be escaped, since otherwise the resulting Markdown syntax will look like an image
  • however, since you can't escape characters in Slack (all backslashes are literal), all actual backslashes in the Slack text must be escaped

This is overly complex and hacky and on the whole this kind of sucks, but it works.

Modifications

  • Render emoji shortcodes in text as emojis
  • Parse mentions as links w/ href #mention
  • Detect URLs
  • Don't render links/images
  • Returns as root element, rather than paragraph