|
|
#1 |
|
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 53,895
Karma: 182150167
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Oddity in Mend and Prettify
I was looking at an epub for another person who was running into errors and ran into an oddity using Mend and Prettify.
An example is one line originally has a missing " after the bold while another had a missing " before the bold: Code:
<p>This is a <span class="bold>test line</span> with a missing " after the bold.></p> <p>This is a <span class=bold">test line</span> with a missing " before the bold.></p> Code:
<p>This is a <span class="bold>test line</span> with a missing " after="" the="" bold.=""></span></p> <p>This is a <span class="bold"">test line</span> with a missing " before the bold.></p> |
|
|
|
|
|
#2 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,951
Karma: 7500000
Join Date: Nov 2009
Device: many
|
Yes, Xhtml spec requires all attributes to be quoted - either with single or double quotes.
If they had run Sigil's well formed check, it should detect things like unopened or unclosed attributes and warned them but sometimes if a suitable quote is found "nearby", even that gets confused. The missing end quote means the attribute value actually encompassed the closing > and converted it to & lt ; to prevent its loss since > are not allowed inside attribute quoted strings without them being xml encoded. It repeated that and converted bare text to attributes and ended that attribute later. The missing quotes around an attribute are really hard to detect at times and this was one of them. Luckily, all text has been either encoded, made into empty attributes or saved in some way. So you can fix it by hand. That said, gumbo follows the same whatwg spec for xhtml so Preview was seeing that code and internally doing pretty much the same thing as gumbo showed. Please try Sigil's built in well formed check or epubcheck on the initial broken attribute code to see if either would better warn you of the breakage properly. Last edited by KevinH; Today at 04:14 PM. |
|
|
|
| Advert | |
|
|
|
|
#3 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,951
Karma: 7500000
Join Date: Nov 2009
Device: many
|
Actually, I tested your example and Preview clearly shows the following error message.
So Preview is interpreting that text the exact same way gumbo did in Mend and Prettify. And Sigil's well formed check detected the missing unclosed attribute value and the Validation window showed: Code:
Section0001.xhtml Line 11: Offset N/A Message: Attribute "class" has unmatched quotes on attribute value. near column 15 Not much I can do here. Both Preview and Sigil's own Well-formed check indicate there is a problem and Sigils' own well-formed check even correctly identifies what is wrong. In general making sure everything is well formed and that Checkpoints are made before running Mend or Mend and Prettify or any Sigil Tool is probably the best approach. Last edited by KevinH; Today at 04:10 PM. |
|
|
|
|
|
#4 |
|
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 53,895
Karma: 182150167
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Any of well-formed check, epubcheck or epubveri options works to warn me of the errors.
I triggered the issue when the original ePub did not believe in line breaks so each file was a solid mass of text and I pretty-printed it using mend and prettify from the Tools menu. I dumped that version, reopened the original and pretty-printed it. After that, I ended up using search/replace & regex to do most of the cleanup to get the book ready to be published. The author couldn't remember which web page she used to do the AI assisted conversion from her word processor file to ePub but will not use it again. |
|
|
|
|
|
#5 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 29,670
Karma: 212352863
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
I'm fairly certain that BeautifulSoup can correct mismatched and/or missing attribute quotes by parsing and re-serializing. If so, a plugin to correct something like this shouldn't be terribly difficult.
|
|
|
|
| Advert | |
|
|
|
|
#6 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,951
Karma: 7500000
Join Date: Nov 2009
Device: many
|
Certainly worth a shot. We could include it as python3lib code and run it before every Mend and Prettify. But I did not think BS4 when using the lxml parser for xml/xhtml did that? Maybe only the html5lib parsing then reserializing as xhtml?
Last edited by KevinH; Today at 05:51 PM. |
|
|
|
|
|
#7 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 29,670
Karma: 212352863
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
It very well could be the html5lib parser now that you mention it.
|
|
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Mend and Prettify frequently fails to run after splitting a file in v2.8.0 | byword | Sigil | 10 | 07-05-2026 08:38 PM |
| Disappointed with 'Mend and Prettify' when <table>'s included. | philja | Sigil | 9 | 12-11-2025 08:38 PM |
| About "Mend and Prettify Code" | RbnJrg | Sigil | 1 | 10-06-2025 07:12 PM |
| Sigil Prettify Code | iMilazzo | Sigil | 26 | 05-12-2025 10:09 AM |
| Prettify HTML questions | n9qqk | Sigil | 13 | 03-06-2018 12:47 PM |