Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 01-17-2025, 02:36 PM   #1
ianc
Member
ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.
 
Posts: 16
Karma: 472024
Join Date: Nov 2012
Device: Samsung Galaxy S3
Having trouble adding indents before paragraphs

Hi folks! I've converted a PDF to an EPUB, and spent quite a bit of time trying to straighten it out. For the most part it is pretty good now, but I'm still having an issue. The EPUB now has a blank line between every paragraph. Ideally, what I'd like is no blank lines and indents at the beginning of every paragraph. I cannot seem to do this with Calibre's conversion function however. In Conversion -> Look & Feel -> Layout, if I select 'Remove spacing between paragraphs', it will in fact remove them, but it will not indent the beginning of the paragraph, so I'm just left with a solid block of text. When I look at the HTML in Sigil, every paragraph of text ends in the tags <p></p> right next to each other. I suspect I'm having this issue because Calibre cannot identify the beginning of the paragraph with this formatting. Can anyone suggest a way I can get the paragraph beginnings to indent? Thanks for your thoughts!
ianc is offline   Reply With Quote
Old 01-17-2025, 02:52 PM   #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,615
Karma: 9500498
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
It should be a simple tweak to the CSS file by adding the following code to the paragraph tag...
text-indent: 1em;

If you post a screenshot of the code in the xhtml page, or even post the epub if it is not in copyright, we can tell you which tag to edit in the CSS file.

Though the paragraph ending with <p></p> sounds wrong. Is there a <p> tag at the start of the paragraph?
Karellen is offline   Reply With Quote
Old 01-17-2025, 03:13 PM   #3
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 46,419
Karma: 169098492
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by Karellen View Post
Though the paragraph ending with <p></p> sounds wrong. Is there a <p> tag at the start of the paragraph?
I've seen a couple of calibre conversions where removing blank lines between paragraphs has resulted in leaving <p></p> tags in code view depending on how the blank lines were coded.

So something like:
Code:
<p>This is a paragraph</p><p></p>
DNSB is offline   Reply With Quote
Old 01-17-2025, 03:19 PM   #4
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: 79,796
Karma: 146391129
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 Karellen View Post
It should be a simple tweak to the CSS file by adding the following code to the paragraph tag...
text-indent: 1em;

If you post a screenshot of the code in the xhtml page, or even post the epub if it is not in copyright, we can tell you which tag to edit in the CSS file.

Though the paragraph ending with <p></p> sounds wrong. Is there a <p> tag at the start of the paragraph?
I prefer text-indent: 1.2em;.
JSWolf is offline   Reply With Quote
Old 01-17-2025, 03:27 PM   #5
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 46,419
Karma: 169098492
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by JSWolf View Post
I prefer text-indent: 1.2em;.
Hardly relevant since the OP is likely to pick an indent they prefer.

An alternative in the CSS stylesheet to indent all but first paragraphs might be:

Code:
p { 
    text-indent: 1.5em; 
}

p:first-of-type {
    text-indent: 0;
}
Use the Extra CSS options to insert this.

Going off a vague memory, I took a quick look at the Layout options in conversion and there seems to be a setting to insert an indent when removing spacing between paragraphs. See the attached image.
Attached Thumbnails
Click image for larger version

Name:	Screenshot 2025-01-17 122544.png
Views:	93
Size:	45.3 KB
ID:	213130  

Last edited by DNSB; 01-17-2025 at 03:30 PM.
DNSB is offline   Reply With Quote
Old 01-17-2025, 03:33 PM   #6
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,615
Karma: 9500498
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
Quote:
Originally Posted by DNSB View Post
I've seen a couple of calibre conversions where removing blank lines between paragraphs has resulted in leaving <p></p> tags in code view depending on how the blank lines were coded.

So something like:
Code:
<p>This is a paragraph</p><p></p>
Ok, I haven't come across that. But wasn't really clear whether the text was outside the tags (which I have seen a couple of times), or there were additional tags within the tagged paragraph.
We'll see if a screenshot is posted.
Karellen is offline   Reply With Quote
Old 01-17-2025, 03:46 PM   #7
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: 79,796
Karma: 146391129
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 DNSB View Post
Hardly relevant since the OP is likely to pick an indent they prefer.

An alternative in the CSS stylesheet to indent all but first paragraphs might be:

Code:
p { 
    text-indent: 1.5em; 
}

p:first-of-type {
    text-indent: 0;
}
Use the Extra CSS options to insert this.

Going off a vague memory, I took a quick look at the Layout options in conversion and there seems to be a setting to insert an indent when removing spacing between paragraphs. See the attached image.
But if you want your ePub to also be backwards compatible with ePub2, then you cannot use p:first-of-type. However, if you do as I do and use <h2>chapter header</h2> then you can use...
Code:
h2 + p {
  text-indent; 0;
}
JSWolf is offline   Reply With Quote
Old 01-17-2025, 03:47 PM   #8
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: 79,796
Karma: 146391129
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
I've seen plenty of cases were <p></p> does not cause a line space to be displayed. So it's not good to use that.
JSWolf is offline   Reply With Quote
Old 01-17-2025, 03:51 PM   #9
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 46,419
Karma: 169098492
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by JSWolf View Post
I've seen plenty of cases were <p></p> does not cause a line space to be displayed. So it's not good to use that.
Oddly, that might be why calibre changes the existing code to <p></p> to remove the paragraph spacing.
DNSB is offline   Reply With Quote
Old 01-17-2025, 03:53 PM   #10
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 46,419
Karma: 169098492
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by JSWolf View Post
But if you want your ePub to also be backwards compatible with ePub2, then you cannot use p:first-of-type. However, if you do as I do and use <h2>chapter header</h2> then you can use...
Code:
h2 + p {
  text-indent; 0;
}
Which would only work is there no other code between the </h2> and the <p>. Quite a few ebooks seem to place images, subheaders, etc. between the chapter header with the </hx> ending tag and the initial p.
DNSB is offline   Reply With Quote
Old 01-17-2025, 04:15 PM   #11
ianc
Member
ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.
 
Posts: 16
Karma: 472024
Join Date: Nov 2012
Device: Samsung Galaxy S3
Hi again, and thanks so much for your comments! There actually isn't a <p> tag at the beginning of each paragraph, only a <p></p> at the end of each, which is why I'm surmising that Calibre can't locate the beginning of each paragraph. Screenshot attached.
It sounds like this is bad formatting. Unfortunately, Calibre itself did this when doing the initial conversion from Word DOCX format. This is why I'm wondering how I can correct this. Does that help?
Attached Thumbnails
Click image for larger version

Name:	epub code.png
Views:	97
Size:	39.4 KB
ID:	213131  
ianc is offline   Reply With Quote
Old 01-17-2025, 04:36 PM   #12
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 46,419
Karma: 169098492
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
That is a total mess. You might be able to clean up some of it by using calibre's ebook-editor to replace the <p></p> with a </p><p> basically reversing the two tags and then using the Beautify tool. Ditto for using Sigil as the editor except for using Mend and Prettify instead of Beautify. After this, you will still need to clean up the first paragraph and last paragraphs in each set.
DNSB is offline   Reply With Quote
Old 01-17-2025, 04:47 PM   #13
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 21,752
Karma: 30237526
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by ianc View Post
It sounds like this is bad formatting. Unfortunately, Calibre itself did this when doing the initial conversion from Word DOCX format. This is why I'm wondering how I can correct this. Does that help?
I convert up to a dozen DOCXs to EPUBs a week using calibre, and I never see what you are seeing. The only thing I do with the EPUB's is get a second opinion from the spellchecker in calibre's book editor and get rid of metadata clutter.

The golden rule with DOCX is that you must format the document using the Styles feature of your word processor (MS Word, LO Writer, etc), if you treat your WP program as a glorified typewriter you'll get the sort of effects your seeing.

BR
BetterRed is offline   Reply With Quote
Old 01-17-2025, 05:18 PM   #14
ianc
Member
ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.
 
Posts: 16
Karma: 472024
Join Date: Nov 2012
Device: Samsung Galaxy S3
DNSB - I was thinking about how I could use the find\replace feature to change that, but that sounds like a more elegant solution than the one I had thought of. I'll give it a whirl. Thanks!

BetterRed, a book I really wanted to read was only available in a wretched image scan PDF. I tried to convert that directly in Calibre but no workie. My workaround was to manually delete the covers in Acrobat, then run it through k2pdfopt.exe with OCR turned on, then open that file in word, save it, and convert that in Calibre. Not sure how to format the Word file using the styles feature, but I'm new at this.... :-)
ianc is offline   Reply With Quote
Old 01-17-2025, 05:45 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,615
Karma: 9500498
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
Quote:
Originally Posted by ianc View Post
then open that file in word, save it, and convert that in Calibre.
What you should have done instead is exported it as an epub.
I don't have Word to see if that is an option, but LibreOffice certainly has that option.
The benefit is that it adds the tags around the paragraphs already, then when it imports into Calibre, you just need to do a bit of tidying up, mainly removing the naked <span> tags that do nothing.
But like others have said, you need to ensure you use Styles so all the styling for the various parts of the book are the same, otherwise you end up with a mess in the conversion with lots of different tags and css entries which becomes a nightmare to clean up, even trying to use regex.
Karellen is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Add blank lines between paragraphs. bn_el KOReader 5 11-02-2017 11:14 AM
blank lines between paragraphs franklekens Kobo Reader 71 01-26-2015 12:52 PM
Blank lines between paragraphs? ascherjim OpenInkpot 30 12-03-2009 12:19 AM
Removing blank lines between paragraphs? corroonb Workshop 3 08-13-2009 04:23 PM
Insert Blank Lines Between Paragraphs Timoleon Calibre 14 03-22-2009 02:43 PM


All times are GMT -4. The time now is 04:37 AM.


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