From e36cb0f96b1bdc7fba90a8e259eebc9bbbc3e696 Mon Sep 17 00:00:00 2001 From: Matthew Kastor Date: Fri, 19 Oct 2012 17:11:45 -0400 Subject: [PATCH] Markdown Input EOL Filtering Added filters for input end of line character where evilstreak/markdown was called because it chokes on `\r\n`. We'll have to do this to any input to this markdown parser unless/until they accept my pull request and we update the upstream source. https://github.com/evilstreak/markdown-js/pull/64 --- plugins/markdown.js | 2 ++ rhino_modules/jsdoc/readme.js | 2 ++ rhino_modules/jsdoc/tutorial.js | 2 ++ 3 files changed, 6 insertions(+) diff --git a/plugins/markdown.js b/plugins/markdown.js index 3c556a38..a5f0c875 100644 --- a/plugins/markdown.js +++ b/plugins/markdown.js @@ -50,6 +50,8 @@ function getParser(parser, conf) { parser = require(parser).markdown; return function(source) { + // filters EOL of source so evilstreak/markdown doesn't screw the pooch. + source = source.replace(/(\r\n|\n|\r)/g, '\n'); return parser.toHTML(source, conf.dialect); }; } else { diff --git a/rhino_modules/jsdoc/readme.js b/rhino_modules/jsdoc/readme.js index c9d46adc..6669821a 100644 --- a/rhino_modules/jsdoc/readme.js +++ b/rhino_modules/jsdoc/readme.js @@ -32,6 +32,8 @@ function getParser(parser, conf) { parser = require('markdown').markdown; return function(source) { + // filters EOL of source so evilstreak/markdown doesn't screw the pooch. + source = source.replace(/(\r\n|\n|\r)/g, '\n'); return parser.toHTML(source, conf.dialect); }; } diff --git a/rhino_modules/jsdoc/tutorial.js b/rhino_modules/jsdoc/tutorial.js index da0ba751..aebde28b 100644 --- a/rhino_modules/jsdoc/tutorial.js +++ b/rhino_modules/jsdoc/tutorial.js @@ -68,6 +68,8 @@ exports.Tutorial.prototype.parse = function() { // markdown case exports.TYPES.MARKDOWN: + // filters EOL of source so evilstreak/markdown doesn't screw the pooch. + this.content = this.content.replace(/(\r\n|\n|\r)/g, '\n'); return mdParser.toHTML(this.content) .replace(/&/g, '&') // because markdown escapes these .replace(/</g, '<')