From 660338e93bd3711dce91c2b8d2995ff38de82472 Mon Sep 17 00:00:00 2001 From: Ben Blank Date: Fri, 20 Apr 2012 14:54:33 -0700 Subject: [PATCH] allow GFM hardwrapping to be disabled Note that hardwrapping is enabled by default in the GFM script (to preserve its behavior), but that it is disabled by default in the JSDoc plugin, as that seems more useful for inline documentation. --- node_modules/gfm/showdown.js | 8 +++++++- plugins/markdown.js | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/node_modules/gfm/showdown.js b/node_modules/gfm/showdown.js index 324b81db..facd58d9 100644 --- a/node_modules/gfm/showdown.js +++ b/node_modules/gfm/showdown.js @@ -101,6 +101,8 @@ var g_html_blocks; // (see _ProcessListItems() for details): var g_list_level = 0; +// == CJS == Allow hardwrapping to be disabled. +var g_hardwrap; this.makeHtml = function(text) { // @@ -118,6 +120,9 @@ this.makeHtml = function(text) { g_titles = new Array(); g_html_blocks = new Array(); + // == CJS == Allow hardwrapping to be disabled. + g_hardwrap = typeof this.hardwrap === "undefined" || this.hardwrap; + // attacklab: Replace ~ with ~T // This lets us use tilde as an escape char to avoid md5 hashes // The choice of character is arbitray; anything that isn't @@ -1140,7 +1145,8 @@ var _FormParagraphs = function(text) { } else if (str.search(/\S/) >= 0) { str = _RunSpanGamut(str); - str = str.replace(/\n/g,"
"); // ** GFM ** + // == CJS == Allow hardwrapping to be disabled. + if (g_hardwrap) str = str.replace(/\n/g,"
"); // ** GFM ** str = str.replace(/^([ \t]*)/g,"

"); str += "

" grafsOut.push(str); diff --git a/plugins/markdown.js b/plugins/markdown.js index 64d08550..bcb8f133 100644 --- a/plugins/markdown.js +++ b/plugins/markdown.js @@ -28,6 +28,7 @@ function getParser(parser, conf) { parser = new (require("gfm/showdown").Converter)(); parser.githubRepoOwner = conf.githubRepoOwner; parser.githubRepoName = conf.githubRepoName; + parser.hardwrap = !!conf.gfmHardwrap; return function(source) { return parser.makeHtml(source);