|  07-23-2014, 11:04 AM | #766 | 
| Resident Curmudgeon            Posts: 80,721 Karma: 150249619 Join Date: Nov 2006 Location: Roslindale, Massachusetts Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3 | 
			
			I've just run the latest version of Modify ePub and I do like the unpretty part. Saves me from having to load into Sigil to fix some not so good formatting of the XML.
		 | 
|   |   | 
|  07-23-2014, 09:08 PM | #767 | 
| Resident Curmudgeon            Posts: 80,721 Karma: 150249619 Join Date: Nov 2006 Location: Roslindale, Massachusetts Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3 | 
			
			I have a request. Would it be possible for the unpretty (de-indent) routine to not double space?
		 | 
|   |   | 
|  07-23-2014, 09:19 PM | #768 | |
| Wizard            Posts: 1,760 Karma: 9918418 Join Date: Feb 2013 Location: Here on the perimeter, there are no stars Device: Kobo H2O, iPad mini 3, Kindle Touch | Quote: 
 If you don't like the double-spacing, just open the book in Calibre's editor and replace \n+ with \n in All text files, using Regex mode. Done. | |
|   |   | 
|  07-24-2014, 11:16 AM | #769 | 
| Guru            Posts: 820 Karma: 6528026 Join Date: Sep 2012 Device: Kobo Elipsa | 
			
			I hesitate to ask for this (it may be my OCD showing), but would it be possible for Modify ePub to have an option to clean up the CSS file (put classes in alphabetical order, make the formatting/indenting/spacing consistent)? Some stylesheets are such a mess that I can't scan them easily. Sometimes I miss classes with identical names--some are duplicates but some are not, and if they were in alphabetical order, at least I could view them together and consolidate or remove duplicates. Sometimes individual properties are all on a single line, sometimes they are on separate lines, sometimes a property has a colon plus a space after the property name, sometimes it has a colon with no space... These things turn a simple search into a regex adventure, which is a pain. Calibre's conversion process handles most of these, but I'd rather not deal with the side effects of conversion. Anyway, just a suggestion, and thank you for the work already done in this essential plugin.
		 | 
|   |   | 
|  07-24-2014, 11:51 AM | #770 | |
| Well trained by Cats            Posts: 31,246 Karma: 61360164 Join Date: Aug 2009 Location: The Central Coast of California Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A | Quote: 
  if you are looking at the CSS, you are probably editing something. 1 click and it is pretty-er). Sigil has the reformat CSS right-click option. Both make the CSS have a standard layout (colon space), but a \s* between the colon and the argument will take care of the REGEX search problem Neither sorts. Both have clean unused styles. | |
|   |   | 
|  07-24-2014, 01:07 PM | #771 | 
| Guru            Posts: 820 Karma: 6528026 Join Date: Sep 2012 Device: Kobo Elipsa | 
			
			[QUOTE=theducks;2881659]You can 'beautify' just the CSS with ebook-edit (  if you are looking at the CSS, you are probably editing something. 1 click and it is pretty-er). QUOTE] Aha, I didn't know that. Thanks. All I need now is to alphabetize the classes. | 
|   |   | 
|  07-24-2014, 02:52 PM | #772 | |
| Wizard            Posts: 1,760 Karma: 9918418 Join Date: Feb 2013 Location: Here on the perimeter, there are no stars Device: Kobo H2O, iPad mini 3, Kindle Touch | Quote: 
 That said, there are several ways to clean up CSS files, some of which have already been mentioned. One of my favorite methods is to open the book with Calibre's editor, add a new (and thus unused) class to the CSS sheet in question, and then use the Tools > Remove unused CSS rules option. (Name is from memory; I'm on my iPad right now.) Not only will that tool remove the unused classes, but it will also reformat the affected sheets to a readable standard. It doesn't do any reordering, though, as sometimes the sequence of rules within a stylesheet matters. Specifically, later rules override earlier rules. (Real example: One sheet defined * { margin: 0; } and then blockquote { margin: 1em 1.5em; } - if you reverse that sequence, blockquote loses its margins.) Yes, if the styles are all independent, the order doesn't matter. However, in my experience, the big long sheets that are hard to wade through are most commonly template-related sheets that contain a lot of unused rules. Clear those out, and things look a lot better really fast. | |
|   |   | 
|  07-24-2014, 06:03 PM | #773 | 
| Guru            Posts: 820 Karma: 6528026 Join Date: Sep 2012 Device: Kobo Elipsa | 
			
			Understood about rule sequence. It's just that I've had a few stylesheets lately that either duplicate entire classes verbatim or override many/most of the properties in those classes. If classes with the same names could be grouped together, I could see what is happening a whole lot easier. Calibre's conversion process does this, and so far it hasn't created any problems in that respect, but it also consolidates classes, which I don't want. But knowing how to reformat the stylesheet helps a lot, so I am reasonably satisfied for the moment. Thanks.
		 | 
|   |   | 
|  07-24-2014, 06:11 PM | #774 | 
| Wizard            Posts: 1,760 Karma: 9918418 Join Date: Feb 2013 Location: Here on the perimeter, there are no stars Device: Kobo H2O, iPad mini 3, Kindle Touch | 
			
			For something like that, you may want to check out http://cleancss.com/ - copy the sheet's CSS into the box, set your selections as you wish, and let 'er rip. Quick, good, and pretty painless (aside from being an online tool rather than an integrated one). I used CleanCSS on one book that had apparently been written with one sheet/chapter, then all the classes got mass-renamed so all the sheets could be crammed into one document. You'd end up with, for instance, .center, .center1, .center2, and so on through about .center29 - and they're all identical. CleanCSS combines those together, and then you can use Calibre's search/replace feature to reduce the references to all those different classes if you want. That part can be tedious, but at least it's possible once everything's been combined. Last edited by Rev. Bob; 07-24-2014 at 06:15 PM. Reason: Remembered a useful example. | 
|   |   | 
|  07-24-2014, 10:25 PM | #775 | 
| Grand Sorcerer            Posts: 24,905 Karma: 47303824 Join Date: Jul 2011 Location: Sydney, Australia Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos | 
			
			Sorting the stylesheet sounds like an something the editor should do. And as Kovid has announced support for editor plugins in the next release, that would be a good way to add the function.
		 | 
|   |   | 
|  07-24-2014, 10:41 PM | #776 | |
| Guru            Posts: 820 Karma: 6528026 Join Date: Sep 2012 Device: Kobo Elipsa | Quote: 
  ) | |
|   |   | 
|  07-24-2014, 10:47 PM | #777 | 
| Resident Curmudgeon            Posts: 80,721 Karma: 150249619 Join Date: Nov 2006 Location: Roslindale, Massachusetts Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3 | 
			
			Personally, I would not mind if Modify ePub cleaned up the stylesheet. But reordering it, nope, things could break.
		 | 
|   |   | 
|  07-25-2014, 01:49 AM | #778 | |
| Grand Sorcerer            Posts: 24,905 Karma: 47303824 Join Date: Jul 2011 Location: Sydney, Australia Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos | Quote: 
 | |
|   |   | 
|  07-25-2014, 10:35 AM | #779 | 
| Guru            Posts: 820 Karma: 6528026 Join Date: Sep 2012 Device: Kobo Elipsa | 
			
			I'd like to reorder it to check dups, but not necessarily save the reordered version. Finding duplicate classes is so tedious that DavidFor's new plugin will make this way easier. Thanks, DavidFor.
		 | 
|   |   | 
|  07-25-2014, 11:08 AM | #780 | 
| Resident Curmudgeon            Posts: 80,721 Karma: 150249619 Join Date: Nov 2006 Location: Roslindale, Massachusetts Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3 | 
			
			Why not then ask for a duplicate class checker instead of reordering?
		 | 
|   |   | 
|  | 
| Tags | 
| modify epub | 
| 
 | 
|  Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post | 
| [GUI Plugin] Quality Check | kiwidude | Plugins | 1277 | 10-21-2025 10:04 AM | 
| [GUI Plugin] Open With | kiwidude | Plugins | 404 | 02-21-2025 05:42 AM | 
| [GUI Plugin] Manage Series | kiwidude | Plugins | 167 | 07-28-2024 03:07 PM | 
| Modify ePub plugin dev thread | kiwidude | Development | 346 | 09-02-2013 05:14 PM | 
| [GUI Plugin] Plugin Updater **Deprecated** | kiwidude | Plugins | 159 | 06-19-2011 12:27 PM |