revolunet / sublimetext-markdown-preview

markdown preview and build plugin for sublime text 2/3
MIT License
2.31k stars 362 forks source link

Option to disable newline to <br> conversion #374

Closed emlai closed 6 years ago

emlai commented 7 years ago

The plugin converts line breaks in the markdown file to <br> elements in the HTML output, which is problematic because GitHub doesn't do this and so when I view the same markdown file on GitHub it looks different.

I tried to find an option to toggle this behavior, but didn't find anything.

facelessuser commented 7 years ago

You specify extensions here: https://github.com/revolunet/sublimetext-markdown-preview/blob/master/MarkdownPreview.sublime-settings#L104. You would remove github and configure them individual omitting nl2br.

The GitHub-esque features are a bit out of date as they are based on my work here: http://facelessuser.github.io/pymdown-extensions/extensions/github/. There, nl2br is already removed. Keep in mind, it is not meant to give you a 1:1 conversion to GitHub's GFM, but to give you a GitHub-esque look. The Python Markdown parser and the GFM parser are fundamentally different in their approach, so it is never going to be a 1:1.


One reason the latest changes haven't made it here, is it has become more of a pain as Python Markdown does not support Python 2.6 anymore, and Markdown Preview continues to support ST2. If Markdown Preview were to drop ST2 support, it would be easy for me to just include the extensions as a dependency (additionally the latest Python Markdown as a dependency) and remove the burden from here. This plugin would just get them for free.

It's just harder to motivate myself to backport everything here since we still have the legacy baggage. I already support a lot of Sublime plugins, but this isn't one of mine. If this were my repo, I'd cut the ST2 support, move the rest of the 3rd party things to dependencies. I would probably clean up the settings as well. And I think this site could use a document page.

I think Markdown Preview probably needs a good 2.0 release that breaks a couple of things but cleans things up. I don't know if that is the direction this project wants to take, but that is what I think it needs.

facelessuser commented 7 years ago

This will get fixed in the new version moving forward.

facelessuser commented 6 years ago

This will be covered by #393

jlidbeck commented 6 years ago

In response to facelessuser, removing "github" from "enabled_parsers" doesn't solve the problem. The default parser, "markdown", also converts linebreaks to <br> in the browser preview. I'm using the most current published version (1.4.3)

facelessuser commented 6 years ago

@jlidbeck The next Markdown Preview (which is not released yet and lives on the dev branch) will use the Github-ish extensions from the pymdown-extensions dependency, instead of our currently vendored versions which are out of date. The latest pymdown-extensions do not enable nl2br by default if using the github extension (which is now deprecated and users are encouraged to configure the individual extensions themselves).

Anyways, when I finally release the new Markdown Preview (which will have some breaking changes), linebreaks will not be converted by default.

So this issue has been addressed, it just isn't available in the latest release.