11-17-2015, 05:44 AM | #181 | |
Connoisseur
Posts: 67
Karma: 136594
Join Date: Jan 2013
Location: Hong Kong
Device: Kindle DX, Paperwhite, Paperwhite II, and Voyage
|
Quote:
Hi all, I realise this thread is rather old, but I am just wondering if someone can tell me if I'm doing something wrong. I read the various posts in this thread about this image (Alice talking to the Cheshire Cat) and wanted to replicate it myself, so followed the instructions to the letter (actually, copied and pasted both the css code into the style sheet, and the html code into the body, adjusting for the size of the image - mine is a gif, 342x480). In fact, I tried all 3 versions detailed in this thread, and got the same (or at least they looked similar) results every time.....and that is, it looks perfect in Sigil (screenshot attached), but doesn't work in any of the e-book previewers I have (iBooks, ADE, and Kindle Previewer) or my Kindle Paperwhite - see attached screenshots. . I am sure it is something I am not understanding and am doing wrong, but I have spent quite a few hours on it now, adjusting various things, and have not been able to get a different result. I could paste the code in here, but it is simply a copy and paste of code earlier in this thread, and it seems to work OK in Sigil. Does anyone have any idea where I should be looking please? |
|
11-17-2015, 07:29 AM | #182 | |
Grand Sorcerer
Posts: 5,635
Karma: 23191067
Join Date: Dec 2010
Device: Kindle PW2
|
Quote:
Check out this solution by RbnJrg. It works with ADE, iBooks and AZW3 books. The only downside is that the image won't resize if the user changes the font size. |
|
Advert | |
|
11-17-2015, 08:04 AM | #183 |
Connoisseur
Posts: 67
Karma: 136594
Join Date: Jan 2013
Location: Hong Kong
Device: Kindle DX, Paperwhite, Paperwhite II, and Voyage
|
Thanks Doitsu. I'll have a look.
|
05-31-2016, 09:52 AM | #184 |
Wizard
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
Formatting centuries (French)
Hi
Putting the Calibre editor "report" to good use, I obtained a list of Roman digits (see screenshot). I wish to enclose them in a span only if they are followed by the expression Code:
<sup>e</sup>* Code:
<span class="century">XII</span><sup>e</sup>* Code:
.century { font-size: smaller; text-transform: uppercase; } Doing this way, I do not modify other names like: Chapter XII, Charles IV which are NOT centuries. To check them one by one for each number would be very long for a full book. Is there a code I could use to get this result? Up to now none of them has a span. All the centuries have this <sup>e</sup> Last edited by roger64; 05-31-2016 at 10:02 AM. |
05-31-2016, 10:54 AM | #185 |
Grand Sorcerer
Posts: 5,635
Karma: 23191067
Join Date: Dec 2010
Device: Kindle PW2
|
You could use a simple regex search & replace operation. The following should work both in Sigil and Calibre Editor:
Find:([MDCLXVI]+)<sup>e</sup> Replace:<span class="century">\1</span><sup>e</sup> |
Advert | |
|
05-31-2016, 12:38 PM | #186 |
Wizard
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
Thank you. Solved (27 items modified).
I suppressed the M in the search field because we have also some M<sup>e</sup> which means "maître" (say a lawyer). |
06-15-2016, 11:41 AM | #187 |
Wizard
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
Only the text please
Hi
It happens we may have to intersperse within the text a lot of no-break spaces or narrow-no-break spaces (if they did not do it before with the text processor). In French, we have to do it according to specific typographic "rules" (before some punctuation signs, among them Code:
? ! : ; So, the question is: how can I insert these signs only within the text and avoid spoiling any tag? For example: - Nothing here: Code:
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" lang="fr-FR" xml:lang="fr-FR"> Code:
<p class="standard">« Cette lettre en est la preuve ! C’est à cause de cette Sylvia Sheilds. Elle lui a tourné la tête. Il est tout bizarre depuis qu’elle a quitté l’île. » Mon père avait donc lu la lettre ! Mon estomac se contracta.</p>
Last edited by roger64; 06-15-2016 at 12:32 PM. |
06-16-2016, 03:13 AM | #188 | |
The Grand Mouse 高貴的老鼠
Posts: 72,162
Karma: 308792702
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
|
Quote:
To do the job properly requires an XML parser linked to the search/replace, so no ordinary text editor is going to be adequate. |
|
06-16-2016, 04:32 AM | #189 |
Interested in the matter
Posts: 421
Karma: 426094
Join Date: Dec 2011
Location: Spain, south coast
Device: Pocketbook InkPad 3
|
With Calibre editor:
For example for the character ?. Remove all non-break spaces or narrow-no-break spaces before ?. Run this search with regex-function: Search: Code:
>[^\n<]*?< Code:
def replace (match, number, file_name, metadata, dictionaries, data, functions, * args, ** kwargs): return match.group().replace ("?","@?") |
06-16-2016, 10:10 AM | #190 |
Wizard
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
@jbacelar
Thanks very much. This code is working very well for one punctuation sign. I tried to make it work for a second one but I probably did something wrong because it failed. I have been told indentation is tricky but between theory and practice... So, I tried this... No Code:
def replace (match, number, file_name, metadata, dictionaries, data, functions, * args, ** kwargs): return match.group().replace ("!","@!") def replace (match, number, file_name, metadata, dictionaries, data, functions, * args, ** kwargs): return match.group().replace ("?","@?") |
06-16-2016, 11:35 AM | #191 |
Interested in the matter
Posts: 421
Karma: 426094
Join Date: Dec 2011
Location: Spain, south coast
Device: Pocketbook InkPad 3
|
@roger64
Oh! forgiveness for being so succinct. The correct code is: Code:
def replace(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs): return match.group().replace("?","@?").replace("!","@!").replace(";","@;").replace(":","@:") Last edited by jbacelar; 06-16-2016 at 11:43 AM. |
06-16-2016, 01:06 PM | #192 |
Wizard
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
It's working.
The only thing is the count with the Calibre editor: it anounces 1386 replacement which seems to be only the replacements regarding the first element. When I make a separate recount (out of the function), it finds 1802 which seems to be the true amount, because, as far as I can look, every punctuation signs get its own @. The main thing is that the full function does the job. I will reuse it for many other things. Thanks a lot for your very appreciated help. |
06-16-2016, 01:13 PM | #193 |
Interested in the matter
Posts: 421
Karma: 426094
Join Date: Dec 2011
Location: Spain, south coast
Device: Pocketbook InkPad 3
|
You are welcome
|
10-08-2016, 08:24 PM | #194 |
Wizard
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
Hi
I have a regex question. The solution would allow me to convert more easily output from my word processor. Say we have this text: Code:
<blockquote> <p>A la première ville,<br/>Son amant l’habille<br/>Tout en satin blanc</p> <p>A la seconde ville,<br/>Son amant l’habille<br/>En or, en argent.</p> <p>Elle était si belle<br/>Qu’on lui tendait les voiles<br/>Dans tout le régiment.</p> </blockquote> I fail to do it. Last edited by roger64; 10-08-2016 at 08:28 PM. |
10-09-2016, 12:07 AM | #195 | |
Well trained by Cats
Posts: 30,364
Karma: 58053698
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
<p> <p class="note"> If you are changing a font, why not apply the class to the Blockquote instead |
|
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
direkter Umlaut oder lieber HTML Code in Epub ? | NASCARaddicted | Erste Hilfe | 14 | 06-16-2011 05:54 AM |
Programming language code snippets in ebooks? | Connochaetes | Writers' Corner | 7 | 10-18-2010 02:43 PM |
ebook-convert HTML to EPUB and problem with <pre><code> | mikegr | Calibre | 2 | 03-09-2010 02:27 PM |
css override code for margins? | Amalthia | Calibre | 15 | 08-11-2009 07:20 PM |
Problems generating ePub from HTML/CSS | AlexBell | Calibre | 3 | 07-17-2009 05:10 AM |