Copyright notice: This article is originally published BY the blogger. It follows the COPYRIGHT agreement CC 4.0 BY-SA. Please attach the link of the original source and this statement. This paper links: gudepeng. Making. IO/note / 2018/0…
Address 1.
mared.js
2. Install
npm install marked --save
3. Set parameters
marked.setOptions({
renderer: new marked.Renderer(),
gfm: true,
tables: true,
breaks: true,
pedantic: false,
sanitize: false,
smartLists: true,
smartypants: false,
highlight(code) {
return Hljs.highlightAuto(code).value
}
})
Copy the code
GFM This is a Boolean value and defaults to true. Allows Git Hub standard Markdown.
Tables It is a Boolean value and defaults to true. Table syntax support is allowed. This option requires GFM to be true.
Breaks it is a Boolean value and defaults to false. Carriage return line feeds are allowed. This option requires GFM to be true.
Pedantic It is a Boolean value and defaults to false. Be as compatible with obscure parts of Markdown.pl as possible. Do not correct any bad behavior or errors in the original model.
Sanitize This is a Boolean value and defaults to false. Filtering (cleaning) the output will ignore any HTML codes (labels) that have been entered smartLists it is a Boolean value and defaults to false. Use a more stylish list than native Markdown. Old lists will be filtered out as possible pedantic processing content.
Smartypants This is a Boolean value and defaults to false. Use funkier punctuation, such as dashes in quotation grammar.
4. Customize the resolution method
const renderer = new marked.Renderer()
const paragraphParse = text => `<p>${text}</p>`
renderer.paragraph = paragraphParse
return marked(content, { renderer })
Copy the code