Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old Yesterday, 06:37 PM   #1
RelUnrelated
Member
RelUnrelated is on a distinguished road
 
RelUnrelated's Avatar
 
Posts: 20
Karma: 64
Join Date: Apr 2014
Location: Homer, Illinois, US
Device: Kindle Paperwhite 2
[Plugin] sprucer: Semantic (X)HTML Formatter

Hi everyone,

I'm happy to share a new Sigil plugin I've been working on called sprucer.

sprucer is a custom plugin designed to rearrange the (X)HTML within an EPUB file so that it is displayed in a way that more accurately depicts its semantic structure, strictly enforcing W3C standards.

Key Features:
  • Custom Formatting Engine: Normalizes the document and rebuilds the indentation and line breaks based on the structural hierarchy of the tags.
  • User Configuration UI: Includes a graphical settings menu that allows you to toggle between spaces or literal tabs, and adjust the indentation multiplier from 1 to 8 characters per level.
  • Sensitive Block Preservation: Safely isolates and perfectly preserves literal <pre>, <style>, and <script> blocks to prevent any layout corruption during the formatting process.

Installation:
  1. Download the attached sprucer.zip file at the bottom of this post. (Do not unzip this file).
  2. Open Sigil and go to Plugins > Manage Plugins.
  3. Click the Add Plugin button on the right side of the panel.
  4. Navigate to and select the downloaded ZIP file.
  5. Click Yes to accept the security warning and install the plugin.

Note: If you are updating from a previous version in the future, you must remove the old plugin via the Manage Plugins menu before adding the new one.

Usage:
Trigger the plugin via the Plugins > Edit menu, or assign it to a shortcut. A settings window will pop up to grab your preferences (which it remembers for your next session). Click "Run Formatter" to process the files in your open EPUB.

The source code, full changelog, and GPLv3 license are available on my GitHub repository here: RelUnrelated/sprucer.

I hope you find it useful for cleaning up your EPUB structures. Let me know if you run into any issues or have suggestions for future updates!
Attached Files
File Type: zip sprucer_v1.0.0.zip (3.5 KB, 8 views)
RelUnrelated is offline   Reply With Quote
Old Today, 07:21 AM   #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: 10,095
Karma: 7640000
Join Date: Nov 2009
Device: many
Thank you for your contribution. I will add you to our Sigil Plugin Index.

Just like with our built-in Mend and Prettify, please be aware that css white-space properties can be used and set on any tag so that it must be exempted from whitespace changes just like a pre tag would.

Perhaps a warning if that property is used in the css to let users decide how they want to handle that case.
KevinH is offline   Reply With Quote
Old Today, 10:39 AM   #3
RelUnrelated
Member
RelUnrelated is on a distinguished road
 
RelUnrelated's Avatar
 
Posts: 20
Karma: 64
Join Date: Apr 2014
Location: Homer, Illinois, US
Device: Kindle Paperwhite 2
Quote:
Originally Posted by KevinH View Post
Perhaps a warning if that property is used in the css to let users decide how they want to handle that case.
That's an excellent observation. I'll start on the changes for that right away.
RelUnrelated is offline   Reply With Quote
Old Today, 10:53 AM   #4
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: 10,095
Karma: 7640000
Join Date: Nov 2009
Device: many
This plugin has now been added to the Sigil Plugin Index.
KevinH is offline   Reply With Quote
Old Today, 03:34 PM   #5
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,061
Karma: 3999999
Join Date: Jan 2017
Location: Poland
Device: Various
My two cents:
* You can achieve exactly what sprucer does by editing prettyprint.xml
* sprucer removes all non-standard spaces and replaces them with regular ones

This isn't a criticism! I'm happy about every new plugin.
BeckyEbook is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Semantic markup question! graycyn Workshop 79 04-13-2023 05:08 PM
Typo in Set Semantic ? Bertrand Editor 1 04-06-2016 10:24 AM
Understanding html input plugin nimblebooks Conversion 3 02-26-2012 01:06 AM
Plugin not customizable: Plugin: HTML Output does not need customization flyingfoxlee Conversion 2 02-24-2012 02:24 AM
HTML input plugin stripping text within toc tags in child html file nimblebooks Conversion 3 02-21-2012 03:24 PM


All times are GMT -4. The time now is 04:28 PM.


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