![]() |
#1 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,178
Karma: 2431850
Join Date: Sep 2008
Device: IPad Mini 2 Retina
|
Calling smarten_punctuation from edit book
Re: https://www.mobileread.com/forums/sho...d.php?t=230684.
I have enhanced ebook-polish to add a new command line parameter: Code:
-s SMARTEN_PUNCTUATION_OPT, --smarten-punctuation-opt=SMARTEN_PUNCTUATION_OPT This all works fine. But I am not clear on exactly how edit-book can call my new smarten_punctuation_opt command (in ebooks\oeb\polish\main.py) with parameters: So in gui2\tweak_book\ui.py I have Code:
self.action_smarten_punctuation = reg( 'smarten-punctuation.png', _('&Smarten punctuation'), partial( self.boss.polish, 'smarten_punctuation_opt', _('Smarten punctuation')), 'smarten-punctuation', (), _('Smarten punctuation')) Code:
if opts.smarten_punctuation_opt: rt(_('Smartening punctuation')) smarten_punctuation(ebook, opts.smarten_punctuation_opt, report) #smarten_punctuation(ebook, "H", report) report('') I need to able to set opts.smarten_punctuation_opt when I call this from edit-book (obviously edit book is also going to need a UI to specify the smarten punctuation options but I will worry about that later). |
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,168
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You need to modify tweak_polish().
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,178
Karma: 2431850
Join Date: Sep 2008
Device: IPad Mini 2 Retina
|
Many thanks.
Am I right in thinking that edit book will be getting saved Find and Replace? If so, then another way to achieve a configurable smarten punctuation would be executing a previously saved Find & Replace, something like this: The saved Find & Replace would need to include all the parameters in the Find and Replace GUI, including Mode, the files to be affected, case sensitivity etc, the action to be performed when executed (Find, Replace, Replace all etc). The user could automatically execute the saved Find & Replace, without having to first load it into the Find and Replace dialog and execute it from there. Multiple saved Find & Replaces could be chained together, or executed as children of a parent container. The overall effect is that a single menu/button click would execute multiple, previously configured regexes. This would be a very powerful feature to enable the user to make a lot of bespoke, automated changes, and goes beyond what Sigil supports. It also solves the problem of the currently hard coded regexes in smartyPants. Any thoughts on this? |
![]() |
![]() |
![]() |
#4 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,168
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
There will be saved find replace. However, it wont store a list fo files to operate on, as that would make them useless across books. Instead you will have to specify the files when you run them.
|
![]() |
![]() |
![]() |
#5 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,178
Karma: 2431850
Join Date: Sep 2008
Device: IPad Mini 2 Retina
|
I was thinking more that when you configure the find replace, you could choose the run-time target as, e.g.,
"Current file" - at run-time this would find and replace in whatever is the current file. "All HTML files". At run-time this would find and replace in all HTML files in the current ebook. "All CSS files". At run-time this would find and replace in all CSS files in the current ebook. "All files". At run-time this would find and replace in all files in the current ebook. etc And you could also automatically execute the saved find replace when you load it. |
![]() |
![]() |
Advert | |
|
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
New DRM to edit your book for you... | VydorScope | Writers' Corner | 3 | 06-19-2013 11:34 PM |
Edit a converted book | GeePee | Conversion | 16 | 03-05-2011 05:31 PM |
Free Book (Kindle) - Calling Home | koland | Deals and Resources (No Self-Promotion or Affiliate Links) | 1 | 07-28-2010 12:29 PM |
Write and edit your own book now | frostine | Lounge | 15 | 05-24-2009 10:54 PM |
What is the Worst Book you have had to Edit? | andyafro | Sony Reader | 2 | 12-01-2007 09:40 PM |