Introducing Markup builder: minimalist but powerful HTML and Markdown markup builder
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 XSS, Remarkable, DOMParser 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 <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, https://www.youtube.com/watch?v=sO_YEdTcVXc https://travis-ci.org/peerquery/markup-builder";
//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);
});
// "<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,<script>alert(\'Quisque rutrum.\')</script> nascetur ridiculus mus. Donec quam felis, <a href="https://www.youtube.com/watch?v=sO_YEdTcVXc">https://www.youtube.com/watch?v=sO_YEdTcVXc</a> <a href="https://travis-ci.org/peerquery/markup-builder">https://travis-ci.org/peerquery/markup-builder</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: https://github.com/peerquery/markup-builder
NPM page: https://www.npmjs.com/package/markup-builder
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 https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]
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 Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).
Want to chat? Join us on Discord https://discord.gg/h52nFrV.
Vote for Utopian Witness!