poetic / reacterminator

Convert html to react components in es6 syntax.
56 stars 6 forks source link

Preserve Non-breaking Spaces #16

Open dvmorris opened 8 years ago

dvmorris commented 8 years ago

Reacterminator does not seem to be honoring nbsp; characters. Example:

Input

<div class="signintext" id="SignInText">Already have an account?&nbsp;<a id="SignInLink" href="login.html">Sign in</a>

Output

<div id="SignInText" className="signintext">
  Already have an account?
  <Link id="SignInLink" href="login.html" params={{  path: 'login'}}> Sign in
  </Link>
</div>
Chun-Yang commented 8 years ago

Fixed in version 0.10.4

dvmorris commented 8 years ago

This fix did not work for me. I am still seeing the same issue, and I'm running the following versions:

├─┬ poetic-stanza@1.0.6
│ ├── chalk@1.1.3
│ ├── cheerio@0.20.0
│ ├── commander@2.9.0 (git://github.com/rike422/commander.js.git#81577a6544b52fb22fee60f5e2c660c6565c04bf)
│ ├── glob@7.0.5
│ ├── lodash@4.13.1
│ ├── reacterminator@0.10.4
│ └── shelljs@0.6.0
martinbee commented 8 years ago

@Chun-Yang I'm looking into this issue and it appears that babylon's parse, using the jsx plugin, strips out   and replaces it with a ' '. If you get some time we can discuss this tomorrow and see if there's anything we want to do or can do. Attached below is a link to the map that babylon uses to replace html attributes and a screen shot of console output.

https://github.com/babel/babylon/blob/master/src/plugins/jsx/xhtml.js

screen shot 2016-08-08 at 8 39 21 pm
Chun-Yang commented 8 years ago

@martinbee Thank you for looking into this. It would be ideal if we can pass in some options into babylon so that it preserve this keyword. Let's see what we can do.