View Single Post
Old 07-20-2022, 09:42 PM   #12
Tex2002ans
Wizard
Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.
 
Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
Quote:
Originally Posted by DaveLessnau View Post
I then went through the files and changed the classes bit by bit. At the end, I was back down to my standard set of classes (and it looks fine). At that point, I had to wonder if I would have just been better off mass deleting all of their classes and just applying my own to the bits and pieces that needed additional formatting.
I described my "clean up very dirty documents" methods in extreme detail:

It works by:
  • Multiple rounds of Calibre EPUB->EPUB conversions
    • while stripping down more and more of the "useless" CSS.
  • Using Diap's Editing Toolbag
    • Convert <span class="calibre123"> -> <i>.
    • + Remove lots of the superfluous <span>s.

* * *

Great news though!

More advanced cleanup tools WILL BE coming to Sigil soon!

After describing my methods in that late-2021 topic, for months, the stuff was nibbling away at me, so I consolidated my decade of ebook-conversion knowledge and proposed ideas to KevinH.

Here's 2 of the advanced tools that are being worked on:
  • CSS Consolidator
    • Or "CSSToolbox", or whatever the official name is going to be.
  • Advanced (List-based) Search/Replace
    • Similar to current Spellcheck Lists (Tools > Spellcheck > Spellcheck).

See this post where I describe some of the use-cases in extreme detail:

CSSToolbox

This will allow you to find/detect—and merge—exact/similar classes together:

Spoiler:
Before

Code:
<p>An <span class="normal">example</span>
where <span class="class98">there</span>
are <span class="class99">similar</span>
and <span class="class100">classes</span>.</p>
CSS:

Code:
.normal {
	font-size: 1em;
}

[...]

.class98 {
	font-size: 1em;
}

.class99 {
	font-size: 1.1em;
}

.class100 {
	font-size: 1em;
	color: black;
}
After

Code:
<p>An <span class="normal">example</span>
where <span class="normal">there</span>
are <span class="normal">similar</span>
and <span class="normal">classes</span>.</p>
CSS:

Code:
.normal {
	font-size: 1em;
}


Right now, "Remove Unused CSS" only works on CSS that isn't used at all.

This will allow you to take the next step:
  • Merging multiple CSS classes that are "the same" or "pretty close" to each other.
  • Taking that fantastic "Right-Click > Rename class" trick, and handling multiple of those for you.
    • 4 different classes into a "normal" class? Just check the boxes, and they'll all be renamed/merged together fine.
    • Right now, you have to do them one-by-one, and you can easily make mistakes.

Side Note: And the Calibre EPUB->EPUB method changes almost everything into "calibre###" classes. This method will keep names in tact.

* * *

Advanced Find/Replace (List-based)

This will allow you to:
  • Use Regex.
  • Search/sort through results like Tools > Spellcheck.

Spoiler:
Like this regex could "find all Dialogue Tags within a fiction book" + replace with "said":

Find: ,” \b(Alex|Bob|Joanne|Suzie|s*he|they)\b (\w+)
Replace: ,” \1 said
Filter:

Code:
Found              | Replace        |  Hits
___________________|________________|______
,” Alex opined     | ,” Alex said   |    10
,” Suzie accused   | ,” Suzie said  |     9
,” Joanne agreed   | ,” Joanne said |     4
,” Alex explained  | ,” Alex said   |     2
,” Alex ejaculated | ,” Alex said   |     1
,” she beseeched   | ,” she said    |     1
Then you could filter the list. Like only searching for "Alex":

Filter: Alex

Code:
Found              | Replace        |  Hits
___________________|________________|______
,” Alex opined     | ,” Alex said   |    10
,” Alex explained  | ,” Alex said   |     2
,” Alex ejaculated | ,” Alex said   |     1
And you could selectively apply Find/Replace ONLY on specific rows:

Code:
Found              | Replace        |  Hits
___________________|________________|______
,” Alex opined     |                |    10
,” Alex explained  |                |     2
,” Alex ejaculated | ,” Alex said   |     1
or sort the columns:

Code:
v Found            | Replace        |  Hits
___________________|________________|______
,” Alex ejaculated | ,” Alex said   |     1
,” Alex explained  |                |     2
,” Alex opined     |                |    10
and/or you could double-click on a row, and jump to its exact location in the EPUB (like Spellcheck Lists!).


This will allow you to visually see all before/after changes in a single menu, and you could selectively apply.

* * *

These tools will greatly speed up all sorts of workflows.

And who knows what other tricks and methods we'll come up with after people begin messing around with it.

Last edited by Tex2002ans; 07-20-2022 at 09:53 PM.
Tex2002ans is offline   Reply With Quote