Coder Social home page Coder Social logo

char0n / blueprint-markdown-renderer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from apiaryio/blueprint-markdown-renderer

0.0 3.0 0.0 59 KB

Default parser and set of settings for parsing Markdown blocks in API Blueprint

License: MIT License

JavaScript 100.00%

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-render';

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 } 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: true, // run HTML sanitization
});

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

By default, tests are ran on server as well as in the browser, using Karma. To ran manually just one specific type, use:

$ npm run server-test
$ npm run browser-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 freaz avatar honzajavorek avatar kuba-kubula avatar

Watchers

 avatar  avatar  avatar

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.