Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil > Plugins

Notices

Reply
 
Thread Tools Search this Thread
Old 05-29-2015, 01:50 PM   #1
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
suggestion: plugin to remove spaces

What about a plugin to remove spaces in filenames of XHTML and/or images? Or perhaps replacing them by an underscore?

Should not be too difficult I think, but I am not a Python expert. Could be very useful in case of a lot of files...
Toxaris is offline   Reply With Quote
Old 05-30-2015, 09:40 AM   #2
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,552
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Are you thinking of an automated "everything in one fell swoop" kind of thing? I only ask because renaming files in the book browser will take care of updating all links to it.
DiapDealer is online now   Reply With Quote
Old 05-30-2015, 12:09 PM   #3
rubeus
Banned
rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.
 
Posts: 272
Karma: 1224588
Join Date: Sep 2014
Device: Sony PRS 650
How to handle these filenames:

chapter 01.html
chapter_01.html

in the same book?
rubeus is offline   Reply With Quote
Old 05-30-2015, 01:41 PM   #4
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,817
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by rubeus View Post
How to handle these filenames:

chapter 01.html
chapter_01.html

in the same book?
2 steps/passes should do it (but you will lose the names)
Select the Range: Change the names to something generic to avoid clashes

Now rename those to the final sequenced names

BTW the bulk renamer allows you to skip files


sec01
sec02
p01 <not selected
sec03
sec04
p02 <not selected
theducks is online now   Reply With Quote
Old 05-30-2015, 01:55 PM   #5
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
Quote:
Originally Posted by DiapDealer View Post
Are you thinking of an automated "everything in one fell swoop" kind of thing? I only ask because renaming files in the book browser will take care of updating all links to it.
Yup. The updating of the links would be the tricky part, especially for the images.
Toxaris is offline   Reply With Quote
Old 05-30-2015, 02:13 PM   #6
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,654
Karma: 5433388
Join Date: Nov 2009
Device: many
Actually, this is not easy as it sounds in that you must go through every link/anchor/aside/footnote, etc in every xhtml file looking for changed file names in internal links.

The code to actually do exactly this is built into Sigil in a C++ routine that performs UniversalUpdates and it is run when the epub is first loaded since the paths to the files will change due to being moved into the epub directory structure used by Sigil.

In the end, it might be easier to change the builtin updates routine then to recreate all of that code in a plugin.

KevinH
KevinH is offline   Reply With Quote
Old 05-30-2015, 06:32 PM   #7
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
Quote:
Originally Posted by KevinH View Post
Actually, this is not easy as it sounds in that you must go through every link/anchor/aside/footnote, etc in every xhtml file looking for changed file names in internal links.

The code to actually do exactly this is built into Sigil in a C++ routine that performs UniversalUpdates and it is run when the epub is first loaded since the paths to the files will change due to being moved into the epub directory structure used by Sigil.

In the end, it might be easier to change the builtin updates routine then to recreate all of that code in a plugin.

KevinH
So it will be core Sigil as of 0.9?

Just kidding...
Toxaris is offline   Reply With Quote
Old 05-31-2015, 10:30 PM   #8
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,866
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Just FYI, this would be five lines of code if you were making a plugin for the calibre editor (not counting the boilerplate for the plugin)

Code:
    from calibre.ebooks.oeb.polish.replace import rename_files
    book = self.current_container
    fmap = {f:f.replace(' ', '_') for f in book.manifest_id_map.itervalues() if ' ' in f}
    if fmap:
        rename_files(book, fmap)
Just replace the call to self.magnify_fonts() with the above code in the demo plugin http://manual.calibre-ebook.com/crea...t-book-plugins

and you are done.

Last edited by kovidgoyal; 05-31-2015 at 11:17 PM.
kovidgoyal is offline   Reply With Quote
Old 05-31-2015, 11:12 PM   #9
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,654
Karma: 5433388
Join Date: Nov 2009
Device: many
Hmm ... since all of the real work is done in rename_files for Calibre, that is very true. I think I could do something similar by extending the Sigil launcher interface and have it call the rename file code inside Sigil in a similar manner.

But I still think the easiest Sigil-based solution is to simply take care of that when the epub is first loaded. So if you are in need of a plugin quickly, doing what Kovid recommended in Calibre is probably the way to go until/if we release this feature in future version on Sigil assuming there is demand for it.

Thanks Kovid!
KevinH

Last edited by KevinH; 06-01-2015 at 09:54 AM.
KevinH is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
search and remove two spaces jlocicero Editor 3 04-24-2015 03:23 PM
CSS to indent paragraphs and remove spaces Alda Sigil 7 06-20-2014 05:36 AM
How to remove blank spaces? Mamaijee Conversion 2 04-09-2013 11:20 AM
Remove Double Spaces PortMan Calibre 20 05-13-2012 11:43 AM
Anyway to remove paragraph spaces in pdb files? twister Other formats 3 03-12-2009 09:36 PM


All times are GMT -4. The time now is 02:24 PM.


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