Parsing Markdown files in Node.js using the node-markdown module

The following example shows how you can parse Markdown files in Node.js using the node-markdown module.

For more information on Markdown, see

First, install the node-markdown module using the following Terminal command:

npm install node-markdown

Next, create a new Markdown file,, in the current directory:

# Books

- [Async JavaScript](
- [Hands-on Node.js](
- [Node for Front-End Developers](
- [Node Web Development](
- [Node.js in Action](
- [Node: Up and Running: Scalable Server-Side Code with JavaScript](
- [Professional Node.js: Building JavaScript Based Scalable Software](
- [Programming Node.js](
- [Smashing Node.js: JavaScript Everywhere](
- [The Node Beginner Book]( ie=UTF8&qid=1347828493&sr=8-9&keywords=nodejs)

Finally, create the main JavaScript file, app.js, and enter the following text:

#!/usr/bin/env node

var fs = require("fs");

var md = require("node-markdown").Markdown;

fs.readFile("", function (err, data) {
    if (err) {
        throw err;


If you run the previous code from the Terminal (node ./app.js) you can see that the Markdown is converted to HTML:


<li><a href=";qid=1347828493&amp;sr=8-6&amp;keywords=nodejs">Async JavaScript</a></li>
<li><a href=";qid=1347828493&amp;sr=8-15&amp;keywords=nodejs">Hands-on Node.js</a></li>
<li><a href=";qid=1347829122&amp;sr=8-28&amp;keywords=nodejs">Node for Front-End Developers</a></li>
<li><a href=";qid=1347828493&amp;sr=8-4&amp;keywords=nodejs">Node Web Development</a></li>
<li><a href=";qid=1347828493&amp;sr=8-3&amp;keywords=nodejs">Node.js in Action</a></li>
<li><a href=";qid=1347828493&amp;sr=8-1&amp;keywords=nodejs">Node: Up and Running: Scalable Server-Side Code with JavaScript</a></li>
<li><a href=";qid=1347829122&amp;sr=8-32&amp;keywords=nodejs">Professional Node.js: Building JavaScript Based Scalable Software</a></li>
<li><a href=";qid=1347828493&amp;sr=8-11&amp;keywords=nodejs">Programming Node.js</a></li>
<li><a href="">Smashing Node.js: JavaScript Everywhere</a></li>
<li><a href=";qid=1347828493&amp;sr=8-9&amp;keywords=nodejs">The Node Beginner Book</a></li>

Leave a Reply

Your email address will not be published.