![]() |
#16 |
Banned
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 272
Karma: 1224588
Join Date: Sep 2014
Device: Sony PRS 650
|
Its not only the PreserveAspectRatio but the viewbox <=> viewBox) attribute true. If i'm changing them back to mixed case after the plugin run its fine again.
While developing and testing i rembered that i've had too look/search the attrubutes they were already in lower case, so i guess its more the soup and not the serialize call. |
![]() |
![]() |
![]() |
#17 |
Banned
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 272
Karma: 1224588
Join Date: Sep 2014
Device: Sony PRS 650
|
Turning on debugmode in the plugin:
Code:
{'height': '100%', 'version': '1.1', 'xmlns:xlink': 'http://www.w3.org/1999/xlink', 'xmlns': 'http://www.w3.org/2000/svg', 'width': '100%', 'viewbox': '0 0 600 800', 'preserveaspectratio': 'xMidYMid meet'} |
![]() |
![]() |
Advert | |
|
![]() |
#18 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,360
Karma: 203720150
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Yes, I have a feeling our sigil_bs4 will need to be made aware of those few, special, case-sensitive attributes.
|
![]() |
![]() |
![]() |
#19 |
Banned
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 272
Karma: 1224588
Join Date: Sep 2014
Device: Sony PRS 650
|
Here is the proof:
Code:
html = soup.serialize_xhtml() html = html.replace('viewbox', 'viewBox') html = html.replace('preserveaspectratio', 'preserveAspectRatio') On one hand its fine you found the root cause, on the other hand its a pity it has nothing to with the ignorance of changes sometimes. I will publish a workaround for this til the new version is out and maybe its a good idea to move the thread to the plugin subforum. Last edited by rubeus; 01-24-2016 at 02:49 PM. |
![]() |
![]() |
![]() |
#20 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,487
Karma: 5703586
Join Date: Nov 2009
Device: many
|
Wow! Good catch. Yes, The svg attributes are case sensitive but most serializers will lowercase them. Gumbo handles this right but it looks like either bs4 or lxml or whatever is not setting them properly. I will take a look at it. We can always fix this in bs4 if it turns out to be the issue.
Kevin |
![]() |
![]() |
Advert | |
|
![]() |
#21 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,487
Karma: 5703586
Join Date: Nov 2009
Device: many
|
I see from your plugin you are just using the default parser for soup. You may want to set it to either use gumbo or html5lib and see if they are better about keeping the case of attributes.
|
![]() |
![]() |
![]() |
#22 |
Banned
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 272
Karma: 1224588
Join Date: Sep 2014
Device: Sony PRS 650
|
html5lib is tampering the doctype and gumbo is producing a runtime error that it cant be found
|
![]() |
![]() |
![]() |
#23 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,487
Karma: 5703586
Join Date: Nov 2009
Device: many
|
You use the gumbo_bs4_adapter.py not soup directly. I will run a test to see how it handles it.
Here is an example of using it: Code:
# examples for using the bs4/gumbo parser to process xhtml import sigil_bs4 import sigil_gumbo_bs4_adapter as gumbo_bs4 samp = """ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml/" xml:lang="en" lang="en-US"> <head><title>testing & entities</title></head> <body> <p class="first second">this is the <i><b>copyright</i></b> symbol "©"</p> <p xmlns:xlink="http://www.w3.org/xlink" class="second" xlink:href="http://www.ggogle.com">this used to test atribute namespaces</p> </body> </html> """ soup = gumbo_bs4.parse(samp) for node in soup.find_all(attrs={'class':'second'}): print(node) print(soup.serialize_xhtml());” Last edited by KevinH; 01-24-2016 at 05:28 PM. |
![]() |
![]() |
![]() |
#24 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,487
Karma: 5703586
Join Date: Nov 2009
Device: many
|
Hi rubeus,
Don't bother testing with sigil gumbo_bs4. It has two typos which I just now fixed that prevent it from working with foreign namespaced attributes well. Once I did fix those typos and adjusted your AdjustSVG code to use it, it worked like a charm. The correct SVG attribute names (mixed case) were used. So the bug is not in sigil_bs4. It just serializes what it is given. The bug is in the default "html" parser which incorrectly changed the case of the svg attributes (and maybe even tag names). It is not properly keeping the mixed case attribute names. Once fixed, sigil_gumb_bs4_adapter works correctly with no changes in sigil_bs4. If BS4 with html5lib messes with your doctype (that is strange), the only solution is to do what you are doing now and fix them after the fact using a regular expression replacement to make sure they are inside tags and not just a word in the text. Or alternatively strip off the doctype pass it to html5lib to parser and fix and then put it back at the end. When Sigil-0.9.3 is released, I can post the adjusted code for using it which has no need of changing the attribute names after the fact. Take care, KevinH |
![]() |
![]() |
![]() |
#25 |
Banned
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 272
Karma: 1224588
Join Date: Sep 2014
Device: Sony PRS 650
|
The replace method was only a quick proof of concept. It is unlikely that there other words like viewBox or presereAspectRatio are used, but Murphy tells us that this wont happen if you take care of, the probability will raise to 100% if you dont take care of
![]() |
![]() |
![]() |
![]() |
#26 | |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,912
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
![]() |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
epubcheck plugin for Sigil | Doitsu | Plugins | 539 | 04-19-2025 08:45 AM |
[Plugin] ePub3-itizer - epub3 output plugin for Sigil | KevinH | Plugins | 456 | 10-27-2024 06:00 AM |
icarus Sigil plugin | AlPe | Plugins | 26 | 12-05-2017 10:03 AM |
smoothRemove_v010 plugin for Sigil | kbanelas | Plugins | 15 | 01-27-2017 05:51 PM |
How do I change Plugin Images/Icons? | Steppa | Plugins | 8 | 01-22-2013 06:37 PM |