Guide
slack-message-parser is a JavaScript library which parses the message returned by Slack API and give you a tree object (imagine AST). You could use the result tree to create a message viewer (HTML, React component, etc...) or whatever you want 😃
Installation
The package is available as slack-message-parser
on npm.
yarn add slack-message-parser
# npm i --save slack-message-parser
Quick Start
Just parse the message!
import slackMessageParser from 'slack-message-parser'
const tree = slackMessageParser('Slack *message* ~to~ _parse_')
console.dir(tree)
Supported Message Features
- Plain text
- Links
- Channels (
#channel
) - User (
@someone
) - URL (
https://foo.bar
,mailto:foo@bar
) - Commands (Represented as
<!foo>
, more detail here)
- Channels (
- Emojis 😍
- Code block
- Inline code (
`foo`
) - Italic (
_foo_
) - Bold (
*foo*
) - Strikethrough (
~foo~
) - Quotes (
> foo
)
Examples
Plain HTML with TypeScript
React with TypeScript
API →