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

Significant whitespace at the end of lines is being lost from Markdown #7

Closed
adam-p opened this issue May 30, 2012 · 2 comments
Closed
Labels

Comments

@adam-p
Copy link
Owner

adam-p commented May 30, 2012

According to the Markdown spec, two spaces at the end of a line indicates a hard line-break (<br>) should be inserted in the rendering.

But the original-HTML-to-plaintext module we're using strips trailing whitespace. See:
https://github.com/adam-p/markdown-here/blob/master/src/common/jsHtmlToText.js#L72

Unfortunately, there are no hooks in htmlToText that will let us skip the stripping. So we'll either have to:

  • modify the code directly
    • distasteful because it makes it harder to pull in any updates to the original project
  • in the preprocessing hook, replace trailing whitespace with placeholder tags, and then swap them back to the original whitespace in the tagreplacement hook
    • distasteful because it's ugly

Originally discovered by a Reddit commenter.

adam-p added a commit that referenced this issue May 31, 2012
…his code will be pull-requested back to jsHtmlToText at some point.)
@adam-p
Copy link
Owner Author

adam-p commented May 31, 2012

Fixed in 49c6b61

@adam-p adam-p closed this as completed May 31, 2012
@crdx
Copy link

crdx commented Sep 25, 2012

distasteful because it makes it harder to pull in any updates to the original project

If you were to make your change in a fork of js-htmltotext and pull upstream and push origin whenever it was updated, wouldn't that be a reasonably easy way of maintaining this change while simultaneously keeping it up-to-date?

This is assuming your change isn't accepted in a pull request back to the original project, of course.

(I know I'm late to the party, but I thought it might be worth still mentioning.)

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

No branches or pull requests

2 participants