@backhq/mrkdwn-parse
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i @backhq/mrkdwn-parse

Weekly Downloads

5

Version

0.0.3

License

MIT

Unpacked Size

43.4 kB

Total Files

35

Last publish

Collaborators

  • rstrom