0.4.3 • Published 8 years ago

markdown-it-sanitizer v0.4.3

Weekly downloads
4,231
License
MIT
Repository
github
Last release
8 years ago

markdown-it-sanitizer

Build Status Coverage Status npm version

sanitizer plugin for markdown-it markdown parser.

Accepted tags

All tags are parsed case insensitive.

Balanced

<b>, <blockquote>, <code>, <em>, <h1>, ..., <h6>, <li>, <ol>, <ol start="42">, <p>, <pre>, <sub>, <sup>, <strong>, <strike>, <ul>

Standalone

<br>, <hr>

Links

<a href="http://example.com" title="link">text</a>

The title attribute is optional.

Images

<img src="http://example.com" alt="cat" title="image">

The alt and title attributes are optional.

Install

node.js, bower:

npm install markdown-it-sanitizer --save
bower install markdown-it-sanitizer --save

Use

Basic

var md = require('markdown-it')({ html: true })
            .use(require('markdown-it-sanitizer'));

md.render('<b>test<p></b>'); // => '<p><b>test</b></p>'

Advanced

For not whitelisted tags and tags that don't have a matching opening/closing tag you can define whether you would like to remove or escape them. You can also define a class attribute that will be added to image tags. Here is an example with default values:

var md = require('markdown-it')({ html: true })
            .use(require('markdown-it-sanitizer'), {
              imageClass: '',
              removeUnbalanced: false,
              removeUnknown: false
            });

// unknown tag
md.render('<u>test</u>'); // => '<p>&lt;u&gt;test&lt;/u&gt;</p>'
// unknown tag with removeUnknown: true
md.render('<u>test</u>'); // => '<p>test</p>'

// unbalanced tags
md.render('<b>test</em>'); // => '<p>&lt;b&gt;test&lt;/em&gt;</p>'
// unbalanced tags with removeUnbalanced: true
md.render('<b>test</em>'); // => '<p>test</p>'

// imageClass: 'img-responsive'
md.render('<img src="http://example.com/image.png" alt="image" title="example">'); // => '<p><img src="http://example.com/image.png" alt="image" title="example" class="img-responsive"></p>'

Differences in the browser. If you load the script directly into the page, without package system, the module will add itself globally as window.markdownitSanitizer.

License

MIT

webchat-bot-uireact-chat-widget-send-manipulation-fix@hyiromori/lib-js-markdown@everything-registry/sub-chunk-2132iez-naviikingtec-cesium-navigationlimendo-chat-widget@bhupesh-sf/react-chat-widget@bimbeo160/react-chat-widget@bwyss/cesium-navigation@cmcleese/cesium-navigation@dosmond37/react-chat-widget@ecatech/chat-widget@du201/react-chat-widget@haugety/react-chat-widget-custom-bundlekoios-chat-widgetnadia-chat-widget-reactnext-chat-widgetnextjs-chat-widgetnervywidgetmy-bot-widgetraml2html-werk-themereact-chat-jordanreact-chat-voice-widgetreact-chat-web-adaptadoreact-chat-widgetreact-chat-widget-2react-chat-widget-all-dreamreact-chatvv-widgetreact-chat-widget-customreact-chat-widget-dsreact-chat-widget-for-sevidevreact-chat-widget-framereact-chat-widget-greact-chat-widget-injectablereact-chat-widget-issreact-chat-widget-mreact-chat-widget-micreact-chat-widget-nsreact-chat-widget-onereact-chat-widget-react-18react-chat-themereact-chat-widget-testreact-chat-widget-with-audioreact-chat-widget-with-micreact-chat-widget-with-uploadreact-chat-widget_lvreact-multiple-chat-widgetscrinity-chatsally-website-widgetreactive-chattest-chat-widgetunidatalab-chat-widgetstemuli-chat-windowth-react-chat-widgettrongnc-comviblo-sdkso-react-chat-widgetwebchat-boto-uixatkit-chat-widget@luisbringitps/react-chat-widget@masila/chat-widget@qinzhengquan/react-chat-widget@proteus-ai/react-chat-widget@ryaneewx/react-chat-widget@redapollos/react-chat-widget@mrizki/react-chat-widget@mryhryki/markdown@nerooc/chat-widget@nhuson/react-chat-widget@newscaler/react-chat-widget@nezha2019/react-chat-widget@soon-gis/effect@thaleslabs/react-chat-widgetapigene-widgetadsionli-navigationaigentx-chat-widget@zalastax/nolb-markdown-i@znemz/cesium-navigation@zync/react-chat-widgetadacesium-navigation-es6asif-ui-libchatkitty-react-widgetcesium-navigation-es6-plugincesium-navigation-es6-wdhcesium-navigation-masoncesium-navigation-plugincesium-navigation-testcesium-navigation-zandneycesium64-navigationcesium-navigation-es6-cyqcesium-navigation-es6-jolincesium-navigation-es6-patchdocaryscorilla-componentsct43dbonfs-chat-widgetes6-cesium-navigation
0.4.3

8 years ago

0.4.2

8 years ago

0.4.1

9 years ago

0.4.0

9 years ago

0.3.2

9 years ago

0.3.1

9 years ago

0.3.0

9 years ago

0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago