![]() |
#1 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,273
Karma: 203719142
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Sample Plugin for the Editor
Quote:
--------- In the spirit of getting some more Editor Plugin action happening, I'm attaching a plugin that has three different tools. All three can be set to run on the currently opened file or to run book-wide. 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). 2) Smarten Punctuation (the sequel): gives slightly more granular control over the the smartening process. It preserves pre-existing entities and lets you choose what you want to smarten. So if you prefer three periods to the ellipse character/entity, you can keep them if you like. Also lets you supply a text file that defines apostrophe exception words like 'cept and 'tis in order to get the apostrophe right (instead of an opening single quote). I'm attaching a sample file for that, but basically it's one word per line WITHOUT any apostrophe characters. You can also choose to go with SmartyPants' default of using numeric entities instead of unicode characters if you like. 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. ![]() Please scour the differences and make judicious use of the checkpoint system before trusting these tools on your babies!! Not sure this is ready for a Prime-time plugin listing, so I thought I'd put it here. Last edited by DiapDealer; 08-20-2014 at 02:02 PM. |
|
![]() |
![]() |
#2 | ||
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
|
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:
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:
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. |
||
![]() |
Advert | |
|
![]() |
#3 | |||
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,273
Karma: 203719142
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
![]() Quote:
![]() Quote:
|
|||
![]() |
![]() |
#4 | |||
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:
Quote:
Quote:
A very useful plugin. And the most impressive part, it even comes with "Help" ![]() |
|||
![]() |
![]() |
#5 | ||
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,273
Karma: 203719142
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
![]() Quote:
![]() Last edited by DiapDealer; 08-02-2014 at 11:07 PM. |
||
![]() |
Advert | |
|
![]() |
#6 | |
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:
|
|
![]() |
![]() |
#7 | |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 691
Karma: 3026110
Join Date: Dec 2008
Location: Lancashire, U.K.
Device: BeBook 1, BeBook Pure, Kobo Glo, (and HD),Energy Sistem EReader Pro +
|
Quote:
I need to play with the span/div one as it looks like a solution to another regular problem I have with badly formatted source EPUBS. A big ![]() BobC |
|
![]() |
![]() |
#8 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,526
Karma: 12595249
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
Quote:
I have played with the span/div option, and I've got a couple of "Index out of range". Is there any log I can get? |
|
![]() |
![]() |
#9 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,273
Karma: 203719142
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
Code:
calibre-debug --edit-book I probably should have mentioned that while it shouldn't have much trouble with "ugly" markup, it's entirely likely that markup that's not well-formed could blow it up. It's either that, or your ebook markup contains elements/attributes that require special handling that I haven't encountered in my own testing yet--which is entirely possible. |
|
![]() |
![]() |
#10 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,086
Karma: 447222
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
|
@DiapDealer --
Quote:
Q1 - can you point me to a link as to how to install the PI in Win7 64 bit please? When I'm trying to clean up the formatting in a book, I usually try to consolidate a lot of 'embedded in the text' formatting into a style sheet, as well as simplify. I don't really care (and who cares what the Kindle thinks) if some paragraphs have 1.25 line after and others have 1.26 line after. This will leave me with a lot Code:
of <span>blah blah</span> more blah blah <span>blah blah</span> Q3 - could there be an option to remove some tag pairs separated by one (number could be settable?) character. Code:
<p><b>I</b>n the beginning ..... </p> Q4 - Maybe and option to remove unused ID=" ..." ? |
|
![]() |
![]() |
#11 | ||||
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,273
Karma: 203719142
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
Quote:
Quote:
Quote:
|
||||
![]() |
![]() |
#12 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 644
Karma: 1242364
Join Date: May 2009
Location: The Right Coast
Device: PC (Calibre), Nexus 7 2013 (Moon+ Pro), HTC HD2/Leo (Freda)
|
DiapDealer,
You have probably already considered this, but some potential issues that popped into my head. What about conversational exchanges between characters like: <p>"Yada, yada yada yada," he said.</p> <p>"Blah! Blah, blah blah, blah blah blah</p> <p>"Yada yada."</p> While I've used paragraphs in this example they could be spans or divs. But wouldn't the non-value add stripping run the risk of merging this conversation into a single run-on comment by the first speaker? Also the less frequently seen monologue of multiple paragraphs, which lacks a closing quotation mark until the final paragraph. (I haven't downloaded the PI as yet - I've been busy at work - so perhaps these points are already accounted for.) |
![]() |
![]() |
#13 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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)
|
Possibly -- if the maker of the book formatted paragraphs using span tags. If so, the whole book would be shot to pieces and we'd need to kill the person who made it.
![]() No real solution for a situation like that -- we just have to assume the person using the plugin knows to check before overwriting the only copy. |
![]() |
![]() |
#14 |
Dead account. Bye
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 587
Karma: 668244
Join Date: Mar 2011
Device: none
|
Extremelly good plugin really, really useful.
![]() Nevertheless some possible issues or suggestions. Test the following text about smarten punctuation mark II: Code:
<p>''Tis is a dialogue' John said.</p> <p>''Whatever'' is not a dialogue.</p> If I tick that option I get: Code:
<p>‘’Tis is a dialogue’ John said.</p> <p>‘’Whatever’’ is not a dialogue.</p> And why has not the double apostrophe after Whatever been converted to a curly ” ? But if I untick that option I get: Code:
<p>‘‘Tis is a dialogue’ John said.</p> <p>‘‘Whatever’’ is not a dialogue.</p> And now a suggestion: '90s is a decade contraction and it needs a right curly quote. '90 is a number in a dialogue', John said, 'so it needs a left curly one.' As coding an automate substitution rule for ' before numbers can be really hard, I propose asking the user each time an occurrence happens. OTOH about the tag substitution feature:
Last edited by arspr; 08-04-2014 at 05:52 PM. Reason: Uploading the exception file. |
![]() |
![]() |
#15 | |||||
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,273
Karma: 203719142
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Definitely something up with that first example. I'll take a look. But as far as:
Quote:
Quote:
![]() Quote:
![]() ![]() Quote:
![]() Quote:
Last edited by DiapDealer; 08-04-2014 at 08:35 PM. |
|||||
![]() |
![]() |
Thread Tools | Search this Thread |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Editor plugin question | DiapDealer | Development | 2 | 07-28-2014 10:23 PM |
Editor: ToC Editor: Start entry | macnab69 | Editor | 2 | 06-25-2014 11:15 AM |
Book Editor TOC Editor Isue? | weberr | Editor | 2 | 04-17-2014 11:13 AM |
Plugin not customizable: Plugin: HTML Output does not need customization | flyingfoxlee | Conversion | 2 | 02-24-2012 02:24 AM |
[GUI Plugin] Plugin Updater **Deprecated** | kiwidude | Plugins | 159 | 06-19-2011 12:27 PM |