rennat / pynliner

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

Add ability to preserve html entities through pynlining process #45

Closed rennat closed 7 years ago

rennat commented 8 years ago

This adds a new preserve_entities keyword argument to pynliner, for both instances and shortcut methods.

Options for preserve_entities are True and False. As of now we assume if you don't tell us, you mean True (this may change before this PR lands.)

BeautifulSoup4 converts all entities to Unicode with no option to prevent it. This means to preserve entities we must first swap them for placeholders then put them back. This introduces 2 more regular expression substitution searches which doesn't help the run speed at all. However, It does set up a substitution system which can be the basis for handling some templating languages in the future (maybe).

I'm going to let this mellow until I'm less sleep deprived. Feel free to add comments/suggestions/insults but I'm particularly interested in contributions in the form of test cases.

listen5k commented 8 years ago

Nice. Looking forward for this being landed.