Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gfm style line breaks break html badly #115

Closed
midnightmonster opened this issue Jan 23, 2013 · 6 comments
Closed

gfm style line breaks break html badly #115

midnightmonster opened this issue Jan 23, 2013 · 6 comments

Comments

@midnightmonster
Copy link

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
Copy link

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
Copy link

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

@SimonCropp
Copy link

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

@midnightmonster
Copy link
Author

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
Copy link
Author

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

@joshbruce
Copy link
Member

#985

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants