diff --git a/dist/showdown.js b/dist/showdown.js index 1e9fb75..bb80608 100644 Binary files a/dist/showdown.js and b/dist/showdown.js differ diff --git a/dist/showdown.js.map b/dist/showdown.js.map index 2697701..52d4269 100644 Binary files a/dist/showdown.js.map and b/dist/showdown.js.map differ diff --git a/dist/showdown.min.js b/dist/showdown.min.js index 8b0db72..bf11a0d 100644 Binary files a/dist/showdown.min.js and b/dist/showdown.min.js differ diff --git a/dist/showdown.min.js.map b/dist/showdown.min.js.map index b4e6a8d..2cf9902 100644 Binary files a/dist/showdown.min.js.map and b/dist/showdown.min.js.map differ diff --git a/src/converter.js b/src/converter.js index eacf003..8325fda 100644 --- a/src/converter.js +++ b/src/converter.js @@ -314,6 +314,9 @@ showdown.Converter = function (converterOptions) { // attacklab: Restore tremas text = text.replace(/¨T/g, '¨'); + // render a complete html document instead of a partial if the option is enabled + text = showdown.subParser('completeHTMLOutput')(text, options, globals); + // Run output modifiers showdown.helper.forEach(outputModifiers, function (ext) { text = showdown.subParser('runExtension')(ext, text, options, globals); diff --git a/src/options.js b/src/options.js index fc4df19..c743c45 100644 --- a/src/options.js +++ b/src/options.js @@ -150,6 +150,11 @@ function getDefaultOpts (simple) { defaultValue: false, description: 'Enable support for underline. Syntax is double or triple underscores: `__underline word__`. With this option enabled, underscores no longer parses into `` and ``', type: 'boolean' + }, + completeHTMLOutput: { + defaultValue: false, + description: 'Outputs a complete html document, including ``, `` and `` tags', + type: 'boolean' } }; if (simple === false) { diff --git a/src/subParsers/completeHTMLOutput.js b/src/subParsers/completeHTMLOutput.js new file mode 100644 index 0000000..7b8c722 --- /dev/null +++ b/src/subParsers/completeHTMLOutput.js @@ -0,0 +1,17 @@ +/** + * Turn Markdown link shortcuts into XHTML tags. + */ +showdown.subParser('completeHTMLOutput', function (text, options, globals) { + 'use strict'; + + if (!options.completeHTMLOutput) { + return text; + } + + text = globals.converter._dispatch('completeHTMLOutput.before', text, options, globals); + + text = '\n\n\n\n\n' + text.trim() + '\n\n'; + + text = globals.converter._dispatch('completeHTMLOutput.after', text, options, globals); + return text; +}); diff --git a/test/features/completeHTMLOutput/simple.html b/test/features/completeHTMLOutput/simple.html new file mode 100644 index 0000000..62aa62a --- /dev/null +++ b/test/features/completeHTMLOutput/simple.html @@ -0,0 +1,14 @@ + + + + + +

This is a markdown file

+

Converted into a full HTML document

+
    +
  • this
  • +
  • is
  • +
  • awesome
  • +
+ + diff --git a/test/features/completeHTMLOutput/simple.md b/test/features/completeHTMLOutput/simple.md new file mode 100644 index 0000000..e35ed26 --- /dev/null +++ b/test/features/completeHTMLOutput/simple.md @@ -0,0 +1,7 @@ +This is a **markdown** file + +Converted into a full HTML document + + - this + - is + - awesome diff --git a/test/node/testsuite.features.js b/test/node/testsuite.features.js index a0d0194..a7ee7e8 100644 --- a/test/node/testsuite.features.js +++ b/test/node/testsuite.features.js @@ -14,7 +14,8 @@ var bootstrap = require('../bootstrap.js'), emojisSuite = bootstrap.getTestSuite('test/features/emojis/'), underlineSuite = bootstrap.getTestSuite('test/features/underline/'), literalMidWordUnderscoresSuite = bootstrap.getTestSuite('test/features/literalMidWordUnderscores/'), - literalMidWordAsterisksSuite = bootstrap.getTestSuite('test/features/literalMidWordAsterisks/'); + literalMidWordAsterisksSuite = bootstrap.getTestSuite('test/features/literalMidWordAsterisks/'), + completeHTMLOutputSuite = bootstrap.getTestSuite('test/features/completeHTMLOutput/'); describe('makeHtml() features testsuite', function () { 'use strict'; @@ -231,4 +232,14 @@ describe('makeHtml() features testsuite', function () { it(suite[i].name.replace(/-/g, ' '), assertion(suite[i], converter)); } }); + + /** test completeHTMLOutput option **/ + describe('completeHTMLOutput option', function () { + var converter, + suite = completeHTMLOutputSuite; + for (var i = 0; i < suite.length; ++i) { + converter = new showdown.Converter({completeHTMLOutput: true}); + it(suite[i].name.replace(/-/g, ' '), assertion(suite[i], converter)); + } + }); });