ssorallen / turbo-react

A JavaScript library that transitions between static HTML pages on navigation; no app server required.
https://turbo-react.herokuapp.com/
Apache License 2.0
274 stars 16 forks source link

Maintain whitespace in JSX transform #3

Closed ssorallen closed 9 years ago

ssorallen commented 10 years ago

When an inline element is on a new line after a block of text or there is a block of text after an inline element and a new line, the white space between is lost.

Example:

<p>
  Howdy there, buddy. Check out my
  <a href="#">website</a>.
</p>

Output:

Howdy there, buddy. Check out my<a>website</a>.

Ideally the source HTML would not have to be modified to maintain the white space.

ssorallen commented 9 years ago

Note: this is not a bug in "turbo-react" but rather a limitation or bug in JSX itself. HTML interprets newlines and/or many spaces to be a single space. JSX does not interpret newlines the same way.

ssorallen commented 9 years ago

Although now I realize why I originally opened this: the loss of significant whitespace needs to be fixed in the output before running it through JSX.

ssorallen commented 9 years ago

This has been fixed by integrating react-magic's HTML to JSX converter.