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 04-10-2015, 03:47 AM   #1
Francois_C
Zealot
Francois_C can illuminate an eclipseFrancois_C can illuminate an eclipseFrancois_C can illuminate an eclipseFrancois_C can illuminate an eclipseFrancois_C can illuminate an eclipseFrancois_C can illuminate an eclipseFrancois_C can illuminate an eclipseFrancois_C can illuminate an eclipseFrancois_C can illuminate an eclipseFrancois_C can illuminate an eclipseFrancois_C can illuminate an eclipse
 
Francois_C's Avatar
 
Posts: 106
Karma: 8300
Join Date: Jul 2012
Location: France
Device: Kobo Aura H2O, Kobo Touch, Kobo Mini
Using ebook-editor in command line

As I already told once, like several ebook makers I still use Amanuensis for building ebooks, but my Kobo does not properly read "vertical-align:top", so I need to convert it to "vertical-align:super", Amanuensis is no longer maintained and the sources are not available anywhere.

I wanted to make an sh or bat file (or small compiled binary with only the command), using the editor in command line that is:
Code:
ebook-edit [opts] [path_to_ebook] [name_of_file_inside_book ...]
I need no options, the ebook file name is easy to set, the file inside ebook is style.css, but I don't know how to tell "replace vertical-align:top with vertical-align:super"

PS. And, when I try a command line that does not work, like:
Code:
ebook-edit "my_epub.epub" replace "style.css" "vertical-align:top" "vertical-align:super"
, I see that I also would need an option in order to avoid opening the GUI (that tells me that "replace" does not exist, style.css is not found…)
…now (after some more trials-and-errors) I can access style.css:
Code:
ebook-edit "my_epub.epub" OPS/style.css
Just lack the replace command

Last edited by Francois_C; 04-10-2015 at 06:08 AM.
Francois_C is offline   Reply With Quote
Old 04-13-2015, 11:27 PM   #2
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,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Why would you want to use the calibre editor as a wrapper to do something that is better done using, say, `unzip` and `sed`?

Assuming you are somewhat masochistic you can also do it with vim.
vim does support opening ZIP files, and EPUB is a rebadged ZIP, so... here's what Kovid Goyal did before he wrote the editor: ePub and vim



Given that there are far better solutions for scripted editing of files, I doubt any equivalent functions will be added to ebook-edit.
eschwartz is offline   Reply With Quote
Advert
Old 04-14-2015, 01:13 PM   #3
Arios
A curiosus lector!
Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.
 
Arios's Avatar
 
Posts: 463
Karma: 2015140
Join Date: Jun 2012
Device: Sony PRS-T1, Kobo Touch
François,

If I understand correctly your problem, why not simply use a regex search when editing your epub?

Of course, you have to do it for each epub, but it's just a matter of saving the regex.

By the way if you are using "vertical-align:top" for, let's say Mme or 1er, the following code is working adequatly, at least with my Kobo Touch :

Code:
sup {
    font-size: .55em;
    vertical-align: .60em;
    line-height: 0.5em;
}
Of course, this code can be changed as needed.
Arios is offline   Reply With Quote
Old 04-14-2015, 01:16 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,422
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 problem is the OP wanted to know how to run a regex in an automated fashion.

The answer is, of course -- wrong tool for the job.
eschwartz is offline   Reply With Quote
Old 04-14-2015, 02:21 PM   #5
Arios
A curiosus lector!
Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.
 
Arios's Avatar
 
Posts: 463
Karma: 2015140
Join Date: Jun 2012
Device: Sony PRS-T1, Kobo Touch
Good point eschwartz,

It's clearer now, but my suggestion is still relevant, especially if this is the only problem involved with the Amanuensis conversion.
Arios is offline   Reply With Quote
Advert
Old 04-14-2015, 08:51 PM   #6
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
Bulk changes to css files can also be done by creating a calibre plugin. Of course if you've never written a plugin before there's quite a learning curve but once you've created the framework to loop around the selected books you can use the calibre epub/azw3 container classes (another learning curve) to do a lot of the work and cssutils (yet another learning curve, but the OP's change would be trivial) to do the css edits. I've only written GUI plugins myself but I think there may be something you can do to make plugins run from the commandline if that's what you prefer.

That probably sounds like a lot of work but once it's done it's very easy to add a new small specific css edit as the need arises.
jackie_w is offline   Reply With Quote
Old 04-14-2015, 09:54 PM   #7
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,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
I dunno -- I still favor the idea of doing The Right Thing and using sed, which already exists and does exactly what is needed. Once we are already using the cli.

And it is extraordinarily easy to add new specific fixes to a sed script...
eschwartz is offline   Reply With Quote
Old 04-15-2015, 01:02 PM   #8
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
@eschwartz,

I suspect you're just being being provocative but wouldn't you say that the Right Tool for the job of exploding/massaging/rebuilding a calibre library epub/azw3 whilst maintaining the integrity of the calibre database may be a calibre container class which already contains most of that functionality. And that a Python package, cssutils, which knows all about css parsing and style rules may be the Right Tool for massaging a css file.

Actually my questions are purely rhetorical, as a rule I've never known any two techies able to agree about much of anything And on the whole the Right Tool is normally considered to be the one we already know how to use or "if all you have is a hammer, everything looks like a nail".
jackie_w is offline   Reply With Quote
Old 04-15-2015, 02:03 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,799
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
In the Navy, it was the 10lb tuning tool

If that would not fix it:

Nuke it : (Request Denied)
theducks is offline   Reply With Quote
Old 04-15-2015, 02:49 PM   #10
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,422
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 Right Tool for this job does not need to be html or css aware, since the original request was to allow passing regexes on the cli.

I am all for any solution that does the job with the minimum fuss (unlike this discussion ) but I see no reason to invent a new tool with unnecessary components.

Thus, for regex, use a pre-existing regex solution. I'm not fussy, it doesn't have to be sed.
eschwartz is offline   Reply With Quote
Old 04-17-2015, 04:06 AM   #11
Francois_C
Zealot
Francois_C can illuminate an eclipseFrancois_C can illuminate an eclipseFrancois_C can illuminate an eclipseFrancois_C can illuminate an eclipseFrancois_C can illuminate an eclipseFrancois_C can illuminate an eclipseFrancois_C can illuminate an eclipseFrancois_C can illuminate an eclipseFrancois_C can illuminate an eclipseFrancois_C can illuminate an eclipseFrancois_C can illuminate an eclipse
 
Francois_C's Avatar
 
Posts: 106
Karma: 8300
Join Date: Jul 2012
Location: France
Device: Kobo Aura H2O, Kobo Touch, Kobo Mini
@eschwartz:
Masochistic seems a bit hyperbolic (or influenced by the pseudo-scientific language of the Freudian faith which I no longer share, but is still alive). I just like well done job. I still prefer Amanuensis to the Calibre ebook compiler, but I hope I'll be soon able to do without it, as the author no longer gives any sign of life.
I know all you tell about epub structure, and I often rename epubs as zip files of course. The reasons why I did not try a Linux tool was: Amanuensis is a Windows tool, which does not work on Linux without wine (and I don't use wine in order not to give Windows viruses an access to m Linux system: you know, I'm masochistic. Pain is my pleasure).
So I found that the Calibre editor was able to get command lines, the function was nearly undocumented, and I hoped to find there a way to automate my work. To the moment, I right-click on the ODT file, a Windows shortcut "Convert ODT to epub" launches Amanuensis, then I "open with" "The Calibre e-book editor", and I replace all vertical-align:top with vertical-align:super. It takes only seconds, but I hoped to include it in my "Convert ODT to epub" menu shortcut on Windows, as I hoped to build my ebooks with a single command. If ebook-edit is the wrong tool, this was a wrong track.
A regex search would not spare a significant time, Arios, as I only need to type "v" tho have "vertical-align:top" prompted in the search history.

Last edited by Francois_C; 04-17-2015 at 04:08 AM.
Francois_C is offline   Reply With Quote
Old 04-17-2015, 07:47 AM   #12
Toxaris
Wizard
Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.
 
Toxaris's Avatar
 
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
It would be fairly easy to cook something up in Python or any other programming/scripting language to have this change executed in batch. You would not even need Calibre for that.
Toxaris is offline   Reply With Quote
Old 04-17-2015, 10:17 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,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Windows is not a problem. Use Gow, which is useful anyway on account of the Windows cli is nearly barren of useful cli commands. Gow is a collection of basic unix staples compiled as native Windows binaries (minGW).
And sed is included. So is zip, but I think somehow unzip got left out. So use 7z instead, what do I care.
eschwartz is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Command line ebook viewer? anoved Reading and Management 1 02-13-2012 02:32 PM
How to only get command line tool ebook-convert installed. okidogi Calibre 4 06-23-2011 10:59 AM
ebook-convert: change settings from command line miwie Calibre 1 11-30-2010 02:05 PM
Command Line Options for ebook-convert godel10 Calibre 14 08-08-2009 08:28 AM
iLiad "joe" command line text editor bobj iRex Developer's Corner 3 06-02-2008 03:03 PM


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


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