UNPKG

@onereach/channel-transformer

Version:

Convert data model between different channels (Slack, Microsoft Teams, Generic...)

23 lines (20 loc) 500 B
import showdown from 'showdown'; const converter = new showdown.Converter({ emoji: true, tables: true, noHeaderId: true, strikethrough: true, simplifiedAutoLink: true, parseImgDimensions: true, literalMidWordUnderscores: true }); export const toHtml = (text: string, trimPTag?: boolean): string => { const html:string = converter.makeHtml(text); if (trimPTag) { return html .split(/<\/?p>\n?/g) .filter(item => !!item) .join('<br>'); } return html; };