![]() |
#1 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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 ...] 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" …now (after some more trials-and-errors) I can access style.css: Code:
ebook-edit "my_epub.epub" OPS/style.css ![]() Last edited by Francois_C; 04-10-2015 at 06:08 AM. |
![]() |
![]() |
![]() |
#2 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
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. |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
A curiosus lector!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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; } |
![]() |
![]() |
![]() |
#4 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
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. |
![]() |
![]() |
![]() |
#5 |
A curiosus lector!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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. |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,249
Karma: 16539642
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
|
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. |
![]() |
![]() |
![]() |
#7 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
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... |
![]() |
![]() |
![]() |
#8 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,249
Karma: 16539642
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
|
@eschwartz,
I suspect you're just being being provocative ![]() Actually my questions are purely rhetorical, as a rule I've never known any two techies able to agree about much of anything ![]() |
![]() |
![]() |
![]() |
#9 |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,914
Karma: 60358908
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) |
![]() |
![]() |
![]() |
#10 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
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 ![]() Thus, for regex, use a pre-existing regex solution. I'm not fussy, it doesn't have to be sed. ![]() |
![]() |
![]() |
![]() |
#11 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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. |
![]() |
![]() |
![]() |
#12 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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.
|
![]() |
![]() |
![]() |
#13 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
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.
![]() And sed is included. So is zip, but I think somehow unzip got left out. ![]() ![]() |
![]() |
![]() |
![]() |
|
![]() |
||||
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 |