slack-markdown
v0.3.0
Published
A markdown parser for Slack messages
Downloads
57,405
Readme
slack-markdown
Slack-markdown aims to be a markdown parser for slack messages.
Installation
npm install --save slack-markdown
Usage
const { toHTML } = require("slack-markdown");
console.log(toHTML("This *is* a _test_"));
// outputs: This <strong>is</strong> a <em>test</em>
Options
const { toHTML } = require("slack-markdown");
toHTML("This *is* a _test_", options);
options
is an object with the following properties (all are optional):
escapeHTML
:boolean
(default:true
), if HTML should be escaped or notslackOnly
:boolean
(default:false
), if only slack-specific markdown should be parsedslackCallbacks
: Object of the custom slack callbacksuser
: (id
: ID,name
: Name) User mentions "<@ID|name>"channel
: (id
: ID,name
: Name) Channel mentions "<#ID|name>"usergroup
: (id
: ID,name
: Name) User group mentions ""atHere
: (name
: Name) At here mentions ""atChannel
: (name
: Name) At channel mentions ""atEveryone
: (name
: Name) At everyone mentions ""date
: (timestamp
: Timestamp,format
: Format,link
: Optional link,fallback
: fallback string) Date mentions ""
cssModuleNames
:object
, name mapping of CSS classes to custom onesnoExtraSpanTags
:boolean
(default:false
) Disable the addition of extra span tags on slack-specific parsingnoExtraEmojiSpanTags
:boolean
(default:false
) Disable the addition of extra span tags around emojishrefTarget
:string
(default: empty) The target for hyperlinks, e.g. "_blank" for a new tab