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

  in odd places appears as text #33

Open
omarshammas opened this issue Sep 19, 2013 · 5 comments
Open

  in odd places appears as text #33

omarshammas opened this issue Sep 19, 2013 · 5 comments

Comments

@omarshammas
Copy link

Again I'm dealing with some pretty bad code, and really pushing the limits of the library.

The following

<br>&nbsp;

gets converted to

= succeed "&amp;nbsp;" do
  %br/

I would have assumed it would result in

%br
&nbsp;

The current setup cause nbsp to appear as text in the html.

@omarshammas
Copy link
Author

Actually it appears that whenever there is text at the end of some html element it is used as the succeed statement.

For example, this line caused the same error.

<a href="http://example.com/">Look here</a> come on.

And below is the corresponding haml.

= succeed "come on." do
  %a{href: "http://example.com/"} Look here

However one would expect

%a{href: "http://example.com/"} Check me out
come on.

@snatchev
Copy link
Member

snatchev commented Oct 7, 2013

@omarshammas I am not able to reproduce this.
With html2haml versions 1.1 and 2.0.0.beta:

$> echo '<a href="http://example.com/">Look here</a> come on.' | html2haml -e
%a{:href => "http://example.com/"} Look here
come on.

Which version of the library are you using?

@ffloyd
Copy link
Contributor

ffloyd commented Oct 7, 2013

Maybe it's connected with Nokogiri::XML parser. When html2haml prefers XML parser to Nokogiri::HTML then strange errors may appear.

@snatchev
Copy link
Member

Very likely. Generally, the rule is if Nokogiri's HTML parser produces some error codes, it will try to use the XML parser which is more forgiving. This works well on things like partials and other HTML fragments, and not entire HTML documents.

I'm not entirely sure how to proceed with this issue, but I will leave it open.

@omarshammas
Copy link
Author

Hey guys, sorry it was such a long time ago I don't even remember how I came across this error.

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

No branches or pull requests

3 participants