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
This commit is contained in:
Matthew Kastor 2012-10-19 17:11:45 -04:00
parent 409c62b22c
commit e36cb0f96b
3 changed files with 6 additions and 0 deletions

View File

@ -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 {

View File

@ -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);
};
}

View File

@ -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(/&lt;/g, '<')