Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Conversion

Notices

Reply
 
Thread Tools Search this Thread
Old 06-23-2019, 03:33 AM   #1
Mr Groch
Junior Member
Mr Groch began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Jun 2019
Device: Kindle PW 4, PB Era Color
Keep raw text in Search & Replace (nbsp and old mobi format)

For some reasons I want to convert to old mobi and I want to use non-breaking spaces. According to Amazon publisher guidelines it is not good in old mobi to use unicode   as non-breaking space, and I should use old and obsolete   named entity. I've checked this on my Paperwhite 4 and this is true - when there is unicode nbsp char, selection and highlighting mechanism threads that char, word before and word after as whole one word...

Problem is that when I try to use \1$nbsp; in calibre Search & Replace in conversion, Calibre will replace this with unicode nbsp char... I want to insert raw '$nbsp;' in output

How to force calibre to use raw text in replace pattern?
Mr Groch is offline   Reply With Quote
Old 06-23-2019, 05:32 AM   #2
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: 45,136
Karma: 27110892
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You cannot. Replacement of entitites by unicode codepoints happens else where in the conversion pipeline, and is relied on by the entire conversion pipeline.
kovidgoyal is offline   Reply With Quote
Advert
Old 06-23-2019, 12:22 PM   #3
Mr Groch
Junior Member
Mr Groch began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Jun 2019
Device: Kindle PW 4, PB Era Color
OK, I see now - even when I edit epub with built in editor, and change all #160 unicode char to   after converting it will be unicode #160 in new created format...

Can you point me a section of the source code when I need to edit t disable that behaviour? I know Python and I can fork calibre to make this private mod, but will be pleased with a little help
Mr Groch is offline   Reply With Quote
Old 06-24-2019, 06:56 AM   #4
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: 45,136
Karma: 27110892
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You cannot disable the behavior it is fundamental to how conversion works. What you could do is modify the MOBI output plugin to put those entities bach right at th eend before it writes out the mobiml markup. See plugins/mobi_output.py
kovidgoyal is offline   Reply With Quote
Old 06-25-2019, 11:23 AM   #5
Mr Groch
Junior Member
Mr Groch began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Jun 2019
Device: Kindle PW 4, PB Era Color
Thanks again, but this still isn't enough... I'm replacing all u'\xa0' with ' ' just before mobimlizer as you suggest, and something is replacing my '&' char with '&' in output mobi. I have also tried to move my code after mobimlizer but with no luck. Where that replacing is done?

EDIT: my replacing is done in i.text and i.tail at:
for x in self.oeb.manifest.items:
if x.media_type in OEB_DOCS:
for body in XPath('//h:body')(x.data):
for i in XPath('descendant::h:*')(body):

Last edited by Mr Groch; 06-25-2019 at 11:26 AM.
Mr Groch is offline   Reply With Quote
Advert
Old 06-25-2019, 10:53 PM   #6
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: 45,136
Karma: 27110892
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Not before, after.
kovidgoyal is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Regex in search problems (NOT Search&Replace; the search bar) lairdb Calibre 3 03-15-2017 07:10 PM
Moving text with a non-breaking space [ ] mcdummy Editor 4 08-23-2016 11:45 AM
Search & Replace on only mobi half of a mobi/k8 combined file EliW Conversion 0 05-03-2013 11:50 PM
Search & replace TEXT ToeRag Calibre 3 04-10-2010 01:44 PM
Mobiperl   lost when converting to mobi Jellby Kindle Formats 19 08-26-2008 03:10 PM


All times are GMT -4. The time now is 02:34 AM.


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