https://github.com/acyortjs/markdown
markdown parser with code highlighting and math latex support
https://github.com/acyortjs/markdown
Last synced: about 1 year ago
JSON representation
markdown parser with code highlighting and math latex support
- Host: GitHub
- URL: https://github.com/acyortjs/markdown
- Owner: acyortjs
- License: mit
- Created: 2017-11-18T08:48:02.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-05-22T12:59:14.000Z (about 7 years ago)
- Last Synced: 2025-06-22T11:07:56.018Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 91.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Markdown
[](https://travis-ci.org/acyortjs/markdown)
[](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)=xf(x)=x
*/
```
```html
```