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

in #utopian-io6 years ago (edited)


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?


npm install markup-builder --save

Use as:

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

Exported to the browser window as markup.

Using markup builder

const t = "**Lorem ipsum dolor sit amet**, consectetuer adipiscing elit. Aenean <i>commodo ligula eget</i> dolor. Aenean massa. Cum @sociis natoque #penatibus et magnis dis parturient montes,<script>alert('Quisque rutrum.')</script> nascetur ridiculus mus. Donec quam felis,";

//inside async function
var content = await /*,config, options*/ );   //with about options object
//With promise API /*,config, options*/).then(function(content){   //options is optional, using defaults
// "<p><strong>Lorem ipsum dolor sit amet</strong>, consectetuer adipiscing elit. Aenean <i>commodo ligula eget</i> dolor. Aenean massa. Cum <a target="_blank" href="/user/sociis">@sociis</a> natoque <a target="_blank" href="/trending/penatibus "> #penatibus </a> et magnis dis parturient montes,&lt;script&gt;alert(\'Quisque rutrum.\')&lt;/script&gt; nascetur ridiculus mus. Donec quam felis, <a href=""></a> <a href=""></p></a>\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:

NPM page:

Published on Peer Query - Blockchain-powered p2p collaboration.


This is very similar to your previous post: It's the sort of post I'd like to see go into much more detail. I would have liked to know why you decided to make this, why you made the decisions you made while making this.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.

Need help? Write a ticket on
Chat with us on Discord.

before i begin let me thank you and utopian for your support, i appreciate it alot

sorry for the brief submission, i am a little late on schedule and rushed things. basically, there are two different libraries, markup-tools for basic manipulations while markup-builder does absolute markup processing

these two libraries are great for handling Steem based markup as they process markup which is sometimes a mix of HTML and Markdown, they also sanitize markup against XSS, while building raw youtube urls into iframes, raw image links into img tags, raw mentions and hashtags into hyperlinked entities and more

they basically handle all the complete parsing, transformations, building and sanitizations of markup so you can just plug it into your project and play. they are also fully customizable giving the developer complete control of the resulting markup

they work in both browser and node.js, making them very compact. i am using them on peer query and they will be integrated into curator and adom and other projects. i believe the community could benefit from them

the difference between the two is: markup-tools is standalone and dependency free, does powerful text parsing, and building of HTML markup. however markup-builder offers a complete solution including markdown conversion, sanitizing and more. actually, markup-builder uses markup-tool as a dependency

Thank you for your review, @didic!

So far this week you've reviewed 14 contributions. Keep up the good work!

Hi @dzivenu!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Hey, @dzivenu!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support!
Simply set as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord

Vote for Utopian Witness!

Coin Marketplace

STEEM 0.29
TRX 0.11
JST 0.031
BTC 69768.04
ETH 3884.71
USDT 1.00
SBD 3.73