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 Today, 03:23 AM   #1
ryder
Enthusiast
ryder began at the beginning.
 
Posts: 29
Karma: 10
Join Date: May 2024
Device: Clara 2E
Calibre not using my indent command

Hello everybody,

I use this css styling for my epub conversions:

p {
p:first-of-type {
text-indent: 0 !important;
}
p {
margin: 0 !important;
padding: 0;
widows: 1;
orphans: 1;
text-indent: 1em !important;
}

Unfortunately calibre indents with more than 1em for the other paragraphs except the first one. How can I combine the two p commands in one, so that the text indent will be 1em?

My goal is that the first indent after chapter or space break is 0 and the normal indent after paragraph should be 1em.

Thank you in advance
ryder is offline   Reply With Quote
Old Today, 03:29 AM   #2
Karellen
Wizard
Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.
 
Karellen's Avatar
 
Posts: 1,703
Karma: 9500498
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
Quote:
Originally Posted by ryder View Post
p {
p:first-of-type {
text-indent: 0 !important;
}
You have one too many opening curly brackets.
Karellen is offline   Reply With Quote
Old Today, 04:26 AM   #3
ryder
Enthusiast
ryder began at the beginning.
 
Posts: 29
Karma: 10
Join Date: May 2024
Device: Clara 2E
The thing is I have tinkered around with the curly brackets and it either indented after every paragraph with 1em even after chapter or the first one was not indented but every other had like 2.5em.

Is it ok to have two p commands or does just the first one count and the second one will be of no use to calibre?

Also tried this with no luck:

p {
p:first-of-type {
text-indent: 0 !important;}
margin: 0 !important;
padding: 0;
widows: 1;
orphans: 1;
text-indent: 1em !important;
}
ryder is offline   Reply With Quote
Old Today, 05:12 AM   #4
Karellen
Wizard
Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.
 
Karellen's Avatar
 
Posts: 1,703
Karma: 9500498
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
You can't nest CSS rules as far as I am aware. So your double sets of curly brackets won't work.

Sometimes it is easier to just use basic coding, so I wouldn't be trying to combine rules
https://www.w3schools.com/css/css_combinators.asp

I would use two separate rules...

For all your standard paragraphs, use this for your 1em indent
p {
display: block;
margin-top: 0;
margin-bottom: 0;
text-indent: 1em;
}

Then for your first para after scene break, use the following. It will give you spacing above for the scene break. And yes, you will have to modify all the scene break p tags to include the class. <p class="scene">Blah blah.</p>
.scene {
padding-bottom: 0;
padding-top: 2em;
text-indent: 0;
}

If you want to use pseudo elements, they will need to be two separate rules anyway, and not all ereader software will understand it.
https://www.w3schools.com/css/css_pseudo_elements.asp
Karellen is offline   Reply With Quote
Old Today, 05:18 AM   #5
readx
Connoisseur
readx 's ceiling is 100% spider-free.readx 's ceiling is 100% spider-free.readx 's ceiling is 100% spider-free.readx 's ceiling is 100% spider-free.readx 's ceiling is 100% spider-free.readx 's ceiling is 100% spider-free.readx 's ceiling is 100% spider-free.readx 's ceiling is 100% spider-free.readx 's ceiling is 100% spider-free.readx 's ceiling is 100% spider-free.readx 's ceiling is 100% spider-free.
 
Posts: 96
Karma: 118402
Join Date: Jul 2009
Device: Cybook Gen3
For me the use of p + p would be the easier solution

Code:
p {
text-indent: 0 !important;
}
p + p {
margin: 0 !important;
padding: 0;
widows: 1;
orphans: 1;
text-indent: 1em !important;
}
readx is offline   Reply With Quote
Old Today, 06:29 AM   #6
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: 81,050
Karma: 150250725
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by readx View Post
For me the use of p + p would be the easier solution

Code:
p {
text-indent: 0 !important;
}
p + p {
margin: 0 !important;
padding: 0;
widows: 1;
orphans: 1;
text-indent: 1em !important;
}
You don't need !important. Nothing is going to override your p that you cannot fix.
JSWolf is offline   Reply With Quote
Old Today, 07:04 AM   #7
Quoth
Still reading
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
Posts: 15,173
Karma: 111120239
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper
Quote:
Originally Posted by readx View Post
For me the use of p + p would be the easier solution

Code:
p {
text-indent: 0 !important;
}
p + p {
margin: 0 !important;
padding: 0;
widows: 1;
orphans: 1;
text-indent: 1em !important;
}
The previous solution is more general and reliable. Explicit class where you want a specific indent is better and a search should find the things that need the new class.

Last edited by Quoth; Today at 07:06 AM.
Quoth is offline   Reply With Quote
Old Today, 09:00 AM   #8
ryder
Enthusiast
ryder began at the beginning.
 
Posts: 29
Karma: 10
Join Date: May 2024
Device: Clara 2E
Thank you all for the great help.

This solution is working like a charm:

p {
text-indent: 0 !important;
}
p + p {
margin: 0 !important;
padding: 0;
widows: 1;
orphans: 1;
text-indent: 1em !important;
}

I have tested it with 10 ebooks which were poorly made and it still did a great job. Fantastic.

There is only one thing left now, sometimes the chapter title is just above the text without a space line. Is there something to fix that too? I know some ebooks use h3, some h1 for chapter headings. In order the get them all there must be something like:

h1, h2, h3 {
margin-bottom: 1.5em;
}

but that is not working sadly.
Attached Thumbnails
Click image for larger version

Name:	1.jpg
Views:	8
Size:	666.9 KB
ID:	219495  
ryder is offline   Reply With Quote
Old Today, 09:11 AM   #9
ryder
Enthusiast
ryder began at the beginning.
 
Posts: 29
Karma: 10
Join Date: May 2024
Device: Clara 2E
Quote:
Originally Posted by Karellen View Post
And yes, you will have to modify all the scene break p tags to include the class. <p class="scene">Blah blah.</p>
.scene {
padding-bottom: 0;
padding-top: 2em;
text-indent: 0;
}
Thanks for this detailed solution. This sounds more reliable, but also more complicated. I know that not all of the ebooks will handle the following solution:

p {
text-indent: 0 !important;
}
p + p {
margin: 0 !important;
padding: 0;
widows: 1;
orphans: 1;
text-indent: 1em !important;
}

but I am okay with a rate of 90%. Right now I have tested 10 ebooks and they all worked with this method without the scene break p tags. I was wondering if your solution with margin-top and margin-bottom values could be transferred to the space beneath headings to make it equally for every ebook.
ryder is offline   Reply With Quote
Old Today, 09:21 AM   #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: 81,050
Karma: 150250725
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by ryder View Post
Thanks for this detailed solution. This sounds more reliable, but also more complicated. I know that not all of the ebooks will handle the following solution:

p {
text-indent: 0 !important;
}
p + p {
margin: 0 !important;
padding: 0;
widows: 1;
orphans: 1;
text-indent: 1em !important;
}

but I am okay with a rate of 90%. Right now I have tested 10 ebooks and they all worked with this method without the scene break p tags. I was wondering if your solution with margin-top and margin-bottom values could be transferred to the space beneath headings to make it equally for every ebook.
You don't want p + p. Because if you have something such as a <blockquote>, the paragraph after the </blockquote> is not always non-indented.

What you want is this...
Code:
p {
  margin-top: 0;
  margin-bottom: 0;
  widows: 1;
  orphans: 1;
  text-indent: 1.2em;
}
.noindent {
  text-indent: 0;
}
This way you can add a class for where you don't want an indent. Also, you do not need !important. You rarely need it. In the many many eBooks I've edited, I've never once added !important.

Another thing I do is...

Code:
h2 {
  text-align: center;
  text-indent: 0;
  margin-top: 0.8em;
  margin-bottom: 0.8em;
}
hr {
  margin-top: 0.9em;
  margin-right: 40%;
  margin-bottom: 0.9em;
  margin-left: 40%;
  border-top: 2px solid;
}
h2 + p, hr + p, .noindent {
  text-indent: 0;
}
The <hr/> is my section break. I use <h2> for the chapter title. You can change <h2> to whatever you want. So if you only have a 1 line chapter header, you can leave the following <p> without a class and get no indent. Same goes for <p> after the section break.

Last edited by JSWolf; Today at 09:27 AM.
JSWolf is offline   Reply With Quote
Old Today, 12:15 PM   #11
ryder
Enthusiast
ryder began at the beginning.
 
Posts: 29
Karma: 10
Join Date: May 2024
Device: Clara 2E
Quote:
Originally Posted by JSWolf View Post
You don't want p + p. Because if you have something such as a <blockquote>, the paragraph after the </blockquote> is not always non-indented.

What you want is this...
Code:
p {
  margin-top: 0;
  margin-bottom: 0;
  widows: 1;
  orphans: 1;
  text-indent: 1.2em;
}
.noindent {
  text-indent: 0;
}


.
Thanks for your reply. I have tried your solution, but unfortunately it didn't work. The first word after a chapter is still indented. I think your solution will work perfectly with ebooks which are already in a good format, but the ones I have tried had always an indent after the chapter heading and with the p + p solution the indent became 0 for the first words.

Regarding the blockquotes: I have read hundreds of ebooks in the last 10 years and only a couple of them had blockquotes. This is not a very common thing or the creators of ebooks don't use it often.

I am still trying to figure out how the h2 and hr css command work properly, because right now there is no change to be seen.

And is there a downside in using the !important command?
ryder is offline   Reply With Quote
Old Today, 02:02 PM   #12
Karellen
Wizard
Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.
 
Karellen's Avatar
 
Posts: 1,703
Karma: 9500498
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
Quote:
Originally Posted by ryder View Post
I have tried your solution, but unfortunately it didn't work. The first word after a chapter is still indented. I think your solution will work perfectly with ebooks which are already in a good format,
Then you are doing something wrong. Is your stylesheet linked? Are you duplicating the tag in the stylesheet? Might be easier if you post the ebook. Scramble it if it is in copyright.

Quote:
Originally Posted by ryder View Post
Regarding the blockquotes: I have read hundreds of ebooks in the last 10 years and only a couple of them had blockquotes. This is not a very common thing or the creators of ebooks don't use it often.
Really? Most of the books I read use blockquotes. I would suggest that the reason you are not seeing them is because they are poorly formatted books, or it has been stripped during a bad conversion.

Quote:
Originally Posted by ryder View Post
I am still trying to figure out how the h2 and hr css command work properly, because right now there is no change to be seen.
A h2 tag is just like any other tag.
Another failed edit. Your stylesheet is probably not linked.
Karellen is offline   Reply With Quote
Old Today, 03:02 PM   #13
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: 81,050
Karma: 150250725
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by ryder View Post
Thanks for your reply. I have tried your solution, but unfortunately it didn't work. The first word after a chapter is still indented. I think your solution will work perfectly with ebooks which are already in a good format, but the ones I have tried had always an indent after the chapter heading and with the p + p solution the indent became 0 for the first words.

Regarding the blockquotes: I have read hundreds of ebooks in the last 10 years and only a couple of them had blockquotes. This is not a very common thing or the creators of ebooks don't use it often.

I am still trying to figure out how the h2 and hr css command work properly, because right now there is no change to be seen.

And is there a downside in using the !important command?
But if it's not a <blockquote>, it's a <div> and you have the same problem. What you need to do is the first <p> should be <p class="noindent"> unless you do the <h2> for the chapter title.

You use the <h2> like this...
Code:
<h2>Chapter 1</h2>
<p>First paragraph.</p>
And the <hr/> like this...
[code]<p>This is the last paragraph before the section break</p>
<hr/>
<p>This is the start of the next section.</p>[code]

The <p> after the </h2> and <hr/> will not be indented. It's that simple. You can edit <hr> and <h2> how you want.

Last edited by JSWolf; Today at 03:06 PM.
JSWolf is offline   Reply With Quote
Old Today, 03:34 PM   #14
ryder
Enthusiast
ryder began at the beginning.
 
Posts: 29
Karma: 10
Join Date: May 2024
Device: Clara 2E
Quote:
Originally Posted by Karellen View Post
Then you are doing something wrong. Is your stylesheet linked? Are you duplicating the tag in the stylesheet? Might be easier if you post the ebook. Scramble it if it is in copyright.


Really? Most of the books I read use blockquotes. I would suggest that the reason you are not seeing them is because they are poorly formatted books, or it has been stripped during a bad conversion.


A h2 tag is just like any other tag.
Another failed edit. Your stylesheet is probably not linked.
I don't have a stylesheet. I just use extra css and some style rules in the conversion option of calibre. And yes, most of the ebooks are poorly formatted. And for some ebooks I also use the edit option of calibre.

I have found the culprit for my ebook which refused to put some space after a chapter heading.

This is the code:

class="calibre_3"><a href="index_split_002.html#filepos1662"><span class="calibre2">CHAP*TER ONE</span></a>

Is this normal for a chapter beginning? The creator of this ebook included hyperlinks for every heading which brings you back to the beginning of the ebook when clicked. Never saw this before. But I handled it the oldschool way: search and replace the beginning of the chapter with the command <br>
Attached Thumbnails
Click image for larger version

Name:	style rules.jpg
Views:	4
Size:	86.9 KB
ID:	219505  
ryder is offline   Reply With Quote
Old Today, 04:08 PM   #15
Karellen
Wizard
Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.
 
Karellen's Avatar
 
Posts: 1,703
Karma: 9500498
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
Oh, right. You are trying to make all these edits using these rules in conversion dialogue.
Don't do that.

Open your epub in the Editor and make your edits there. Teach yourself how epub coding works, rather than that hit-n-miss approach in conversion. If you don't, you are always going to run into problems and unable to figure out why.
Even your comment "I don't have a stylesheet" is a major red flag issue. Of course you do, but you don't know what it is or where it is. So how can you possibly fix any coding issues?
So, go ahead, open the epub in the Editor and look at how an epub is built.
Karellen 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
Command line, Adding books also picks up metadata not in command used droodled Library Management 2 11-26-2025 10:30 AM
Is there a way to execute a non-root command without access to command line Galunid Kindle Developer's Corner 4 05-15-2018 08:50 PM
Aldiko & Calibre Indent Woe. Themus Calibre 1 05-19-2012 05:37 PM
Calibre Indent Issue When Removing Blank Lines (Converting From HTML to MOBI or EPUB) David Derrico Calibre 5 08-04-2010 01:13 AM
calibre command line utilities and calibre defaults astrodad Calibre 2 08-07-2008 04:27 PM


All times are GMT -4. The time now is 07:49 PM.


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