Git Product home page Git Product logo

node-hoedown's Introduction

node-hoedown (beta)

Build Status

var hoedown = require("hoedown");

Lightweight, fast Node.JS bindings for Hoedown, the amazing Markdown library (successor for the abandoned Sundown).

Really simple to use:

var renderer = hoedown();

renderer.do("Some *useful* Markdown.") //-> "<p>Some <em>useful</em> Markdown.</p>"
renderer.do("¿ÚTF? Nö **prøblem**.") //-> "<p>¿ÚTF? Nö <strong>prøblem</strong>.</p>"
// be sure to reuse the object for blazing speed!

It's flexible

Because parsing pure Markdown is really boring, you can pass an options object to hoedown() to customize it. How about making it recognize some extensions?

var renderer = hoedown({
  extensions: hoedown.Extensions.AUTOLINK | hoedown.Extensions.FOOTNOTES
});

renderer.do("Here's a http://link.com.") //-> "<p>Here's a <a href="http://link.com">http://link.com</a>.</p>"

You can see the full list of extensions in the docs.
It's also possible to customize the HTML renderer by passing some flags:

var renderer = hoedown({
  extensions: hoedown.Extensions.AUTOLINK | hoedown.Extensions.FOOTNOTES,
  renderer: {
    flags: hoedown.HTML.Flags.HARD_WRAP | hoedown.HTML.Flags.ESCAPE
  }
});

renderer.do("Roses are red.\nViolets are blue.") //-> "<p>Roses are red.<br>Violets are blue.</p>"

The full options accepted by the HTML renderer can be found at the docs. You can also use the TOC renderer to render a Table of Contents of the document, as in this example.

Other things

Hoedown comes with a fully functional implementation of SmartyPants. You can also access Hoedown's version, use the autolinker, escape things, etc. Check out the docs and the examples!

It's secure

Hoedown is all about security. It has been extensively tested to make sure it won't crash or leak under any input. If you believe you have found a vulnerability, report it there.

That said, the HTML produced by Hoedown is not secure. Unless you're using the ESCAPE or SKIP_HTML flags, you should really consider sanitizing the HTML.

No custom renderers?

Users coming from Robotskirt may notice these bindings don't offer the possibility of including custom callbacks in renderers, or create pure JS renderers. There are many reasons for that, notably:

  • Painfully slow: the constant switches between C++ and JS decrease performance.
  • Often useless: the callbacks had to be synchronous, which totally stopped you from working with asynchronous libraries.

If you need further processing, it's better to process the rendered output (if it's HTML, you can use jsdom for instance). FIXME: mention JSON

Tip: If you need code highlighting, just include Prism in your site, it'll automatically highlight your fenced code blocks.

node-hoedown's People

Contributors

mildsunrise 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.