开源软件名称(OpenSource Name):dimerapp/markdown开源软件地址(OpenSource Url):https://github.com/dimerapp/markdown开源编程语言(OpenSource Language):TypeScript 95.6%开源软件介绍(OpenSource Introduction):Table of contentsMarkdown processor
Dimer markdown is an opinionated markdown processor built on top of remark with following features and goals.
SetupInstall the package from npm registry as follows: npm i @dimerapp/markdown
# yarn
yarn add @dimerapp/markdown And import the package to process the markdown files. import { MarkdownFile } from '@dimerapp/markdown'
const markdownContents = `
# Hello world
This is a markdown doc with some GFM syntax
- [ ] Todo 1
- [ ] Todo 2`
const md = new MarkdownFile(markdownContents)
const ast = await md.process() Generating HTMLThe package encourages using AST vs directly generating the HTML from the markdown. Using AST let you bring your own frontend layer. It is like creating a JSON API and then using Vue or React to create webpages. However, if also ship with a helper function to convert the markdown file instance to HTML. import { MarkdownFile, toHTML } from '@dimerapp/markdown'
const md = new MarkdownFile(contents)
await md.process()
const { contents, summary, toc, excerpt } = toHTML(md)
OptionsYou can pass the following options when creating a new instance of the import { MarkdownFile } from '@dimerapp/markdown'
const md = new MarkdownFile(contents, {
generateToc?: boolean
allowHtml?: boolean
filePath?: string
enableDirectives?: boolean
collectAssets?: boolean
})
Use casesLets go over all the use cases that this package can serve User land featuresTBD Use Vue as the rendering layerTBD Validate cross referenced linksTBD Collect todos in a documentTBD MacrosExistingAdding your ownPluginsShikiTBD |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论