rennat / pynliner

Python CSS-to-inline-styles conversion tool for HTML using BeautifulSoup and cssutils
http://pythonhosted.org/pynliner/
181 stars 93 forks source link

Case sensitivity issues #1

Closed rogerhu closed 8 years ago

rogerhu commented 13 years ago

While using Pynliner with the Hudson html.jelly file to do inline CSS styles, I found a bunch of issues using it with this file, most notably the BODY and TD.bg1 tags (the HTML itself had lowercase tags). Some styles were not added as a result of these case sensitivity mismatches.

http://fisheye.hudson-ci.org/browse/Hudson/trunk/hudson/plugins/email-ext/src/main/resources/hudson/plugins/emailext/templates/html.jelly?r=HEAD

I believe I was able to correct it with the following changes and commands: import pynliner p = pynliner.Pynliner().from_string(open("html.jelly", "r").read()) open("/tmp/html_gmail.jelly", p.run(prettify=True))

To get the multiple CSS styles to appear on the same line, I also manually overrode the getCssText and passed in a separator ' ' for the correct output.

rennat commented 13 years ago

Thanks for the patch @rogerhu as soon as I have time to look it over I'll pull it into master.

rennat commented 13 years ago

Hey rogerhu sorry it's taken me so long to look at the patch. It needs to be revised before I pull it in. According to the W3C HTML 4 specification class and id names are case-sensitive.

As for element case-sensitivity, the W3C CSS2 specification says that in HTML the element selector is case-insensitive and in XHTML the selector is case-sensitive. This was not considered during my initial coding as I worked almost exclusively with XHTML.

It would be ideal to check for this and then enable/disable case-sensitivity according to document type. However, until this is done I believe we must treat all documents as case-sensitive. I'm open for debate tho.

rogerhu commented 12 years ago

Took me a year to get back to you. :) I've put an option now for case sensitivty and repatched things. You can review the individual commits too to see what else got changed.

rennat commented 11 years ago

I like the direction you headed with it. I already merged in changes from the @philipkimmey and that introduces some merge conflicts, can you merge the new master in and resolve the conflicts?

rennat commented 8 years ago

closing stale pull request