Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Editor

Notices

Reply
 
Thread Tools Search this Thread
Old 01-25-2016, 12:37 PM   #1
phossler
Wizard
phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.
 
Posts: 1,079
Karma: 412718
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
Remove unused class attributes

[Remove Unused CSS Rules] has a checkbox option to remove unused class attributes in the HTML.

However, it always cleans up the CSS stylesheets to remove unused class rules also.

Is there any way to just remove unused class attributes in the HTML? (RegEx, another check box options, .....?)

I try to keep my 'standard' stylesheet consistent so even though rules are not used in a given book, I'd like to keep them.

I ePubMerged a group of short stories and there was a lot of variety in how the same type of text was styles. For example, my 'standard' CSS has <p> for 99% of the cases, but it seems like each short story had it's own.
Attached Thumbnails
Click image for larger version

Name:	Capture.JPG
Views:	321
Size:	88.9 KB
ID:	145815  
phossler is offline   Reply With Quote
Old 01-25-2016, 02:15 PM   #2
PeterT
Grand Sorcerer
PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.
 
PeterT's Avatar
 
Posts: 12,246
Karma: 74000002
Join Date: Nov 2007
Location: Toronto
Device: Nexus 7, Clara, Touch, Tolino EPOS
Why not just reattach your CSS file after the cleanup?
PeterT is offline   Reply With Quote
Advert
Old 01-25-2016, 02:50 PM   #3
phossler
Wizard
phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.
 
Posts: 1,079
Karma: 412718
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
Actually that was my work-around

Before that I used the report feature and RegEx-ed the class attributes (tedious even using wildcards wherever possible) before I figured out that I was working way too hard

I was wondering / hoping there was a better way that could be done in a single operation

If not, then I'll use your workaround
phossler is offline   Reply With Quote
Old 01-25-2016, 02:51 PM   #4
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
The whole point of that tool is to trim the fat on books right before production.

Removing unused attributes is optional, because sometimes attributes can do things even without a matching CSS style. But there is no reason to keep unmatched style rules.


Why do you want to keep all that fat in your stylesheets???


Note: You can have calibre remember your house styles in the default template for newly-added CSS files.
eschwartz is offline   Reply With Quote
Old 01-25-2016, 02:52 PM   #5
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
P.S. What does ePubMerge have to do with anything?
eschwartz is offline   Reply With Quote
Advert
Old 01-25-2016, 03:34 PM   #6
phossler
Wizard
phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.
 
Posts: 1,079
Karma: 412718
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
Quote:
Originally Posted by eschwartz View Post
P.S. What does ePubMerge have to do with anything?
I merged a number of stories into a single epub and there was a lot of redundant attributes across them. I wanted to be neat and make sure the styling was consistent where is needed to be
phossler is offline   Reply With Quote
Old 01-25-2016, 03:48 PM   #7
phossler
Wizard
phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.
 
Posts: 1,079
Karma: 412718
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
Quote:
Originally Posted by eschwartz View Post
Why do you want to keep all that fat in your stylesheets???
Does having a number of unused CSS styles from a my 'House Rules' CSS add anything significant to the overhead of size or performance? (serious question since I don't know)

I concentrate on cleaning the HTML text and standardizing formatting either between merged files, or even within a epub. Especially to make it the way I prefer to see it on my Kindle

I've never worried about unused CSS rules in my standard CSS file (currently epub34.css) , since for example I have a <p> that I like, also headings, tables, etc. I have TOC-related CSS that makes the HTML TOC the way I prefer.

Admittedly when I'm done I could put the epub on a diet to get rid of all that fat. Just never thought about it because of the way my workflow has developed.
phossler is offline   Reply With Quote
Old 01-25-2016, 04:00 PM   #8
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Quote:
Originally Posted by phossler View Post
I merged a number of stories into a single epub and there was a lot of redundant attributes across them. I wanted to be neat and make sure the styling was consistent where is needed to be
Ummm... the tool that is the topic of this thread will not undo the damage caused by inconsistent styling in the original sources (or else whatever later conversions may have done)...

So I am still wondering what that has to do with this thread.

Quote:
Originally Posted by phossler View Post
Does having a number of unused CSS styles from a my 'House Rules' CSS add anything significant to the overhead of size or performance? (serious question since I don't know)
It can... every little bit helps. And then there are the monstrous house styles used by BPH ebook makers, which have hundreds and hundreds of unused rules (and attributes) and noticeably decreases the file size when cleaned up!

Quote:
I've never worried about unused CSS rules in my standard CSS file (currently epub34.css) , since for example I have a <p> that I like, also headings, tables, etc. I have TOC-related CSS that makes the HTML TOC the way I prefer.

Admittedly when I'm done I could put the epub on a diet to get rid of all that fat. Just never thought about it because of the way my workflow has developed.
And now you are worrying about missing unused CSS rules.
It is one thing to not be concerned about putting your EPUB on a diet. It is another thing entirely to have a tool you used for other reasons, give your EPUB a free diet, and then protest that you want the fat back!


So I don't see why you need a workaround to add back in the styles you aren't using, just because "I try to keep my 'standard' stylesheet consistent so even though rules are not used in a given book, I'd like to keep them".

Unless you really, really want to, just Because.
But if so, I don't think calibre is going to add another option just for that.

Last edited by eschwartz; 01-25-2016 at 04:02 PM.
eschwartz is offline   Reply With Quote
Old 01-25-2016, 04:00 PM   #9
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: 29,944
Karma: 55705602
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by phossler View Post
Does having a number of unused CSS styles from a my 'House Rules' CSS add anything significant to the overhead of size or performance? (serious question since I don't know)

I concentrate on cleaning the HTML text and standardizing formatting either between merged files, or even within a epub. Especially to make it the way I prefer to see it on my Kindle

I've never worried about unused CSS rules in my standard CSS file (currently epub34.css) , since for example I have a <p> that I like, also headings, tables, etc. I have TOC-related CSS that makes the HTML TOC the way I prefer.

Admittedly when I'm done I could put the epub on a diet to get rid of all that fat. Just never thought about it because of the way my workflow has developed.
Significant? probably not unless the list is huge.

But why? What is important is you are using the same names. Deleting unused does not change any names.

In the rare case you find your edit needs a previously discarded rule, you can replace the CSS (I would use the Unpack tool and slip the replacement in that way) then reclean after the latest edit.

Lean Mean EPUB Machine
theducks is offline   Reply With Quote
Old 01-25-2016, 04:37 PM   #10
phossler
Wizard
phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.
 
Posts: 1,079
Karma: 412718
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
@all -- I bow to your vastly more experience (not sarcasm). I guess I was worrying about something that doesn't really matter and got lost in the forest and kept bumping into trees.

Besides, who can argue against a "Lean Mean EPUB Machine"

Appreciate your time to explain

phossler is offline   Reply With Quote
Old 01-25-2016, 09:20 PM   #11
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Quote:
Originally Posted by eschwartz View Post
Ummm... the tool that is the topic of this thread will not undo the damage caused by inconsistent styling in the original sources (or else whatever later conversions may have done)...

So I am still wondering what that has to do with this thread.
Because I have just been yelled at by someone who saw me say this...

I just want to put it publicly out there, that the above quote was NOT me telling the OP what he is or is not allowed to talk about.

It was me being confused as to why ePubMerge was mentioned (because it didn't seem to fit with the rest of what was being said), and desiring clarification.

On the grounds that if I don't understand why the OP mentioned it, I may be missing something.



Then I made the observation that the tool which featured heavily in the title as well as the OP, was agnostic on whether ePubMerge was involved in creation of the source -- thus, my understanding of the query is that the OP need not worry about whether it was used earlier in the production.

...

I would also like to note that I am usually totally OK with multiple topics, offtopics, etc. -- even if I occasionally make comments in my own unique way attempting to clarify what it is, exactly, that someone is asking/saying.
eschwartz is offline   Reply With Quote
Old 01-25-2016, 10:51 PM   #12
phossler
Wizard
phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.
 
Posts: 1,079
Karma: 412718
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
@eschwartz -- Sorry I didn't expand on why I mentioned ePubMerge in my #1

It was the results of a tedious merge cleanup that got me wondering if there was an easy way to do some more text cleaning.

When I merged 9 or 10 stories to make an anthology for myself, the source stories had a variety of oft times contradictory styles and their own style sheets which produced a jumbled mess. Different fonts, line spacing, font size, paragraph margins, etc. Heading formatted differently, etc.

Deleting the merged style sheets and replacing and linking with my 'preferred' version at least provided an improved starting point (e.g. all <p> at least have the same basic format)

As part of the cleanup, I wanted to remove the now unused attributes in the text files to make text more lean (cleaner).

The source books had formatting like <p class="tx"> in one, <p class="txt"> in another, <p class="caliber_12">, etc. While there might be slight differences in the final formatting, they were still for me just basic body text.

Because some of the attributes were in <div>s and <span>s (and different) I couldn't use DiapDealer's wonderful editor plugin to also delete these non-value added tags also

To keep things simple for myself, since 95% of the HTML text is basic <p>, I find it's easier if I style <p> in a style sheet, and seldom add a class to such basic paragraphs.

I think that I'll use the [Remove Unused CSS Rules] the way it is intended (and recommended). I can always use PeterT's suggestion to just re-add my 'standard' style sheet should I need to for further editing
phossler is offline   Reply With Quote
Old 01-26-2016, 12:20 AM   #13
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Yeah -- disparate tag soup is a mess at the best of times. 10 books worth, all in one, must be even more fun.

Worth noting -- Diap's plugin can match and remove the attributes of a tag, instead of the tag itself. Also, ISTR you could sneak around the back and modify the config file to add extra target tags.

...

Usually I go through the styles, figure out which ones are junk, delete them from the CSS, and then use the Remove unused class attributes to clean up afterward. It just seemed faster to me than doing it the other way around (attributes then styles).
eschwartz is offline   Reply With Quote
Old 01-26-2016, 11:38 AM   #14
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: 29,944
Karma: 55705602
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
+1 for Diaps plugin

I would cleanup as much code as I could while the books were separate .

I have been replacing the pair
deNaked <spans>, but use care with <div> that might be confining a 'Block'
<span class="only italic attribute class"> with <i>

It would not hurt to ADD you standard (FULL set) stylesheet and shift over to it as you go.

Once you have run EPUB MERGE, Simply S&R the redundant sheet names to a single name (IRRC Epub merge adds adigit to the name if it finds a tie)
theducks is offline   Reply With Quote
Old 01-26-2016, 01:02 PM   #15
Thom*
The Fumbler
Thom* began at the beginning.
 
Posts: 66
Karma: 10
Join Date: Jun 2015
Device: android 4.2/fbreader
I deal with this issue thus:

1. Import an HTML "text" file that uses all of my standard css rules.
2. Link the file to the css file that is in the book.
3. Add my standard css rules to the css file. (via one snippet)
Note: Each time I run the "Remove unused css rules" tool, my standard css rules are preserved.
4. When finished editing the book I delete the imported HTML file.
5. Run the "Remove unused css rules" tool. Any of my standard css rules that are unused are then deleted.
6. End of story, life is sweet.
Thom* is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove unused folders in Calibre Library hashken Calibre 3 11-16-2014 06:05 AM
Is it possible to reject some changes after using "Remove unused CSS tool"? bowlins Editor 7 09-02-2014 04:22 AM
Remove unused CSS Rules Divingduck Editor 2 06-21-2014 07:51 AM
Adding class attributes in bulk kuvera Sigil 4 03-31-2014 06:36 AM
How to remove multiple class attribute from div lrui Recipes 4 08-13-2012 09:47 PM


All times are GMT -4. The time now is 12:42 AM.


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