Giter Site home page Giter Site logo

blueprint-markdown-renderer's Introduction

Blueprint Markdown Renderer

Default parser and set of settings for parsing and rendering of Markdown blocks in API Description Documents.

Installation

$ npm install blueprint-markdown-renderer

Usage

Basic Rendering

import { renderHtml } from 'blueprint-markdown-renderer';

const mdText = '# Heading';

const html = renderHtml(mdText);

console.log("Rendered HTML: ", html);

Advanced Usage

Note that if you alter renderer's settings, you are potentially diverging from the ecosystem, therefore this is not encouraged. However, it's still better to share the same rendering core with customised behaviour than it is to start for the blank slate.

Blueprint Markdown Renderer uses markdown-it under the hood. See markdown-it API Documentation to find all available options how to change renderer.

import { renderHtml, rendererFactory, sanitize } from 'blueprint-markdown-render';
import emojiPlugin from 'markdown-it-emoji';

const renderer = rendererFactory();

// alter default options
renderer.set({ langPrefix: 'lang-', breaks: true });

// add own plugin
renderer.use(emojiPlugin);

const mdText = ':smiley:';

const html = renderHtml(mdText, {
  renderer, // custom renderer
  env, // additional data from parsed input (references, for example)
  sanitize, // run HTML sanitization function
});

console.log("Rendered HTML: ", html);

Motivation

While API Blueprint syntax is based on Markdown, it doesn't care about the (Markdown) content of description blocks. The reference parser actually preserves the source Markdown in the produced API Elements. Same logic applies to

This library is intended to provide a consistent API for parsing those Markdown blocks. Use it to get the same defaults and consistent rendering with the rest of JavaScript API Blueprint ecosystem.

To get consistent experience accross languages, this library uses CommonMark implementation under its hood. Following extensions to default rendering is enabled by default:

Development

$ npm install
$ npm test

This package is using Semantic Release.

Please use proper commit message format.

License

MIT (see LICENSE file)

Apiary Czech Republic, s.r.o. [email protected]

blueprint-markdown-renderer's People

Contributors

abtris avatar almad avatar char0n avatar freaz avatar honzajavorek avatar kuba-kubula avatar patricksmms avatar tomas-mechura avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

char0n

blueprint-markdown-renderer's Issues

Mark / solve / announce regressions

Regressions against current robotskirt:

  • Standalone <img> has always been wrapped in <p>
  • Escaping in fenced code blocks: ' vs. &#39;
  • Additional newline between headers
  • Different newlines between li and ul elements with nested lists
  • Different newline skipping with (fenced) code blocks
  • GFM Alignment directive (:--) is ignored in tables
  • alert at the beginning of line killed table recognition -- but only in plugin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.