amo-html-to-mrkdwn

3.4.1 • Public • Published

html-to-mrkdwn Actions Status

Convert HTML to Slack's mrkdwn format.

screenshots

Usage

const mrkdwn = require('amo-html-to-mrkdwn')
 
const html = `
<p><strong>Hello</strong> <a href="https://example.com">cruel</a> <em>world</em>!</p>
 
<p><img src="https://media.giphy.com/media/5xtDarEbygs3Pu7p3jO/giphy.gif"></p>
`
 
mrkdwn(html)
{
  "text": "*Hello* <https://example.com|cruel> _world_!\n\n<https://media.giphy.com/media/5xtDarEbygs3Pu7p3jO/giphy.gif>",
  "image": "https://media.giphy.com/media/5xtDarEbygs3Pu7p3jO/giphy.gif",
}

Parameters

The module exports a function that takes the following parameters:

Parameter Type Description
html string Required HTML string
flavor string Optional application-specific HTML flavor
options object Optional flavor options

Flavors

Application-specific HTML flavors are supported by including an optional second argument. Supported flavors include:

github

per GitHub Flavored Markdown

jira

per rendered Jira comments

Options

Option Type Example Description
jiraBaseUrl string https://subdomain.atlassian.com Jira base URL used to generate absolute attachment links

Package Sidebar

Install

npm i amo-html-to-mrkdwn

Weekly Downloads

136

Version

3.4.1

License

ISC

Unpacked Size

10.9 kB

Total Files

11

Last publish

Collaborators

  • namoscato