Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old Yesterday, 11:23 PM   #16
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,970
Karma: 7518950
Join Date: Nov 2009
Device: many
I am confused. That was the point of the requested change for "Mend and Prettify", ie. that it check for well-formed before running it. It forces people to not run that command until after the source is well-formed. So just Mend or hand fixing until well formed, then running Prettify.

"Mend and Prettify" is actually not two different steps. It parses any xhtml using gumbo (whatwg) and the when serializing the DOM tree back to xhtml, it does the prettify part.

The actual name of the command indicates how it works (ie it runs the gumbo repair parser then when serializing it back it does the prettify part. Normally that is safe but as you saw it can cause issues when attributes are not properly quoted, and since Prettify changes whitespace wholesale, it can be a bit disruptive at times.

So Mend vs Mend and Prettify are two different commands that each first parse the xhtml using a repair/whatwg parser then just serialize the DOM tree in different ways. The latter has never been running Mend first then Prettify.

Last edited by KevinH; Today at 12:22 AM.
KevinH is offline   Reply With Quote
Old Today, 12:43 AM   #17
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: 54,060
Karma: 182150335
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
I may have misunderstood but I was under the impression that Mend and Prettify ran mend and then prettify. By the evidence, Mend and Prettify does not run Mend and then Prettify and so it is useless to me. I ended up renaming the option to Prettify only since that change helps to remind me to run it only if the ePub does not need mending. I would suggest removing the Mend portion of the option and having only Prettify as the label. I also note that Mend & Prettify still has the P underlined and Mend has the M underlined as though there were keyboard shortcuts for them.
DNSB is offline   Reply With Quote
Old Today, 12:58 AM   #18
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,970
Karma: 7518950
Join Date: Nov 2009
Device: many
Mend and Prettify effectively still does a "mend" (ie parses using the whatwg gumbo parser) but if well-formed first the parser makes no changes, so just the serialization of the parsed DOM tree will make changes.

I am happy to rename Mend and Prettify with just Prettify, but the parsing step will still need to be done by gumbo. It is inherent in how Prettify is done.
KevinH is offline   Reply With Quote
Old Today, 02:55 AM   #19
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: 54,060
Karma: 182150335
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Since Mend & Prettify fails on a missing DOCTYPE in one file and makes no changes to any files, I really don't consider it as doing a mend. If I click on the Mend, the missing DOCTYPE is inserted and then Prettify (AKA Mend & Prettify) will work to prettify the ePub.

Basically to me, if Mend & Prettify will only work on a ePub that does not need mending, it is not Mend & Prettify, it is just Prettify with a longer name.
DNSB is offline   Reply With Quote
Old Today, 11:33 AM   #20
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,970
Karma: 7518950
Join Date: Nov 2009
Device: many
Which was the exact feature requested in this thread. So I can either revert that change and leave Sigil as it has worked for years, or keep that change and rename that menu item to just Prettify.

Which do people want?
KevinH is offline   Reply With Quote
Old Today, 12:00 PM   #21
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: 54,060
Karma: 182150335
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Since my original complaint was about an single ePub where Mend & Prettify mucked up the file, I see the point in no longer allowing Mend & Prettify to run on a file with errors. OTOH, since running any of epubcheck/epubveri/well-formed showed those errors as did opening in Preview, I've changed my workflow to ensure an error checker is run before doing a Mend & Prettify which I must admit was mostly used to automatically fix the missing DOCTYPEs.

I ran well-formed check, epubcheck and epubveri on a ePub3 file with a missing DOCTYPE and none showed an error.

Since the alternative of running Mend will cause the same issue as running Mend & Prettify, I would vote for reverting the change with perhaps a mention in the User Guide about potential issues though it already mentions checkpointing before/after though that seems more about the white space changes.

Last edited by DNSB; Today at 01:27 PM. Reason: Added comment about error-checking and DOCTYPE
DNSB is offline   Reply With Quote
Old Today, 12:09 PM   #22
BeckyEbook
Wizard
BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.
 
BeckyEbook's Avatar
 
Posts: 1,019
Karma: 3761621
Join Date: Jan 2017
Location: Poland
Device: Various
There must be more to it… After all, the DOCTYPE is just a minor detail; there must be something worse going on.

And what does the "Well-Formed Check EPUB" (F7) say?

Please try another test:
  • Take your already-processed file, with the DOCTYPE and everything else perfect.
  • Run "Mend and Prettify."
  • Does it work? OK, let's move on.
  • In one of the XHTML files, remove the DOCTYPE.
  • Run "Mend and Prettify."
  • Does it work? It does for me.

---

I don’t want to make life difficult for anyone or change the habits users have developed over the years while working with Sigil.
For me, this extra safeguard is useful, and even if it’s removed, I can still add it to my build.
BeckyEbook is online now   Reply With Quote
Old Today, 01:15 PM   #23
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: 54,060
Karma: 182150335
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
I'll give it a try.
  • Opened a known good ePub. Well-formed, epubcheck and epubveri showed no issues.
  • Ran Mend and Prettify. Pretty Printing windows popped up and ran.
  • Removed DOCTYPE from 1 file. Mend and Prettify popped up the error window listing that file. See attached image.
  • Removed DOCTYPE from 2 more files. The error window mentioned the first file. The popup was identical.
  • Ran Mend. The 3 missing DOCTYPEs were restore and M&P ran.

Well-formed check, epubcheck and epubveri did not show any errors for the missing DOCTYPE which is correct since ePub3 does not require the DOCTYPE. Ghod alone knows where Sigil is picking it up as an error.

Hmmm... latest code from GitHub, Python 3.14.6, Qt 6.10.2, Microsoft (R) C/C++ Optimizing Compiler Version 19.51.36252 for x64
Attached Thumbnails
Click image for larger version

Name:	Screenshot 2026-08-27 100707.png
Views:	6
Size:	17.4 KB
ID:	225475  

Last edited by DNSB; Today at 01:28 PM. Reason: Added well-formed, epubcheck & epubveri bit
DNSB is offline   Reply With Quote
Old Today, 02:39 PM   #24
BeckyEbook
Wizard
BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.
 
BeckyEbook's Avatar
 
Posts: 1,019
Karma: 3761621
Join Date: Jan 2017
Location: Poland
Device: Various
You're right! I've modified this commit so much that it works differently for me than the official version from the master branch.

I hope I can come up with changes that will satisfy everyone, because the current version is way too strict about ensuring the files are correct before Prettify.
BeckyEbook is online now   Reply With Quote
Old Today, 03:32 PM   #25
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,970
Karma: 7518950
Join Date: Nov 2009
Device: many
Well having a doctype was required for epub2 to allow for named entities. For epub3 the doctype is still required for the spec case and I believe that epubcheck has a long standing bug about not requiring it. Only html allows it to be skipped. Sigil will always treat missing doctype as a error for both epub2 and epub3. Sigil also requires the xml header as well. Neither of those are changing. Calibre simply cares less about doctypes and epubcheck and spec meeting than Sigil, as that has always been Kovids view and why calibre has its own check function.

I am travelling now but upon my return I will simply revert this change, and we will go back to how it has worked for years. Sigil will continue to require the doctype as the original epub3 spec clearly required it for xhtml no matter what epubcheck does. Only html said it was optional.

Last edited by KevinH; Today at 03:35 PM.
KevinH is offline   Reply With Quote
Old Today, 04:02 PM   #26
BeckyEbook
Wizard
BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.
 
BeckyEbook's Avatar
 
Posts: 1,019
Karma: 3761621
Join Date: Jan 2017
Location: Poland
Device: Various
Wait! Take a look at this solution.
I hope it will suit everyone involved. If not – OK, just pull your commit entirely.

If we don’t use the main FileIsWellFormed but instead use the existing GumboWellFormedErrorForSource, then IMHO we get exactly what we expected:
* important issue like the DOCTYPE gets fixed either way
* but if there’s some strange markup or a problem like the one in the first post – we see the message

@DNSB: Check for yourself if it’s really that bad.
Attached Files
File Type: zip pret-patch.zip (1.0 KB, 0 views)
BeckyEbook is online now   Reply With Quote
Old Today, 04:40 PM   #27
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,970
Karma: 7518950
Join Date: Nov 2009
Device: many
I will not be able to examine or test this for a few weeks. But upon my return if you both agree and if it works as expected, and both think this is better than reverting, I will include it along with a name change to just Prettify.
KevinH is offline   Reply With Quote
Old Today, 05:52 PM   #28
rkomar
Wizard
rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.
 
Posts: 3,130
Karma: 18963119
Join Date: Oct 2010
Location: Sudbury, ON, Canada
Device: PRS-505, PB 902, PRS-T1, PB 623, PB 840, PB 633
Maybe rename it to "Mend if possible, and if so, Prettify"
rkomar 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 06:31 PM.


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