![]() |
#1 |
Junior Member
![]() 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? |
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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.
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Junior Member
![]() 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 |
![]() |
![]() |
![]() |
#4 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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
|
![]() |
![]() |
![]() |
#5 |
Junior Member
![]() 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. |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,136
Karma: 27110892
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Not before, after.
|
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
|
![]() |
||||
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 |