diff --git a/lib/markdown.js b/lib/markdown.js index fa7411d..a5bc07c 100644 --- a/lib/markdown.js +++ b/lib/markdown.js @@ -51,29 +51,16 @@ // // var text = "Markdown *rocks*."; // -// var converter = new Showdown.converter(); -// var html = converter.makeHtml(text); +// var markdown = require("markdown"); +// var html = markdown.encode(text); // -// alert(html); +// print(html); // // Note: move the sample code to the bottom of this // file before uncommenting it. // -// -// Showdown namespace -// -var Showdown = {}; - -// -// converter -// -// Wraps all "globals" so that the only thing -// exposed is makeHtml(). -// -Showdown.converter = function() { - // // Globals: // @@ -88,7 +75,7 @@ var g_html_blocks; var g_list_level = 0; -this.makeHtml = function(text) { +exports.makeHtml = function(text) { // // Main function. The order in which other subs are called here is // essential. Link and image substitutions need to happen before @@ -1293,10 +1280,11 @@ var escapeCharacters_callback = function(wholeMatch,m1) { return "~E"+charCodeToEscape+"E"; } -} // end of Showdown.converter +exports.markdown = function(src) { + return exports.makeHtml(src); +}; -exports.Markdown = Showdown.converter; +exports.encode = function (src) { + return exports.makeHtml(src); +}; -exports.markdown = function(src) { - return new Showdown.converter().makeHtml(src); -} diff --git a/tests/all-tests.js b/tests/all-tests.js new file mode 100644 index 0000000..b835ba2 --- /dev/null +++ b/tests/all-tests.js @@ -0,0 +1,13 @@ +var assert = require("test/assert"); +var markdown = require("markdown"); + +exports.testH1 = function () { + assert.eq("

Hi

", markdown.encode("Hi\n=")); +}; + +exports.testP = function () { + assert.eq("

Paragraph.

", markdown.markdown("Paragraph.")); +}; + +if (require.main === module.id) + require("os").exit(require("test/runner").run(exports));