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

html2haml: improper indentation of meta tags #14

Open
mattwildig opened this issue Oct 7, 2012 · 2 comments
Open

html2haml: improper indentation of meta tags #14

mattwildig opened this issue Oct 7, 2012 · 2 comments

Comments

@mattwildig
Copy link
Contributor

(Originally reported by @DanielKehoe at haml/haml#588)

I'm using html2haml.

If I start with a self-closing meta tag:

<meta name="description" content=""/>

I get

%meta{:content => "", :name => "description"}/

with a superfluous trailing forward-slash.

If I start with no self-closing meta tag:

<meta name="description" content="">

I get improperly indented Haml:

%html
  %head
    %meta{:charset => "utf-8"}
      %meta{:content => "IE=edge,chrome=1", "http-equiv" => "X-UA-Compatible"}
        %meta{:content => "width=device-width, initial-scale=1.0", :name => "viewport"}
          %title= content_for?(:title) ? yield(:title) : "Folio"
          %meta{:content => "", :name => "description"}
            %meta{:content => "", :name => "author"}
              = stylesheet_link_tag    "application", :media => "all"
              = javascript_include_tag "application"
              = csrf_meta_tags
              = yield(:head)

Can we get this fixed for proper indentation when the meta tags are not self-closing?

Or is this my error?

@norman
Copy link
Contributor

norman commented Feb 16, 2013

I've attempted to reproduce this and it seems to come from using the -x flag which causes html2haml to parse the document as XHTML. If you don't close the meta tags in this case, it will assume the following tags are nested under the meta tag but not indented.

To fix this, when html2haml is treating a document as HTML rather than XML, we should should self-close the tags with the trailing "/" only if the tag closes itself in the source document.

@norman
Copy link
Contributor

norman commented Feb 16, 2013

Note that this is already partially fixed in the Nokogiri branch - the trailing slashes are still there but the tags aren't nested incorrectly as they are with the current Hpricot-based master branch.

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

2 participants