![]() |
#1 |
Member
![]() 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! |
![]() |
![]() |
![]() |
#2 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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. |
![]() |
![]() |
Advert | |
|
![]() |
#3 | |
Member
![]() Posts: 10
Karma: 10
Join Date: Mar 2023
Device: Kobo Clara HD 1
|
Quote:
|
|
![]() |
![]() |
![]() |
#4 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 55
Karma: 392326
Join Date: Feb 2023
Device: Kobo Libra 2
|
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.
|
![]() |
![]() |
![]() |
#5 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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.
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Member
![]() Posts: 10
Karma: 10
Join Date: Mar 2023
Device: Kobo Clara HD 1
|
|
![]() |
![]() |
![]() |
#7 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 55
Karma: 392326
Join Date: Feb 2023
Device: Kobo Libra 2
|
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.
|
![]() |
![]() |
![]() |
#8 |
Member
![]() Posts: 10
Karma: 10
Join Date: Mar 2023
Device: Kobo Clara HD 1
|
I mainly used DOCX, but neither PDF nor RTF works.
|
![]() |
![]() |
![]() |
#9 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 55
Karma: 392326
Join Date: Feb 2023
Device: Kobo Libra 2
|
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. |
![]() |
![]() |
![]() |
#10 |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,731
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
|
![]() |
![]() |
![]() |
#11 | |
Member
![]() Posts: 10
Karma: 10
Join Date: Mar 2023
Device: Kobo Clara HD 1
|
Quote:
|
|
![]() |
![]() |
![]() |
#12 | |
Member
![]() Posts: 10
Karma: 10
Join Date: Mar 2023
Device: Kobo Clara HD 1
|
Quote:
|
|
![]() |
![]() |
![]() |
#13 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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 |
![]() |
![]() |
![]() |
#14 | |
Member
![]() Posts: 10
Karma: 10
Join Date: Mar 2023
Device: Kobo Clara HD 1
|
Quote:
|
|
![]() |
![]() |
![]() |
#15 |
Still reading
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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. |
![]() |
![]() |
![]() |
|
![]() |
||||
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 |