在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):npm/marky-markdown开源软件地址(OpenSource Url):https://github.com/npm/marky-markdown开源编程语言(OpenSource Language):JavaScript 100.0%开源软件介绍(OpenSource Introduction):marky-markdown
Node Version Supportmarky-markdown strives to support all LTS, current, and maintenance versions of Node.js. When a version of Node.js is EOL, we will EOL support for that version for marky-markdown. For more information on Node.js LTS and support, click here.
Installationnpm install marky-markdown --save Programmatic Usagemarky-markdown exports a single function. For basic use, that function takes a single argument: a string to convert. var marky = require("marky-markdown")
var html = marky("# hello, I'm markdown") OptionsThe exported function takes an optional options object as its second argument: marky("some trusted string", {sanitize: false}) The default options are as follows: {
sanitize: true, // remove script tags and stuff
nofollow: true, // add rel=nofollow to all links
linkify: true, // turn orphan URLs into hyperlinks
highlightSyntax: true, // run highlights on fenced code blocks
prefixHeadingIds: true, // prevent DOM id collisions
enableHeadingLinkIcons: true, // render icons inside generated section links
serveImagesWithCDN: false, // use npm's CDN to proxy images over HTTPS
debug: false, // console.log() all the things
package: null, // npm package metadata,
headingAnchorClass: 'anchor', // the classname used for anchors in headings.
headingSvgClass: ['octicon'] // the class used for svg icon in headings.
} Low Level Parser AccessIf you need lower level access to the markdown-it parser (to add your own
markdown-it plugins, for
example), you can call the var parser = marky.getParser()
parser.use(someMarkdownItPlugin)
var html = parser.render("# markdown string")
When you're done customizing the parser, call Command-line UsageYou can use marky-markdown to parse markdown files in the shell. The easiest way to do this is to install globally:
In the BrowserThis module mostly works in the browser, with the exception of the You can Here is an example using HTML5 to render text inside <script src="marky-markdown.js"></script>
<marky-markdown>**Here** _is_ some [Markdown](https://github.com/)</marky-markdown>
<script>
for (el of document.getElementsByTagName('marky-markdown')) {
el.innerHTML = markyMarkdown(el.innerHTML, {highlightSyntax: false})
}
</script> Note: Usage with webpack requires that your
plugins: [
new webpack.DefinePlugin({
'process.browser': true
})
], Testsnpm install
npm test What it does
npm packagesPass in an npm var package = {
name: "foo",
description: "foo is a thing",
repository: {
type: "git",
url: "https://github.com/kung/foo"
}
}
marky(
"# hello, I am the foo readme",
{package: package}
) Dependencies
Extra syntax highlighting, in addition to what comes with highlights:
LicenseISC |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论