markdown vs markdown-it vs remark vs showdown
Markdown Parsing Libraries
markdownmarkdown-itremarkshowdownSimilar Packages:

Markdown Parsing Libraries

Markdown parsing libraries are tools used to convert Markdown text into HTML or other formats, enabling developers to easily render formatted text in web applications. These libraries vary in features, extensibility, and performance, catering to different needs in terms of simplicity, customization, and output quality. Choosing the right library can significantly impact the ease of integration, the flexibility of rendering options, and the overall performance of the application.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
markdown07,695-10513 years ago-
markdown-it021,170768 kB59a month agoMIT
remark08,78615.7 kB73 years agoMIT
showdown014,839801 kB236-MIT

Feature Comparison: markdown vs markdown-it vs remark vs showdown

Extensibility

  • markdown:

    The 'markdown' package is minimalistic and does not offer extensibility options, making it less suitable for projects requiring additional features or customization.

  • markdown-it:

    'markdown-it' is highly extensible, allowing developers to create and integrate plugins for custom syntax and rendering options, making it ideal for complex applications.

  • remark:

    'remark' provides a robust plugin system that enables extensive transformations and custom processing of Markdown, making it the best choice for projects needing deep customization.

  • showdown:

    'showdown' offers limited extensibility through options but is primarily focused on straightforward conversion, making it less flexible than others.

Performance

  • markdown:

    Being lightweight, 'markdown' offers fast performance for basic parsing tasks, but may struggle with larger documents or more complex features.

  • markdown-it:

    'markdown-it' is optimized for performance and can handle large documents efficiently, making it suitable for applications with high rendering demands.

  • remark:

    'remark' is designed for performance when processing large Markdown files, especially when using its syntax tree manipulation capabilities.

  • showdown:

    'showdown' provides decent performance for standard Markdown conversion but may not be as fast as 'markdown-it' for larger documents.

Learning Curve

  • markdown:

    The 'markdown' library has a very low learning curve due to its simplicity and straightforward API, making it easy for beginners to adopt.

  • markdown-it:

    'markdown-it' has a moderate learning curve, especially when utilizing its plugin system and advanced features, but is well-documented for ease of use.

  • remark:

    'remark' has a steeper learning curve due to its focus on syntax trees and transformations, which may require a deeper understanding of Markdown processing.

  • showdown:

    'showdown' is easy to learn and implement, making it a good choice for developers looking for a quick solution without complex configurations.

Output Quality

  • markdown:

    The output quality of 'markdown' is basic and may not support advanced Markdown features like tables or footnotes, limiting its use in more sophisticated applications.

  • markdown-it:

    'markdown-it' produces high-quality HTML output with support for advanced Markdown features, making it suitable for professional applications.

  • remark:

    'remark' allows for high-quality output and offers flexibility in how the final HTML is structured, catering to specific project needs.

  • showdown:

    'showdown' generates good quality HTML output but may not handle all Markdown features as comprehensively as 'markdown-it'.

Use Cases

  • markdown:

    Best suited for simple applications or static sites where basic Markdown rendering is sufficient.

  • markdown-it:

    Ideal for applications requiring complex Markdown processing, such as content management systems or blogs with custom syntax.

  • remark:

    Perfect for projects that need to manipulate Markdown content extensively, such as documentation generators or static site generators.

  • showdown:

    Great for quick implementations where simplicity and ease of use are prioritized, such as small web apps or personal projects.

How to Choose: markdown vs markdown-it vs remark vs showdown

  • markdown:

    Choose 'markdown' for a simple and lightweight solution if you need basic Markdown parsing without additional features or customization. It's suitable for small projects or quick implementations.

  • markdown-it:

    Opt for 'markdown-it' if you require a highly customizable and extensible parser with support for plugins, advanced features like syntax highlighting, and a focus on performance. It's ideal for applications that need more control over the rendering process.

  • remark:

    Select 'remark' if you are looking for a powerful ecosystem for processing Markdown with a focus on syntax tree manipulation. It allows for extensive transformations and is best suited for projects that require complex processing of Markdown content.

  • showdown:

    Use 'showdown' if you need a straightforward and easy-to-use Markdown to HTML converter that works well in both browser and Node.js environments. It's particularly useful for projects that prioritize simplicity and quick setup.

README for markdown

markdown-js

Yet another markdown parser, this time for JavaScript. There's a few options that precede this project but they all treat markdown to HTML conversion as a single step process. You pass markdown in and get HTML out, end of story. We had some pretty particular views on how the process should actually look, which include:

  • producing well-formed HTML. This means that em and strong nesting is important, as is the ability to output as both HTML and XHTML

  • having an intermediate representation to allow processing of parsed data (we in fact have two, both JsonML: a markdown tree and an HTML tree)

  • being easily extensible to add new dialects without having to rewrite the entire parsing mechanics

  • having a good test suite. The only test suites we could find tested massive blocks of input, and passing depended on outputting the HTML with exactly the same whitespace as the original implementation

Installation

Just the markdown library:

npm install markdown

Optionally, install md2html into your path

npm install -g markdown

Usage

### Node

The simple way to use it with node is:

var markdown = require( "markdown" ).markdown;
console.log( markdown.toHTML( "Hello *World*!" ) );

### Browser

It also works in a browser; here is a complete example:

<!DOCTYPE html>
<html>
  <body>
    <textarea id="text-input" oninput="this.editor.update()"
              rows="6" cols="60">Type **Markdown** here.</textarea>
    <div id="preview"> </div>
    <script src="lib/markdown.js"></script>
    <script>
      function Editor(input, preview) {
        this.update = function () {
          preview.innerHTML = markdown.toHTML(input.value);
        };
        input.editor = this;
        this.update();
      }
      var $ = function (id) { return document.getElementById(id); };
      new Editor($("text-input"), $("preview"));
    </script>
  </body>
</html>

Command line

Assuming you've installed the md2html script (see Installation, above), you can convert markdown to html:

# read from a file
md2html /path/to/doc.md > /path/to/doc.html

# or from stdin
echo 'Hello *World*!' | md2html

### More options

If you want more control check out the documentation in lib/markdown.js which details all the methods and parameters available (including examples!). One day we'll get the docs generated and hosted somewhere for nicer browsing.

Meanwhile, here's an example of using the multi-step processing to make wiki-style linking work by filling in missing link references:

var md = require( "markdown" ).markdown,
    text = "[Markdown] is a simple text-based [markup language]\n" +
           "created by [John Gruber]\n\n" +
           "[John Gruber]: http://daringfireball.net";

// parse the markdown into a tree and grab the link references
var tree = md.parse( text ),
    refs = tree[ 1 ].references;

// iterate through the tree finding link references
( function find_link_refs( jsonml ) {
  if ( jsonml[ 0 ] === "link_ref" ) {
    var ref = jsonml[ 1 ].ref;

    // if there's no reference, define a wiki link
    if ( !refs[ ref ] ) {
      refs[ ref ] = {
        href: "http://en.wikipedia.org/wiki/" + ref.replace(/\s+/, "_" )
      };
    }
  }
  else if ( Array.isArray( jsonml[ 1 ] ) ) {
    jsonml[ 1 ].forEach( find_link_refs );
  }
  else if ( Array.isArray( jsonml[ 2 ] ) ) {
    jsonml[ 2 ].forEach( find_link_refs );
  }
} )( tree );

// convert the tree into html
var html = md.renderJsonML( md.toHTMLTree( tree ) );
console.log( html );

Intermediate Representation

Internally the process to convert a chunk of markdown into a chunk of HTML has three steps:

  1. Parse the markdown into a JsonML tree. Any references found in the parsing are stored in the attribute hash of the root node under the key references.

  2. Convert the markdown tree into an HTML tree. Rename any nodes that need it (bulletlist to ul for example) and lookup any references used by links or images. Remove the references attribute once done.

  3. Stringify the HTML tree being careful not to wreck whitespace where whitespace is important (surrounding inline elements for example).

Each step of this process can be called individually if you need to do some processing or modification of the data at an intermediate stage. For example, you may want to grab a list of all URLs linked to in the document before rendering it to HTML which you could do by recursing through the HTML tree looking for a nodes.

Running tests

To run the tests under node you will need tap installed (it's listed as a devDependencies so npm install from the checkout should be enough), then do

$ npm test

Contributing

Do the usual github fork and pull request dance. Add yourself to the contributors section of package.json too if you want to.

## License

Released under the MIT license.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.