@diplodoc/markdown-it-markdown-renderer
TypeScript icon, indicating that this package has built-in type declarations

0.16.0 • Public • Published

markdown-it-markdown-renderer

This is custom 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

Overview

Usage

Plugin

Plugin interface allows you to configure your markdown-it instance with plugin to use renderer 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 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);

Package Sidebar

Install

npm i @diplodoc/markdown-it-markdown-renderer

Weekly Downloads

120

Version

0.16.0

License

MIT

Unpacked Size

71.6 kB

Total Files

52

Last publish

Collaborators

  • yndx-birman111
  • martyanov-av
  • vsesh
  • rndnm
  • v8tenko
  • moki
  • 3y3
  • alexey_w100
  • robot-dataui-npm