Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Sigil > Plugins

Notices

Reply
 
Thread Tools Search this Thread
Old 04-14-2026, 04:47 PM   #16
BeckyEbook
Guru
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: 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:

Code:
<?xml version="1.0" encoding="utf-8"?>











<!DOCTYPE html>

 
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops"> 
<head> 
  <title>test</title>




  <link href="../Styles/style.css" type="text/css" rel="stylesheet"/>




  <style></style>
 </head>
 

<body>
 

  <h1>Chapter</h1>

 
  <p>*</p>

 
  <table><thead> 
      <tr> 
        <th>sample text</th>
 
        <th>sample text</th>
 
        <th>sample text</th>
 
        <th>sample text</th>
       </tr>
     </thead><tbody> 
      <tr style="color: blue;"> 
        <td>sample text</td>
 
        <td>sample text</td>
 
        <td>sample text</td>
 
        <td>sample text</td>
       </tr>
 
      <tr> 
        <td>sample text</td>
 
        <td>sample text</td>
 
        <td style="color:red;">sample text</td>
 
        <td>sample text</td>
       </tr>
 
      <tr> 
        <td>sample text</td>
 
        <td class="big">sample text</td>
 
        <td>sample text</td>
 
        <td>sample text</td>
       </tr>
     </tbody><tfoot> 
      <tr> 
        <td colspan="4">sample text</td>
       </tr>
     </tfoot></table>
 
</body>
 </html>



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>
BeckyEbook is offline   Reply With Quote
Old 04-14-2026, 04:59 PM   #17
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,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.
KevinH is offline   Reply With Quote
Old 04-14-2026, 05:04 PM   #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,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.
KevinH is offline   Reply With Quote
Old 04-14-2026, 05:18 PM   #19
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,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.
Attached Files
File Type: zip PrettyPrinter_v040.zip (14.8 KB, 17 views)
KevinH is offline   Reply With Quote
Old 04-14-2026, 05:28 PM   #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,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.
KevinH is offline   Reply With Quote
Old 04-14-2026, 05:28 PM   #21
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,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.
DiapDealer is offline   Reply With Quote
Old 04-14-2026, 05:42 PM   #22
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: 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.
DNSB is offline   Reply With Quote
Old 04-14-2026, 05:51 PM   #23
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,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.
KevinH is offline   Reply With Quote
Old 04-14-2026, 06:02 PM   #24
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,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.
KevinH is offline   Reply With Quote
Old 04-14-2026, 07:06 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,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.
KevinH is offline   Reply With Quote
Old 04-14-2026, 07:56 PM   #26
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,518
Karma: 212177546
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by KevinH View Post
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.
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.
DiapDealer is offline   Reply With Quote
Old 04-15-2026, 02:29 AM   #27
BeckyEbook
Guru
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: 988
Karma: 3600000
Join Date: Jan 2017
Location: Poland
Device: Various
Quote:
Originally Posted by KevinH View Post
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.

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.
BeckyEbook is offline   Reply With Quote
Old 04-15-2026, 08:33 AM   #28
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,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.
KevinH is offline   Reply With Quote
Old 04-15-2026, 03:09 PM   #29
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,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.
Attached Files
File Type: zip PrettyPrinter_v042.zip (15.0 KB, 16 views)
KevinH is offline   Reply With Quote
Old 04-15-2026, 08:27 PM   #30
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: 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>
It seems that spaces before the <i> and after the </i> are being removed. The same happens with <b> and </b>.

Last edited by DNSB; 04-15-2026 at 08:30 PM.
DNSB is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

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


All times are GMT -4. The time now is 12:27 PM.


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