Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix for issue #58 "Windows linebreak issues" #64

Closed
wants to merge 1 commit into from

3 participants

@matthewkastor

Fix for issue #58 "Windows linebreak issues"

I installed markdown 0.4.0 through npm. While using md2html from the commandline on windows, I noticed that the program chokes on end of line marks that windows uses \r\n. I also noticed this same problem when using JSDoc3 which, has incorporated markdown-js into its source.

This pull request fixes the issue by replacing line breaks of the form \r\n, \n, and \r with the line break \n. I followed the process to the split_blocks function and inserted the filter on input text to occur just before it is processed. I believe this is the point in code that all input text has to pass through and that by affecting things here I've resolved the issue for all cases without introducing any bugs. Of course I could be wrong.

I commit these Glorious updates to make stuff do things, better!

@matthewkastor matthewkastor Issue #58 FIXED
Normalize EOL to `\n` so markdown doesn't gag on it.
22cedff
@matthewkastor matthewkastor referenced this pull request in jsdoc3/jsdoc
Closed

Markdown - Filters input EOL 2 #225

@RyanGough

+1 for this, would be great not to have to worry about line endings in markdown files

@evilstreak
Owner

I included your fix in 67d8fee, along with some tests. Thanks for the patch.

@evilstreak evilstreak closed this
@matthewkastor

Awesome. :D

@dchambers dchambers referenced this pull request from a commit in BladeRunnerJS/brjs
@matthewkastor matthewkastor 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.

evilstreak/markdown-js#64
e36cb0f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 16, 2012
  1. @matthewkastor

    Issue #58 FIXED

    matthewkastor authored
    Normalize EOL to `\n` so markdown doesn't gag on it.
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 0 deletions.
  1. +1 −0  lib/markdown.js
View
1  lib/markdown.js
@@ -160,6 +160,7 @@ function count_lines( str ) {
// Internal - split source into rough blocks
Markdown.prototype.split_blocks = function splitBlocks( input, startLine ) {
+ input = input.replace(/(\r\n|\n|\r)/g, '\n');
// [\s\S] matches _anything_ (newline or space)
var re = /([\s\S]+?)($|\n(?:\s*\n|$)+)/g,
blocks = [],
Something went wrong with that request. Please try again.