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

HTML-to-plaintext fails for <pre> text #10

Open
adam-p opened this issue Jun 7, 2012 · 1 comment
Open

HTML-to-plaintext fails for <pre> text #10

adam-p opened this issue Jun 7, 2012 · 1 comment
Labels

Comments

@adam-p
Copy link
Owner

adam-p commented Jun 7, 2012

Reproduction
  1. Go here or to any "raw" source page for a Github README (like ours).
  2. Select-all, copy.
  3. Paste into Gmail.
  4. Click "Markdown Toggle".

Result: Pretty disastrous rendering. Specifically, it mostly looks like the whole text is being treated as a single line.

Preliminary diagnosis

jsHtmlToText (the library we use for HTML-to-plaintext) adds newlines to text based on tags, and doesn't pay attention to stuff like white-space: pre; -- which changes how newlines should be treated.

Possible solutions
  • Make the HTML-to-plaintext processing more intelligent. E.g., check styles like white-space.
  • Make the HTML-to-plaintext processing simple: just use innerText (or textContent in Gecko). It'll require proper testing, but some initial fooling around suggests it works well.
Workaround

Don't paste <pre> text. Paste plaintext or convert to plaintext (like with Gmail's "Strip formatting" button).

@adam-p
Copy link
Owner Author

adam-p commented Jun 7, 2012

This issue was forked from #9

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

1 participant