Closed paulmsmith closed 11 years ago
I've committed a possible fix to a branch. Please try it out and let me know how you get on! You'll need to put this in your Gemfile
:
gem "htmlbeautifier", git: "https://github.com/threedaymonk/htmlbeautifier.git", branch: "ie-cc"
Brilliant and thank you for the swift response. That is vast improvement! Ace!
I'm planning on releasing a framework for front-end development based on middleman with your gem as a requirement.
If you have anymore spare time bud. I wonder if you can fix this? Maybe not, I'm not sure as I have a broken understanding of how you clever chaps write gems and require in other libs, etc. So this might be out of your hands.
Now that its ignoring the conditional comments the indentation is much better however because the conditional comments I'm using (as per HTML5 Boiler plate) are essentially wrapping the HTML element in a comment. I think the tidy/html-parser is tripping up and doesn't know how to handle the remaining indentation....it does a decent enough job but I'm assuming once it's gone ary with that HTML tag it doesn't know where things should stop being indented.
See this mark-up - before and after.
Original: https://gist.github.com/paulmsmith/85d9758341ed849e2512 Beautified: https://gist.github.com/paulmsmith/541a297ef294a3ed6ef1
Notice how the beautified mark-up is nice and tidy but not quite indented correctly. It would be amazing if that was fixed/resolved.
What its doing now is a brilliant improvement but thought I'd ask. Thanks again for the super fast turn around on this!
From a brief look at that, it appears to me that the incorrect nesting is happening due to standalone tags like <meta ...>
. Do you concur? There is a solution to that, I think, but I don't think it's quick. I wrote the code with the assumption that it would be used with XHTML. To handle <meta ...>
without a final />
, the parser would need to know which tags can be standalone and to handle them separately.
Ah you might be right sir. Maybe one for your to-do list if you ever get the time or motivation. I can change my mark-up so its XHTML style for now.
Thanks again for the response and the gem.
Just confirm, updating the mark-up to XHTML style self closing tags has corrected things. I actually prefer that style of mark-up anyway, just when using code completion in certain editors it doesn't always do it.
That's good to hear. I think I'll close this issue, then; please do open an issue for non-XHTML self-closing tag support if you think it would be useful.
Hi,
Love this gem. Really simple to use. I'm bolting on to Middleman, at the end of its build I run this on all the HTML Files. Works a treat apart from when it hits IE-Conditional comments.
This:
becomes:
Anyway to have it ignore/skip conditional comments? I'm not a ruby dev otherwise I'd have tried patching myself.