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 08-10-2017, 09:33 PM   #1
slowsmile
Witchman
slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.
 
Posts: 628
Karma: 788808
Join Date: May 2013
Location: Philippines
Device: Android S5
[Plugin] ConvertAbs2RelCSSValues

Converts cm, mm, inch, pica, point and pixel values to relative 'em' values in the css

Requirements
Plugin Type: Edit
MIT Licence(OSI)
Minimum Sigil requirement: v0.9.3 or higher
Requirements: Python 3.4+ (Bundled or External)
OS Requirements: Windows, Linux or OSX
Current Version: "0.1.8"

Installation
* Select Manage Plugins from the Plugins menu. In the dialog box, select either the Bundled Python or the External Python(Python 3.4+ should be installed on your computer to run this plugin externally).

* Click Add Plugin and select ConvertAbs2RelCSSValues_vXXX.zip. This will load and install the plugin into Sigil, which you can then select and run it using Plugins > Edit > ConvertAbs2RelCSSValues

Description
This is an edit plugin that automatically converts all absolute values such as cm, mm, inch, pica, point and pixel(Added in v10.1.7) values to relative em values in the epub stylesheet(s). Depending on user choice, this plugin will also convert all shorthand forms of "padding" or "margin" to their long forms(see User Options). This plugin can be used for epub v2 and epub v3 files(Added in v1.5).

Examples of the various shorthand forms for 'margin'(it's the same format for 'padding') are shown below:
margin: 0;
margin: 1.5pt 0;
margin 1pt 0pt 1.5pt;
margin 24pt 0pt 12pt 0pt;

The above forms will be converted to the long form. Example shown below:
margin-top: 2em;
margin-bottom: 1.0em;
margin-left: 1.5em;
margin-right: 0em;

The other benefit of converting to the long form is that certain ereaders like the Nook ereader are known to have problems with the shorthand forms of 'margin' and 'padding'. That's why it's much safer to use the long forms -- because using the long forms should never give you any problems on any ereader conversion.

User Dialog
This dialog will ask the user whether or not he/she wants to convert the 'margin' and 'padding' shorthand forms to their long forms. If 'Yes' is chosen then the shorthand forms will all be converted to the long form as before. But if 'No' is chosen then all the shorthand form values will be converted to 'em' values in place.

Plugin Run
First load your epub into Sigil and then just run this plugin.

Caveats
* This plugin will not convert percentage values to 'em' values
* This plugin will not convert 'margin: 0 auto' to the long form.
* Can now convert pixel values to em values in the css(Added in v0.1.7).
* Take note that pixel conversions(Added in v0.1.7) using this plugin will not convert the following CSS class property pixel values to em: height, width, max-width, max-height and border.

In the past I've had several problems with sizing and spacing in my epub after I have converted my ebooks to the vendor format. I've read that some Nook readers have problems with the shorthand forms of both 'padding' and 'margin' properties. I've also had some weird problems using absolute values(e.g. pts, cm, mm, pc, etc) in the CSS with my Kindle conversions. Hopefully this plugin should go some way towards both saving you some time and will also help to alleviate most of these sizing and spacing problems in your epubs.

Update:
* Redesigned the absolute to relative value conversion with better precision.
* Added a dialog to choose whether or not to convert the shorthand margin/padding forms to their long forms.
* The plugin will now also convert all forms of shorthand margin/padding values to em values as well.

Changes
Spoiler:

v0.1.8
-- Fixed some minor issues wrt points and inch conversions.
v0.1.7
-- Fixed inches conversion problem reported by DNSB.
v0.1.6[INDENT]-- This plugin can now process and convert pixels to em values.Thanks to gregorio and Doitsu.
-- The plugin will not convert px to em values if the pixel values are being used within the following class properties: width, height, max-width, max-height and border.
v0.1.5
-- This plugin can now be used for epub v2 and epub v3 files
v0.1.4
-- Now uses a standard tkinter askyesno dialog for the user dialog.
v0.1.3
-- Added MIT Licence
v0.1.2
-- Redesigned the absolute to relative value conversion with better
precision.
-- Added a dialog to choose whether or not to convert the shorthand
margin/padding forms to their long forms.
-- The plugin will now also convert all forms of shorthand margin/padding
values to 'em' values as well.
-- Changed and updated the release notes.
v0.1.1
-- Fixed a bug on conversion with the 'size' property
v0.1.0
-- Initial release
Attached Files
File Type: zip ConvertAbs2RelCSSValues_v018.zip (44.9 KB, 737 views)

Last edited by slowsmile; 03-10-2022 at 09:41 PM.
slowsmile is offline   Reply With Quote
Old 08-13-2017, 12:22 PM   #2
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: 28,038
Karma: 199464182
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Added to the plugin index thread. Thanks for your contribution!
DiapDealer is offline   Reply With Quote
Advert
Old 08-13-2017, 12:56 PM   #3
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 76,333
Karma: 136006010
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
The title of this thread is a tad confusing and I think some may not get it.

Convert Absolute to Relative Values in CSS

would be much easier to understand.
JSWolf is offline   Reply With Quote
Old 08-13-2017, 01:07 PM   #4
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: 28,038
Karma: 199464182
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by JSWolf View Post
The title of this thread is a tad confusing and I think some may not get it.

Convert Absolute to Relative Values in CSS

would be much easier to understand.
The plugin names have ALWAYS been the threads' titles, Jon. Get over it. Use the Plugin Index or the Plugin Description if you need more help "getting it." Those who have a need for such a thing have little trouble understanding.
DiapDealer is offline   Reply With Quote
Old 08-13-2017, 10:41 PM   #5
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 30,441
Karma: 58055868
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
I have wanted that function for quite a while since some publishers still use inches
What do the think they are formatting? Paper?
(Wait, where is my Pica stick)
theducks is offline   Reply With Quote
Advert
Old 08-13-2017, 11:10 PM   #6
slowsmile
Witchman
slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.
 
Posts: 628
Karma: 788808
Join Date: May 2013
Location: Philippines
Device: Android S5
@theducks...Although your comment is quite valid, it's almost a given that some people would not understand what absolute and relative values are when describing css values. Sure a developer or formatter would understand these terms but I've learned from hard experience that if you want lay people(with no html or css knowledge) to use your plugins then you've got to give a simple short description of the plugin for them to fully understand what it actually does. And I think that my description(below the title) does that:

Converts cm, mm, inch, pica and point values to relative 'em' values in the css

Last edited by slowsmile; 08-13-2017 at 11:23 PM.
slowsmile is offline   Reply With Quote
Old 08-13-2017, 11:15 PM   #7
slowsmile
Witchman
slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.
 
Posts: 628
Karma: 788808
Join Date: May 2013
Location: Philippines
Device: Android S5
@DiapDealer....Thanks for that !!
slowsmile is offline   Reply With Quote
Old 09-04-2017, 07:00 AM   #8
slowsmile
Witchman
slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.
 
Posts: 628
Karma: 788808
Join Date: May 2013
Location: Philippines
Device: Android S5
I've changed/upgraded the plugin in the following way:

* Redesigned the absolute to relative value conversion with better precision.

* Added a dialog to choose whether or not to convert the shorthand margin/padding forms to their long forms.

* The plugin will now also convert all forms of shorthand margin/padding values to 'em' values as well.
slowsmile is offline   Reply With Quote
Old 01-27-2022, 04:55 PM   #9
gregorio
Junior Member
gregorio began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Oct 2012
Device: Kobo touch, iPad
Update for EPUB3?

Hi!
Do you happen to have any plans to update this useful plugin for supporting EPUB3?

Thanks,
Gregorio
gregorio is offline   Reply With Quote
Old 01-31-2022, 04:39 AM   #10
slowsmile
Witchman
slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.
 
Posts: 628
Karma: 788808
Join Date: May 2013
Location: Philippines
Device: Android S5
@gregorio...I've already modified the plugin and I'm testing it with epub3 ebooks at the moment. The testing seems to be going well, not many problems so far. I'll get back to you later, if that's OK.

Last edited by slowsmile; 01-31-2022 at 05:01 AM.
slowsmile is offline   Reply With Quote
Old 01-31-2022, 11:54 AM   #11
gregorio
Junior Member
gregorio began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Oct 2012
Device: Kobo touch, iPad
Great! Thank you.
gregorio is offline   Reply With Quote
Old 02-16-2022, 03:53 AM   #12
slowsmile
Witchman
slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.
 
Posts: 628
Karma: 788808
Join Date: May 2013
Location: Philippines
Device: Android S5
Plugin Update(v1.5):
This plugin can now be used with epub v2 and epub v3 files.
slowsmile is offline   Reply With Quote
Old 03-01-2022, 10:12 AM   #13
gregorio
Junior Member
gregorio began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Oct 2012
Device: Kobo touch, iPad
Hi, I'm testing the plugin with an EPUB 3 generated from InDesign, but I'm not sure it is working correctly.

I attach the EPUB test file here.
Attached Files
File Type: epub test.epub (299.0 KB, 269 views)
gregorio is offline   Reply With Quote
Old 03-01-2022, 01:05 PM   #14
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,640
Karma: 23191067
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by gregorio View Post
Hi, I'm testing the plugin with an EPUB 3 generated from InDesign, but I'm not sure it is working correctly.
For some odd reason, the author decided not to convert px values.

Quote:
Originally Posted by slowsmile View Post
Caveats
* This plugin will not convert pixel values or percentage values to 'em' values
Doitsu is offline   Reply With Quote
Old 03-02-2022, 07:35 PM   #15
slowsmile
Witchman
slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.
 
Posts: 628
Karma: 788808
Join Date: May 2013
Location: Philippines
Device: Android S5
@gregorio...I had a good look at your epub and discovered two things. First, because you used Adobe InDesign to generate your epub, the embedded fonts used in your epub's Font directory are all obfuscated using crypto. They shouldn't be obfuscated -- that will always give you a fail when you run the Epubcheck plugin. If you want to resolve or fix that font obfuscation problem then just open your test epub in Sigil and, in the Fonts directory, just right-click on each font in turn and select Font Obfuscation > None.

Secondly, I also state quite clearly in the plugin release notes -- in the Caveats section -- that this plugin will not convert pixel values to 'em' values. And the main reason I prefer not to convert pixels to em is because pixels should really only ever be used for the likes of image dimension values like "height" and "width" in the css and should not be used for font or font spacing values such as "font-size", "margin", "padding" and "text-indent" values etc.

I used Adobe InDesign about 10 years ago but eventually gave up using that app because of all the epub problems it still throws up whenever you use their epub converter. Also I found that their conversion to epub always created a vast amount of unnecessary cludge and clutter in the epub html which takes alot of extra work and time to clear up. Nowadays I tend to use Jutoh with Sigil for my epub conversions -- for speed. And both Jutoh and Scrivener(I have both) epub converters will always correctly give all css font and spacing values in 'em', properly done.

Anyway I will have a look at the plugin and see if I can incorporate the conversion of pixel values to em values in the css.

Last edited by slowsmile; 03-02-2022 at 08:50 PM.
slowsmile is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[FileType Plugin] YVES Bible Plugin ClashTheBunny Plugins 27 01-16-2023 02:25 AM
Problem with my ScrambleEbook plugin and the Plugin Updater tool jackie_w Development 14 01-19-2017 11:49 PM
Plugin not customizable: Plugin: HTML Output does not need customization flyingfoxlee Conversion 2 02-24-2012 03:24 AM
[GUI Plugin] Plugin Updater **Deprecated** kiwidude Plugins 159 06-19-2011 01:27 PM
New Plugin Type Idea: Library Plugin cgranade Plugins 3 09-15-2010 01:11 PM


All times are GMT -4. The time now is 01:33 PM.


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