Introducing Markup builder: minimalist but powerful HTML and Markdown markup builder

image

Meet Markup builder, a minimal powerful utility for building markup, be it HTML or Markdown.

This library can help you transform your markup by sanitizing against XSS, converting markdown to HTML and more. It is built on XSSRemarkableDOMParser and Markup tools.

How do you use Markup builder?

Node.js

npm install markup-builder --save

Use as:

const markup = require('markup-builder');

Browser
https://unpkg.com/markup-builder/dist/markup.min.js
Exported to the browser window as markup.

Using markup builder

const t = "**Lorem ipsum dolor sit amet**, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum @sociis natoque #penatibus et magnis dis parturient montes,alert('Quisque rutrum.')

; //inside async function var content = await markup.build.content(t /*,config, options*/ ); //with about options object console.log(content); //With promise API markup.build.content(t /*,config, options*/).then(function(content){ //options is optional, using defaults console.log(content); }); // "

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum @sociis natoque #penatibus et magnis dis parturient montes,<script>alert(\'Quisque rutrum.\')</script> nascetur ridiculus mus. Donec quam felis, https://travis-ci.org/peerquery/markup-builder\n"

How is Markup builder different from Markup tools?

Markup tools is a small set of standalone utilities for basic text manipulation. However Markup builder allows you to actually build markup.

Markup builder's build functions use Markup tools to build all un-attached hashtags into hyperlinked tags, all un-attached mentions into hyperlinked mentions, as well as build all raw urls and image links into their respective tags.

In addition to this markup is also sanitized, and markdown is converted to HTML.

Resources and links

Github repo: https://github.com/peerquery/markup-builder

NPM page: https://www.npmjs.com/package/markup-builder


Published on Peer Query - Blockchain-powered p2p collaboration.

H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now
Logo
Center