Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old Today, 03:05 PM   #1
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
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>
After Mend and Prettify, the lines read:
Code:
  <p>This is a <span class="bold&gt;test line&lt;/span&gt; with a missing " after="" the="" bold.=""></span></p>
  <p>This is a <span class="bold"">test line</span> with a missing " before the bold.&gt;</p>
The whole ePub was full of similar items since the author manually added most of the spans in violation of common sense.
DNSB is offline   Reply With Quote
Old Today, 03:54 PM   #2
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
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.
KevinH is offline   Reply With Quote
Advert
Old Today, 04:01 PM   #3
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
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
Unfortunately, I did not design the whatwg/gumbo parser but it seems that missing quotes in attribute names is not a common enough occurence to create a better self mend process probably because real html does not need attributes to have quotes or even have any value.

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.
Attached Thumbnails
Click image for larger version

Name:	Screenshot 2026-08-19 at 4.00.01 PM.png
Views:	4
Size:	49.4 KB
ID:	225266  

Last edited by KevinH; Today at 04:10 PM.
KevinH is offline   Reply With Quote
Old Today, 04:14 PM   #4
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
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.
DNSB is offline   Reply With Quote
Old Today, 05:37 PM   #5
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
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.
DiapDealer is offline   Reply With Quote
Advert
Old Today, 05:49 PM   #6
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
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.
KevinH is offline   Reply With Quote
Old Today, 05:58 PM   #7
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 29,670
Karma: 212352863
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by KevinH View Post
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?
It very well could be the html5lib parser now that you mention it.
DiapDealer is offline   Reply With Quote
Reply


Forum Jump

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


All times are GMT -4. The time now is 10:20 PM.


MobileRead.com is a privately owned, operated and funded community.