An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

# 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)=xf(x)=x

*/
```

```html

```