@acyort/markdown 中文文档教程

发布于 5 年前 浏览 10 项目主页 更新于 2 年前

# Markdown [![Build Status](https://travis-ci.org/acyortjs/markdown.svg?branch=master)](https://travis-ci.org/acyortjs/markdown) [![codecov](https://codecov.io/gh/acyortjs/markdown/branch/master/graph/badge.svg)](https://codecov.io/gh/acyortjs/markdown) markdown parser with code highlighting and math latex support [DEMO](https://acyortjs.github.io/markdown/) ## Install ```bash $ npm i @acyort/markdown -S ``` ## Usage ### basic ```js const Marked = require('@acyort/markdown') const config = { lineNumbers: true, // if show code line numbers getHeadingId: fn // for set heading id } const marker = new Marked(config) // parse option, this will override initial option const option = { lineNumbers: true, getHeadingId: fn } // parse markdown string marker.render('# H1') // width option marker.render('# H1', option) marker.render('# An h1 header') //

// // An h1 header //

const slugify = require('@sindresorhus/slugify') const option = { getHeadingId: slugify } marker.render('# I ♥ Dogs', options) //

// // An h1 header //

const code = '\`\`\`html\n

h1

\n\`\`\`' marker.render(code) //
////////////////
//   1
// 
// 
//   <h1>h1</h1>
// 
//
``` ```html``` ### Marked lexer API [lexer](https://marked.js.org/#/USING_PRO.md#lexer) ```js const { lexer } = require('@acyort/markdown') ``` ### math latex ```js const text = '实例:$$f(x)=x$$' marker.render(text) /*

实例:

f(x)=xf(x)=x
*/ ``` ```html```
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文