@plumbiu/md
this respository is used for @plumbiu/blog as I don't want to install too many dependencies
Feature
- lazy loading for
<img />
- Toc API
Usage
parseMd
md2html
+ md2toc
import { parseMd } from '@plumbiu/md'
await parseMd('# hello\r\nworld', {
lazy: true,
})
md2html
import { md2html } from '@plumbiu/md'
await md2html('# hello\r\nworld', {
lazy: true,
})
html2toc
import { md2html } from '@plumbiu/md'
await md2toc('<h1 id="hello-world">hello world</h1>', {
isPython: false,
})
As this repo is used for transfrom markdown, html(at least h
label) should not be nested.
HTML like this will get error output:
<div>
<div>
<h1>hello</h1>
</div>
<div>
<h2>world</h2>
</div>
</div>
md2toc
import { md2toc } from '@plumbiu/md'
await md2toc(
`
# hello
world
# foo bar
baz
`,
{
depth: 3,
},
)
styles
@plumbiu/md
offer the highliht.js
and github-markdown.css
style
import '@plumbiu/styles/github-markdown.css'
import '@plumbiu/styles/hljs-markdown.css'
dark-theme
needs add <html theme="dark"></html>