|
|
#16 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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. |
|
|
|
|
|
#17 |
|
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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.
|
|
|
|
|
|
#18 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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. |
|
|
|
|
|
#19 |
|
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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. |
|
|
|
|
|
#20 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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? |
|
|
|
|
|
#21 |
|
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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 |
|
|
|
|
|
#22 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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:
--- 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. |
|
|
|
|
|
#23 |
|
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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.
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 Last edited by DNSB; Today at 01:28 PM. Reason: Added well-formed, epubcheck & epubveri bit |
|
|
|
|
|
#24 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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. |
|
|
|
|
|
#25 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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. |
|
|
|
|
|
#26 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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. |
|
|
|
|
|
#27 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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.
|
|
|
|
|
|
#28 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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"
|
|
|
|
![]() |
|
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 |