Skip to content

gfm style line breaks break html badly #115

Open
midnightmonster opened this Issue Jan 23, 2013 · 5 comments

4 participants

@midnightmonster

With gfm line breaks enabled, code like this:

<table>
<tr><td>Hello</td></tr>
</table>

Will generate <br> tags at the end of each line, which creates invalid HTML and ugly rendering as the browser moves those extra line breaks somewhere.

github's actual github flavored markdown doesn't appear to have this unfortunate behavior.

@chemzqm
chemzqm commented Feb 3, 2013

I changed the * to + in line 507 and 508 of libs/maked.js

inline.breaks = merge({}, inline.gfm, {
    br: replace(inline.br)('{2,}', '+')(),
    text: replace(inline.gfm.text)('{2,}', '+')()
  });

to remove the unnecessary <br>, that means there should always a space to add a break line.

@janpaul123

+1 -- very serious issue if you want to include some readable HTML.

@SimonCropp

is the change proposed by @chemzqm a viable fix for this? any chance of it being merged in?

@midnightmonster

The correct behavior (where correct means "works most of the time and matches what github actually does") is to toss the current line breaks implementation and make it so that newline-to-br processing happen with a simple find and replace only in the 'paragraph' and 'text' cases in the big Parser.prototype.tok switch.

@midnightmonster

Submitted a pull request #348. It doesn't feel like it matches the style/organization exactly, but it does the right thing.

@adam-p adam-p referenced this issue in adam-p/markdown-here Mar 9, 2014
Open

Line-break tag noise added to multi-line HTML #157

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.