Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 03-02-2023, 02:12 AM   #1
TTimeTraveller
Member
TTimeTraveller began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Mar 2023
Device: Kobo Clara HD 1
Problem with EPUB's stanzas

Hello, I'm trying to convert an EPUB into an usable format for printing. The problem is that after conversion, the blank lines between stanzas are missing. Like this:

This is how it should look:

boss i went
and interviewed the mummy
of the egyptian pharaoh
in the metropolitan museum
as you bade me to do

what ho
my regal leatherface
says i

This is how it looks after conversion with any format:

boss i went
and interviewed the mummy
of the egyptian pharaoh
in the metropolitan museum
as you bade me to do
what ho
my regal leatherface
says i


I've looked into the code but I'm failing to understand why it isn't working.

<div class="block5">
<p class="bl_hanging">boss i went</p>
<p class="bl_hanging">and interviewed the mummy</p>
<p class="bl_hanging">of the egyptian pharaoh</p>
<p class="bl_hanging">in the metropolitan museum</p>
<p class="bl_hanging">as you bade me to do</p>
</div>
<div class="block5">
<p class="bl_hanging">what ho</p>
<p class="bl_hanging">my regal leatherface</p>
<p class="bl_hanging">says i</p>
</div>

When I check the class it looks like this:

div.block5
{
margin-left: 5em;
margin-right: 0em;
text-align:justify;
margin-top: 1em;
margin-bottom: 1em;
}

I only have superficial knowledge of code but I was hoping I could get help on how to fix this. Otherwise I might to manually insert a blank line between each stanza and it would be very time consuming. Thank you so much in any case!
TTimeTraveller is offline   Reply With Quote
Old 03-02-2023, 03:22 AM   #2
Lukusaukko
Connoisseur
Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.
 
Posts: 55
Karma: 392326
Join Date: Feb 2023
Device: Kobo Libra 2
What you see is called collapsing margins, and it's a feature of CSS: Basically it happens here because the margin property refers to the distance from the other element's content, not its margin (that is, because the top and bottom margins are the same, the distance between the contents doesn't change).

There are a few ways you can fix this - what works best depends a bit on your layout. You could set bottom-margin: 2em; or add autoflow: auto; into your style, or you could use padding-top; and padding-bottom; instead of margin. Try out what looks best in your case - each of these has a slightly different effect on the layout.
Lukusaukko is offline   Reply With Quote
Advert
Old 03-02-2023, 03:25 AM   #3
TTimeTraveller
Member
TTimeTraveller began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Mar 2023
Device: Kobo Clara HD 1
Quote:
Originally Posted by Lukusaukko View Post
What you see is called collapsing margins, and it's a feature of CSS: Basically it happens here because the margin property refers to the distance from the other element's content, not its margin (that is, because the top and bottom margins are the same, the distance between the contents doesn't change).

There are a few ways you can fix this - what works best depends a bit on your layout. You could set bottom-margin: 2em; or add autoflow: auto; into your style, or you could use padding-top; and padding-bottom; instead of margin. Try out what looks best in your case - each of these has a slightly different effect on the layout.
Will any of these solutions fix the conversion issue? As in, will the stanza breaks appear after conversion? Thanks btw.
TTimeTraveller is offline   Reply With Quote
Old 03-02-2023, 03:37 AM   #4
Lukusaukko
Connoisseur
Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.
 
Posts: 55
Karma: 392326
Join Date: Feb 2023
Device: Kobo Libra 2
Quote:
Originally Posted by TTimeTraveller View Post
Will any of these solutions fix the conversion issue? As in, will the stanza breaks appear after conversion? Thanks btw.
They should - I haven't tried conversion, but I don't see any reason why it shouldn't work if the conversion implements CSS properly, since it's stardard CSS behaviour.
Lukusaukko is offline   Reply With Quote
Old 03-02-2023, 03:46 AM   #5
Lukusaukko
Connoisseur
Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.
 
Posts: 55
Karma: 392326
Join Date: Feb 2023
Device: Kobo Libra 2
NOTE: I see I had a brainfart above: one of the things you can try is setting "overflow: auto;" - not "autoflow" like I typed.
Lukusaukko is offline   Reply With Quote
Advert
Old 03-02-2023, 03:51 AM   #6
TTimeTraveller
Member
TTimeTraveller began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Mar 2023
Device: Kobo Clara HD 1
Quote:
Originally Posted by Lukusaukko View Post
NOTE: I see I had a brainfart above: one of the things you can try is setting "overflow: auto;" - not "autoflow" like I typed.
I'm very sorry to bother you, but none of these worked. I'm beginning to think this EPUB is cursed.
TTimeTraveller is offline   Reply With Quote
Old 03-02-2023, 04:32 AM   #7
Lukusaukko
Connoisseur
Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.
 
Posts: 55
Karma: 392326
Join Date: Feb 2023
Device: Kobo Libra 2
Quote:
Originally Posted by TTimeTraveller View Post
I'm very sorry to bother you, but none of these worked. I'm beginning to think this EPUB is cursed.
What format are you trying to convert it into? I did a short test, and a PDF works ok, but DOCX doesn't - I suppose the DOCX conversion is pretty bare bones. Other than that, I'm afraid I can't figure out anything else.
Lukusaukko is offline   Reply With Quote
Old 03-02-2023, 04:35 AM   #8
TTimeTraveller
Member
TTimeTraveller began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Mar 2023
Device: Kobo Clara HD 1
Quote:
Originally Posted by Lukusaukko View Post
What format are you trying to convert it into? I did a short test, and a PDF works ok, but DOCX doesn't - I suppose the DOCX conversion is pretty bare bones. Other than that, I'm afraid I can't figure out anything else.
I mainly used DOCX, but neither PDF nor RTF works.
TTimeTraveller is offline   Reply With Quote
Old 03-02-2023, 04:47 AM   #9
Lukusaukko
Connoisseur
Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.
 
Posts: 55
Karma: 392326
Join Date: Feb 2023
Device: Kobo Libra 2
Quote:
Originally Posted by TTimeTraveller View Post
I mainly used DOCX, but neither PDF nor RTF works.
That's odd - I made a EPUB using your html and styles, and just used margin-bottom: 2em; and it worked when converted to PDF.

Just to make sure: it looks like what you want in the EPUB, but only misses the space between div elements in the converted version? I was thinking if there might be something elsewhere in the CSS, in some other style, that overrides the space between divs, but if it looks right in EPUB, it's probably not it... and if it's the case, I'm out of options.
Lukusaukko is offline   Reply With Quote
Old 03-02-2023, 04:51 AM   #10
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,731
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
@TTimeTraveller: if it looks okay in the viewer try printing from there -- it creates a PDF.

Click image for larger version

Name:	Screenshot 2023-03-02 204549.jpg
Views:	132
Size:	146.4 KB
ID:	200051

BR
BetterRed is offline   Reply With Quote
Old 03-02-2023, 06:42 AM   #11
TTimeTraveller
Member
TTimeTraveller began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Mar 2023
Device: Kobo Clara HD 1
Quote:
Originally Posted by Lukusaukko View Post
That's odd - I made a EPUB using your html and styles, and just used margin-bottom: 2em; and it worked when converted to PDF.

Just to make sure: it looks like what you want in the EPUB, but only misses the space between div elements in the converted version? I was thinking if there might be something elsewhere in the CSS, in some other style, that overrides the space between divs, but if it looks right in EPUB, it's probably not it... and if it's the case, I'm out of options.
PDF works for some reason now, but it's not really editable. You are right, it should be something in the CSS. Don't know what though.
TTimeTraveller is offline   Reply With Quote
Old 03-02-2023, 06:47 AM   #12
TTimeTraveller
Member
TTimeTraveller began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Mar 2023
Device: Kobo Clara HD 1
Quote:
Originally Posted by BetterRed View Post
@TTimeTraveller: if it looks okay in the viewer try printing from there -- it creates a PDF.

Attachment 200051

BR
That works but PDF is not useful in my situation.
TTimeTraveller is offline   Reply With Quote
Old 03-02-2023, 08:04 AM   #13
Lukusaukko
Connoisseur
Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.
 
Posts: 55
Karma: 392326
Join Date: Feb 2023
Device: Kobo Libra 2
The problem here is that DOCX as a format does not support cascading formatting. That is, unlike with HTML (EPUB is just a container for HTML), you can't tell it to format all paragraphs inside section/div A like this, and all paragraphs inside section/div B like this - it can only deal with paragraph or character level formatting. And that's why the conversion fails (and also because the conversion is mainly concerned with turning other documents into something for e-readers, so converting e-reader formats to something else isn't a high priority).

So what to do if you both need a well-formatted EPUB and would like to produce equally well-fomatted DOCX out of it? To be honest, I don't really know, to me that sounds like it's the wrong way around - I would first make everything as a Word doc, and then convert the final result to epub.

However, if epub > docx is the correct workflow for whatever reason, I don't think there is any way to avoid inserting empty paragraphs where the break should be. However, this should be fairly easy to do with a simple search and replace: just search for "</div><div class="block5">" and replace it with "</div><p class="break"><br/></p><div class="block5">" and adjust to rest of the styles so the overall look remains the same.

Hopefully that's of some help, even if that's not the answer you were hoping for.

Last edited by Lukusaukko; 03-02-2023 at 08:06 AM. Reason: Fix typos
Lukusaukko is offline   Reply With Quote
Old 03-02-2023, 08:38 AM   #14
TTimeTraveller
Member
TTimeTraveller began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Mar 2023
Device: Kobo Clara HD 1
Quote:
Originally Posted by Lukusaukko View Post
The problem here is that DOCX as a format does not support cascading formatting. That is, unlike with HTML (EPUB is just a container for HTML), you can't tell it to format all paragraphs inside section/div A like this, and all paragraphs inside section/div B like this - it can only deal with paragraph or character level formatting. And that's why the conversion fails (and also because the conversion is mainly concerned with turning other documents into something for e-readers, so converting e-reader formats to something else isn't a high priority).

So what to do if you both need a well-formatted EPUB and would like to produce equally well-fomatted DOCX out of it? To be honest, I don't really know, to me that sounds like it's the wrong way around - I would first make everything as a Word doc, and then convert the final result to epub.

However, if epub > docx is the correct workflow for whatever reason, I don't think there is any way to avoid inserting empty paragraphs where the break should be. However, this should be fairly easy to do with a simple search and replace: just search for "</div><div class="block5">" and replace it with "</div><p class="break"><br/></p><div class="block5">" and adjust to rest of the styles so the overall look remains the same.

Hopefully that's of some help, even if that's not the answer you were hoping for.
Thank you. This is more or less what I did. I got just what I needed so I'll call this great success! Thank you for your time and patience!
TTimeTraveller is offline   Reply With Quote
Old 03-02-2023, 08:39 AM   #15
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: 14,051
Karma: 105092227
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper
It can be fixed by editing the CSS/HTML. Then the docx will work.
I've not seen ebooks with that method for verses.

No empty paragraphs needed. Just a different first line CSS with a top margin of 2em and the divs removed. Or else different first and last line per verse (stanza) with 1em top and 1em bottom respectively, depending on what is after the last stanza.
Quoth is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Conversion problem from ePub to ePub (possibly kepub) brudigia Conversion 7 07-09-2020 06:35 PM
epub to epub conversion problem with regex spanning multiple input files ctop Conversion 2 02-12-2012 01:56 AM
ePub Problem sceadugenga iRiver Story 2 11-19-2011 01:47 AM
epub problem mircea Calibre 3 03-06-2010 02:24 PM
Epub to LRF no problem, Epub to Mobi indexerror Rogier Calibre 3 06-09-2009 11:42 AM


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


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