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

Style not being applied when multiple elements have same class/Id and same content #49

Closed dikesh closed 8 years ago

dikesh commented 8 years ago

I am facing some weird issue when using pynliner.fromString(htmlString). When multiple elements have same class/Id, it fails to apply CSS rules to all elements except the first one. Here is the sample code with expected output and actual output.

<style>
    .text-right {
        text-align: right;
    }
    .box {
        width:200px;
        border: 1px solid #000;
    }
</style>
<div class="box">
    <p>Hello World</p>
    <p class="text-right">Hello World on right</p>
    <p class="text-right">Hello World on right</p>
</div>

Expected Output: image

Actual Output: image

rennat commented 8 years ago

That is indeed odd. I'll be able to devote some time to this pynliner within a few days and I'll check on this issue

On Fri, Aug 12, 2016, 1:39 AM Dikesh notifications@github.com wrote:

I am facing some weird issue when using pynliner.fromString(htmlString). In table when multiple cells of same column have repeated values, it fails to apply CSS rules to all cells except the first one. Here is the sample code with expected output and actual output.

Day Part Day of week Conversions CVR
After noon Friday 64 1.2 %
After noon Saturday 58 1.2 %
Morning Saturday 70 1.4 %

Expected Output:

[image: image] https://cloud.githubusercontent.com/assets/1618526/17614615/46ac8ac8-6085-11e6-9d70-116ed5c6d878.png

Actual Output:

[image: image] https://cloud.githubusercontent.com/assets/1618526/17614625/5362ad24-6085-11e6-98e6-99d8a0d02a11.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rennat/pynliner/issues/49, or mute the thread https://github.com/notifications/unsubscribe-auth/AABt9zG-t-nz6TBvlsJG3nSKur7NSuooks5qfBU0gaJpZM4Ji0J2 .

tadonis commented 8 years ago

i just fix this problem in my newest push. This is cause by elem_prop_map[element], element hash by element.string, so only one element's style is inlined of the identical elements set.