https://github.com/moki/markdown-it-markdown-renderer
render markdown-it tokens into markdown
https://github.com/moki/markdown-it-markdown-renderer
Last synced: about 1 year ago
JSON representation
render markdown-it tokens into markdown
- Host: GitHub
- URL: https://github.com/moki/markdown-it-markdown-renderer
- Owner: moki
- Created: 2023-02-05T14:34:10.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-29T15:50:23.000Z (about 3 years ago)
- Last Synced: 2025-02-10T08:46:17.268Z (over 1 year ago)
- Language: TypeScript
- Size: 154 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.MD
Awesome Lists containing this project
README
# markdown-it-markdown-renderer
This is custom [markdown-it](https://github.com/markdown-it/markdown-it) renderer that aims to provide zero diff with **original markdown** in **most cases** and **exact zero diff** in the case of the **html render**.
supporting syntax from the [commonmark specification](https://spec.commonmark.org/)
## Overview
- [rules](src/rules/README.MD)
- [renderer](src/renderer/README.MD)
- [plugin](src/plugin/README.MD)
## Usage
### Plugin
Plugin interface allows you to configure your markdown-it instance with plugin to
use [renderer](src/renderer/README.MD) to render into **markdown** instead of the **html**.
```
import MarkdownIt from 'markdown-it';
import {MarkdownRendererEnv} from 'src/renderer';
import {mdRenderer} from 'src/plugin';
const md = new MarkdownIt('commonmark', {html: true});
md.use(mdRenderer);
```
Markdown renderer needs additional information parsed from the document
For that reason we require you to provide, `MarkdownRendererEnv` described in the [renderer](src/renderer/README.MD) module.
`source` - is original markdown string split by new lines
```
const markdown = '# Title\nparagraph goes **here**\n- list item one\n- list item two\n';
const env: MarkdownRendererEnv = {source: markdown.split('\n')};
const rendered = md.render(markdown, env);
```