View Single Post
Old 08-02-2014, 04:20 PM   #2
Rev. Bob
Wizard
Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.
 
Rev. Bob's Avatar
 
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
NOTE TO ALL: Please forgive the slightly stream-of-consciousness writing below. I had relatively minor surgery yesterday and am still recovering. I'm just trying to throw some ideas out there; use whatever you like.

Quote:
Originally Posted by DiapDealer View Post
1) Span Div Editor: conveniently remove, change the attributes of (and/or convert to different html elements) those pesky, nestable spans and divs (as well as a few others).
Now that sounds neat. So if I've got a bunch of, say, <span class="italic"> or <div class="reallyaparagraph">, I could use this to switch those over to proper <i> and <p class="reallyaparagraph"> throughout the book without having to worry about nesting issues? And to hearken back to my own recent project, is it able to remove attributeless spans or (hope, hope) join adjacent identical spans?

Example of that last:

<span class="foo">blah blah </span><span class="foo">blah</span>

...would become, naturally:

<span class="foo">blah blah blah</span>

(And should such spans still count as adjacent when separated only by whitespace? I'd say yes, but there's certainly room for debate.)

Then again, what'd really be neat is the ability to correctly convert un-nested spans to nested ones. I see stuff like this all the time, particularly in ill-coded books that define a class for the paragraph, only to turn right around and wrap all of its text in a span that redefines everything...except it doesn't do a real wrap, because it doesn't nest spans:

<span class="foo">blah </span><span="ital">blah</span><span class="foo"> blah</span>

...which, of course, can usually be safely converted to:

<span class="foo">blah <span class="ital">blah</span> blah</span>

...although that feature may merit a note about unintended side-effects due to cascading, come to think of it.

Speaking of which - it'd really be handy to be able to say "all text files that call spreadsheet X" in search/replace. It's not an extremely common case, but if you're dealing with omnibus collections, it can be quite an issue. Just imagine one ebook containing three novels, each with a couple of dozen chapters and its own stylesheet...not fun. (Especially when the class names overlap but the classes' styles differ between sheets...)

Then again, I wish calibre's editor was generally more...is "CSS-aware" right? For instance, imagine being able to pick a class somewhere (in a sheet or on a page) and easily operate on it across the board, in the sheet which defines the class and in all the pages that use it. Rename it, replace it with another (existing or new) class, see if a class name is in use, convert a tag's style="definitions" into a class and make that change wherever it appears...that sort of thing. I mean, the editor's fine if you've got a basic ebook with one stylesheet, or multiple sheets with mutually exclusive class names or domains, but once there's any overlap, things get weird fast.

Quote:
Originally Posted by DiapDealer
3) Convert CM to EM: this one was one I did for roger64. It simply parses CSS files looking for attributes that have cm dimensions and converts them to em (based on a preset factor). Figured I'd toss that in.
Any chance of expanding that to handle IN as well? And are you using the canonical "2.54 cm = 1 in = 6pc = 72 pt" conversion, or something else?

ADDENDUM: Also, 96px = 1in.

Last edited by Rev. Bob; 08-03-2014 at 02:39 AM. Reason: Corrected "6em" to the proper "6pc" - picas, not ems.
Rev. Bob is offline