plain text extractor for markdown-it
npm install markdown-it-plain-text
https://cdn.jsdelivr.net/gh/wavesheep/markdown-it-plain-text@0.3.0/dist/markdown-it-plain-text.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.plainText
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);
If you load the script in ts, you will get the ts(2339) error. You can fix it with
(md as any).plainText
or
// @ts-ignore
md.plainText
- extract
text
,fence
,html_block
,code_block
,code_inline
,html_inline
,emoji
content directly - add
space
at closing tag to prevent words from sticking together - remove redundant white spaces from result