markdown-it-plain-text
v0.3.0
Published
plain text extractor plugin for markdown-it markdown parser
Downloads
14,994
Maintainers
Readme
markdown-it-plain-text
plain text extractor for markdown-it
Install
nodejs
npm install markdown-it-plain-textbrowser (CDN)
uncompressed
https://cdn.jsdelivr.net/gh/wavesheep/[email protected]/dist/markdown-it-plain-text.js
compressed
https://cdn.jsdelivr.net/gh/wavesheep/[email protected]/dist/markdown-it-plain-text.min.js
Usage examples
Node.js
const MarkdownIt = require('markdown-it');
const plainText = require('markdown-it-plain-text');
const md = new MarkdownIt();
md.use(plainText);
md.render('your markdown content')
// Here are plain text result
md.plainTextBrowser
If you load the script directly into the page without using a package system, the module will add itself globally with the name markdownItPlainTextPlugin. Init code will look a bit different in this case:
const md = window.markdownit().use(window.markdownItPlainTextPlugin);Typescript
If you load the script in ts, you will get the ts(2339) error. You can fix it with
(md as any).plainTextor
// @ts-ignore
md.plainTextGeneration rule
- extract
text,fence,html_block,code_block,code_inline,html_inline,emojicontent directly - add
spaceat closing tag to prevent words from sticking together - remove redundant white spaces from result
