Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 02-27-2018, 04:08 PM   #1
rjwse@aol.com
Addict
rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.
 
rjwse@aol.com's Avatar
 
Posts: 283
Karma: 2228060
Join Date: Dec 2013
Location: LaVernia, Texas
Device: kindle epub readers on android
strange dropcap behavior with/without merged xhmtl

h1 ~ p:first-of-type, /*use for split xhtml */
h2 + p /*use for merged xhtml*/ {
text-indent: 0;
/*unindents first p following every h1*/}
h1 ~ p:first-of-type:first-letter, /*use for split xhtml*/
h2 + p:first-letter /*use for merged xhtml*/ {
color: red;
font-size: 3em;
float:none;
line-height: 0.5em;
/*float:none makes TALLcap*/}
If you split xhtml segments at every <h1> you can use the pseudo code to create dropcaps at the first letter of the first <p> following every <h1> when converting to PDF. If the xhtml segments are merged into a single file (to avoid page breaks before <h1>) then the pseudo code does not function and there are no dropcaps. Of course, normally, you would NOT merge the <h1> xhtml segments; I did that to prevent page breaks before every <h1>. However, if you also have <h2> subchapters you may actually want to prevent page breaks between every <h2>. If so, the above code for <h2> is a "work around" which lets you make drop caps no matter if the xhtml segments are merged or split. These are TALLcaps because dropcaps (float:left) are not well behaved. Best regards, Pop
Attached Thumbnails
Click image for larger version

Name:	Screenshot from 2018-02-27 15-04-37.png
Views:	193
Size:	41.0 KB
ID:	162535  
rjwse@aol.com is offline   Reply With Quote
Old 02-27-2018, 05:44 PM   #2
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 74,015
Karma: 129333114
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
You have at least two thing wrong here. The first is that the blue box is too close to the top of the first letter. Next is that the indent is ridiculously large.
JSWolf is offline   Reply With Quote
Advert
Old 02-27-2018, 06:08 PM   #3
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by JSWolf View Post
You have at least two thing wrong here. The first is that the blue box is too close to the top of the first letter. Next is that the indent is ridiculously large.
As rjwse@aol.com is trying to work out why the drop-caps isn't working, I'd say that is part of the reason the blue box is to close to the first letter. As to the indent, that's a personal style thing and while it is bigger than I tend to use, it isn't "ridiculously large".

@rjwse@aol.com: We need to see the page code, then we can try it ourselves. Create an epub that has the code you are using in the separate pages and with merged pages. Then we can see what is actually being done and maybe experiment.
davidfor is offline   Reply With Quote
Old 03-01-2018, 10:09 AM   #4
rjwse@aol.com
Addict
rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.
 
rjwse@aol.com's Avatar
 
Posts: 283
Karma: 2228060
Join Date: Dec 2013
Location: LaVernia, Texas
Device: kindle epub readers on android
dropcap/tallcap xhtml problems

I am enclosing an epub. The epub is best looked at in the calibre editor. I also have a matching video, but cannot upload to this site, as it is MKV. Instead I uploaded the matching video to youtube. The name is "dropcapvideo" https://youtu.be/8jh8RzaF72M Best regards, Pop
Attached Files
File Type: epub dropcaptext.epub (2.43 MB, 97 views)
rjwse@aol.com is offline   Reply With Quote
Old 03-01-2018, 11:15 AM   #5
Brett Merkey
Not Quite Dead
Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.
 
Posts: 194
Karma: 654170
Join Date: Jul 2015
Device: Paperwhite 4; Galaxy Tab
@rjwse: Your file can challenge some machines. You reference css files which do not exist but Calibre tries to retrieve anyway. In addition, your active css file has text which you must have meant to include in comments. I'm sure this also made Calibre work a bit hard.

I eliminated most of your code and split on H1 tags. Then I merged. I see what you mean. At least I probably expected the behavior you did. However, I did not find in the W3C spec that this :first-of-type behavior is wrong.

I tested this by changing the H1 tags to H2, beginning at the end of the file. I also changed the rule in the css file to H2. No dropcaps until I had changed the very first H1 to H2 (!) Apparently the structure is interpreted to mean the first-of-type of ALL p siblings, not just those related to any particular OTHER sibling. This appears to agree with W3C specs, even tho they are somewhat vague on this.

As I understand it, the definition of :first-of-type trumped your use of the general sibling combinator.

Last edited by Brett Merkey; 03-01-2018 at 11:35 AM.
Brett Merkey is offline   Reply With Quote
Advert
Old 03-01-2018, 11:44 AM   #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: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Basically the problem is that :first-of-type applies to the entire CSS selector, that is (h1 ~ p) so it only applies to the first h1 in the file. Which is why splitting the file works, as it means there is only one h1 in each file.

The simplest solution is to simply wrap the content after each h1 in a <div>. Something like,

Code:
<h1>Title</h1>
<div>
<img><img>blah blah
<p>Drop caps</p>
<p> other para</p>
</div>
Then use a adjacent combinator, something like

Code:
h1 + div p:first-of-type { color: red }
The trick here is that first of type now only applies to the p not to the h1 + div (at least if I remember my CSS operator precedence rules correctly, try it and see)

Last edited by kovidgoyal; 03-01-2018 at 11:48 AM.
kovidgoyal is offline   Reply With Quote
Old 03-01-2018, 11:45 AM   #7
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,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Here's a full example:

Code:
<h1>title</h1><div><span>xx</span><p>magic</p><p>other</p>
<h1>title</h1><div><span>xx</span><p>magic</p><p>other</p>
Code:
h1 + div p:first-of-type {
  color: red;
}
this should result in *both* magic words being red, and only those.

Last edited by kovidgoyal; 03-01-2018 at 11:47 AM.
kovidgoyal is offline   Reply With Quote
Old 03-01-2018, 03:04 PM   #8
rjwse@aol.com
Addict
rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.
 
rjwse@aol.com's Avatar
 
Posts: 283
Karma: 2228060
Join Date: Dec 2013
Location: LaVernia, Texas
Device: kindle epub readers on android
dropcaps

I cannot thank you enough for that explanation. This is the code I used:
h1 + div p:first-of-type {
text-indent: 0;}
h1+ div p:first-of-type:first-letter {
font-size: 3em;
float: none;
line-height: 0.5em;}
However, there is still a tiny problem. If I use float:none TALLcaps are produced (in correct locations). If I use float:left DROPcaps will wander away from the correct location if they are behind half-width images.
Attached Thumbnails
Click image for larger version

Name:	Screenshot from 2018-03-01 14-02-48.png
Views:	147
Size:	311.0 KB
ID:	162570   Click image for larger version

Name:	Screenshot from 2018-03-01 14-03-12.png
Views:	137
Size:	317.5 KB
ID:	162571  
rjwse@aol.com is offline   Reply With Quote
Old 03-01-2018, 03:08 PM   #9
rjwse@aol.com
Addict
rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.
 
rjwse@aol.com's Avatar
 
Posts: 283
Karma: 2228060
Join Date: Dec 2013
Location: LaVernia, Texas
Device: kindle epub readers on android
Thank you for that information. I did not know first-of-type took precedence.
rjwse@aol.com is offline   Reply With Quote
Old 03-01-2018, 03:16 PM   #10
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 74,015
Karma: 129333114
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
With the new revised code, how does it work with ADE 2.0.1?
JSWolf is offline   Reply With Quote
Old 03-01-2018, 04:44 PM   #11
rjwse@aol.com
Addict
rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.
 
rjwse@aol.com's Avatar
 
Posts: 283
Karma: 2228060
Join Date: Dec 2013
Location: LaVernia, Texas
Device: kindle epub readers on android
I am not familiar with ADE 2.0.1and am only using CSS and xhtml inside of the editor of calibre.
rjwse@aol.com is offline   Reply With Quote
Old 03-01-2018, 08:22 PM   #12
deback
Book E d i t o r
deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.
 
Posts: 432
Karma: 288184
Join Date: May 2015
Device: Laptop
If you don't care if the first capital letter drops or not, here is a simple .css code for dropcap:

.dropcap {
display: inline;
font-weight: bold;
font-size: 1.66667em;
line-height: 1.2;
}

It works every time, looks nice, is simple, and never gets messed up. I use the following html code:

<p class="noindent"><span class="dropcap">M</span>text continues here...

And it's easy to add the <span class="dropcap"> and corresponding </span> using a Regex search and replace.
deback is offline   Reply With Quote
Old 03-02-2018, 08:21 AM   #13
rjwse@aol.com
Addict
rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.
 
rjwse@aol.com's Avatar
 
Posts: 283
Karma: 2228060
Join Date: Dec 2013
Location: LaVernia, Texas
Device: kindle epub readers on android
I tried it and it works very well! I thank you for that. I copied and pasted your code into the calibre editor "create/edit snippets" with the snippet trigger "dc" (enabled by ctrl-j) in order to use it anywhere. Could you please show me how to do "a Regex search and replace" to add in this code? Best Regards, Pop
rjwse@aol.com is offline   Reply With Quote
Old 03-02-2018, 09:37 AM   #14
deback
Book E d i t o r
deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.
 
Posts: 432
Karma: 288184
Join Date: May 2015
Device: Laptop
You're welcome!

This is how I usually use Regex to add the "dropcap" code (be sure to check the "case sensitive" box and change the class to whatever is used in your file for the first paragraph in each chapter and change the "h1" to whatever is used in your file):

Search:

</h1>\s+<p class="noindent">([A-Z])


Replace:

</h1> <p class="noindent"><span class="dropcap">\1</span>


Then I also do this (to add the beginning quotation mark, if any):

Search:

</h1>\s+<p class="noindent">([“])

Replace:

</h1> <p class="noindent"><span class="dropcap">\1</span>


Then click the "Beautify Files" icon to arrange all the codes in the file to be spaced nicely.

I'm sure someone probably has a better way to do this, but I try to keep things simple. The above codes won't work if <h?> is not used for the chapter heading. In that case, you would need to do something a little different using Regex, or you might not be able to add a dropcap using Regex (as far as I know...like when "calibre1" or similar class is used for the class for every line in the file, including the chapters, etc).
deback is offline   Reply With Quote
Old 03-03-2018, 09:02 AM   #15
rjwse@aol.com
Addict
rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.
 
rjwse@aol.com's Avatar
 
Posts: 283
Karma: 2228060
Join Date: Dec 2013
Location: LaVernia, Texas
Device: kindle epub readers on android
regex dropcap

Wow! That works really good. I copied and pasted it into the calibre editor in the Saved Searches box so that I don't have to reinvent the wheel each time. Thank you. Best regards, Pop
Attached Thumbnails
Click image for larger version

Name:	Screenshot from 2018-03-03 07-57-46.png
Views:	133
Size:	63.4 KB
ID:	162597  
rjwse@aol.com is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Glo Strange display behavior AlterusPrime Kobo Reader 2 06-22-2015 01:39 PM
[KT 5.1.0] strange font behavior vpx Kindle Developer's Corner 0 04-18-2012 03:28 PM
strange behavior zeroh Nook Color & Nook Tablet 3 12-09-2010 11:14 AM
strange behavior valb2953 Calibre 1 11-22-2010 01:12 PM
DR800 Strange flipbar behavior penartur iRex 8 08-05-2010 09:17 PM


All times are GMT -4. The time now is 03:43 PM.


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