|
|
#16 |
|
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 988
Karma: 3600000
Join Date: Jan 2017
Location: Poland
Device: Various
|
Hmmm… Strange.
Even after applying the patch, this is what it looks like after running the plugin five times. I can see that: a) empty lines are added before the DOCTYPE, link and style tags b) closing block tags have an unnecessary space before them (see e.g. /head, /tr, /html) c) there are no spaces before thead, tbody and tfoot, but this is a minor issue as they can be added to the prettyprinter.pcss file Spoiler:
Another (aesthetic) issue arises when we first run Sigil’s Prettify function and then run the plugin. It then adds unnecessary spaces, resulting in this: Code:
<td> sample text </td> |
|
|
|
|
|
#17 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,727
Karma: 6774572
Join Date: Nov 2009
Device: many
|
Wow, I am not seeing anything like what you and DNSB are seeing on my Mac. I wonder if something related to the differences between newlines and carriage returns is going on?
Very vey strange. There must be something I am missing here. I am going to try your testcase on Linux to see if I see the same thing. |
|
|
|
| Advert | |
|
|
|
|
#18 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,727
Karma: 6774572
Join Date: Nov 2009
Device: many
|
My wag on this is that the code that parses the prettyprinter.pcss code if not able to handle imbedded carriage returns so it is freaking out it.
I will try filtering out carriage returns when the .pcss file is first read in. |
|
|
|
|
|
#19 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,727
Karma: 6774572
Join Date: Nov 2009
Device: many
|
Okay, please give this a try. It removes carriage returns that exist in the .pcss file after reading it in, and then trims out \r as well if they exist in the xhtml source inside the plugin.
|
|
|
|
|
|
#20 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,727
Karma: 6774572
Join Date: Nov 2009
Device: many
|
Okay, I tested the 0.3.5 plugin under Linux and it worked identically to Mac.
So it must be carriage returns being inserted but not trimmed out that are the issue. If need be I can change the plugin to remove all carriage returns from the bk.readfile output. Hopefully I will not need to go that far, and v040 will do the trick. |
|
|
|
| Advert | |
|
|
|
|
#21 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 29,518
Karma: 212177546
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Python's text mode should automatically convert \r\n and \r to single \n characters when reading the file shouldn't it? Then writing would use the system default for the endings. At least that's how I understood Python's universal newline support worked.
Of course none of that probably matters if you need to read the file using binary mode for your plugin code. ![]() EDIT: I was only thinking of the reading of the .pcss file in your plugin code. I forgot that the plugin framework itself reads/writes everything as binary. Last edited by DiapDealer; 04-14-2026 at 05:48 PM. |
|
|
|
|
|
#22 |
|
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 52,519
Karma: 180945220
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
PrettyPrinter v0.4.0 does not seem to be adding the extra blank lines and spaces. I've checked it on ~8 ePubs and looks good.
|
|
|
|
|
|
#23 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,727
Karma: 6774572
Join Date: Nov 2009
Device: many
|
Great!
Thank you for testing and reporting back! Now if someone would show me what they want a table that has been pretty printed to look like. I can tweak the default .pcss to do that. |
|
|
|
|
|
#24 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,727
Karma: 6774572
Join Date: Nov 2009
Device: many
|
I think the issue is that the entire plugin wrapper code always reads in as binary as it can read both binary image files and text files.
The PrettyPrinter plugin only reads in with 'r' and writes with 'w'. At this point I an truly afraid of changing the pluginrunner wrapper.py file as changing it may break lots of existing plugins and I do not want that. Last edited by KevinH; 04-14-2026 at 06:08 PM. |
|
|
|
|
|
#25 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,727
Karma: 6774572
Join Date: Nov 2009
Device: many
|
If after playing with this, people prefer it over the just updated Prettify code built into Sigil, I can easily mothball that code and add the C++ version of the PrettyPrinter code directly to Sigil, eliminating the need for this plugin completely.
Just let me know. Last edited by KevinH; 04-14-2026 at 07:11 PM. |
|
|
|
|
|
#26 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 29,518
Karma: 212177546
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Oh, I agree. I was only thinking of your parsing of the .pcss file. I forgot that the epub's xhtml would have \r\n line endings on Windows (and that wrapper.py would preserve them with it's read/write functions). Most of Sigil's Qt C++ routines guarantee that everything will have \n line endings on all platforms while being manipulated.
|
|
|
|
|
|
#27 | |
|
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 988
Karma: 3600000
Join Date: Jan 2017
Location: Poland
Device: Various
|
Quote:
Although you know how much I love plugins, a global approach will certainly be easier to manage. After all, we’ve got loads of configuration files as it is, so one more – just for those who’re interested – shouldn’t be a problem. But first, let me thoroughly test the plugin on lots and lots of files so we can catch any issues. You know yourself that there have been instances where Prettify messed up valid files, so it’s better to spend even two months testing than to roll out a feature that will perform worse than the existing one. So let’s make sure it’s better by thoroughly testing edge cases. |
|
|
|
|
|
|
#28 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,727
Karma: 6774572
Join Date: Nov 2009
Device: many
|
Sounds good to me. I will keep PrettyPrinter as a plugin until that decision is made.
That said, the old Prettify has not had a bug report against it in a long time. It can now be configured as well. The only way it can hurt html is when people use white-space controlling css *outside* of a pre, script, or style tag which can now be tested for to make things safer. And I actually prefer plugins for adding features as Sigil has reached the point of feature saturation in my humble opinion unless it is a feature that helps the vast majority of users. |
|
|
|
|
|
#29 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,727
Karma: 6774572
Join Date: Nov 2009
Device: many
|
Here is a cleaned up version of the PrettyPrinter_v042.zip which tries to more systematically deal with line terminators.
This will be the hopefully the final version for testing until we decide whether to keep it as a plugin or build it into Sigil proper. |
|
|
|
|
|
#30 |
|
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 52,519
Karma: 180945220
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Minor issue I've found with PrettyPrinter 0.4.2
Code:
<p class="para"><b>Digi Dareel</b>—The young heir of Clan Harzi, Rogh and Asali’s oldest daughter, a shrewd and capable leader. She acts as an <i>orsi</i>, the <i>tair’s</i> representative in Kair Toren.</p> <p class="para"><b>Digi Dareel</b>—The young heir of Clan Harzi, Rogh and Asali’s oldest daughter, a shrewd and capable leader. She acts as an<i>orsi</i>, the<i>tair’s</i>representative in Kair Toren.</p> Last edited by DNSB; 04-15-2026 at 08:30 PM. |
|
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Assess if a pdf file is editable | RotAnal | Plugins | 3 | 06-06-2018 06:54 PM |
| Where to put userStyle.css? | GeoffR | Kobo Reader | 15 | 04-06-2013 04:57 PM |
| User-Editable HTML in Templates? | marcot | Calibre | 0 | 06-15-2010 09:19 AM |