![]() |
#1 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 141
Karma: 2382428
Join Date: Feb 2013
Location: California
Device: OnePlus 6 phone, Kobo Clara HD, Libra H2O
|
CSS for book descriptions?
Does one of the CSS files in /data or elsewhere govern the rendering of text on the Description screen (that contains the descriptive metadata visible on the metadata screen in Calibre and in the epub's opf file) that's accessible from, among other places, the Book Information screen for each book? Mainly, I want to create space between paragraphs so that multi-paragraph descriptions don't all look like one paragraph. I can do this by manually adding one space paragraphs in Calibre or in the opf directly, but it would be nice not to have to bother with that.
|
![]() |
![]() |
![]() |
#2 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 122
Karma: 43580
Join Date: Apr 2016
Device: KPW3, Kobo Clara HD, Onyx Boox Nova 2
|
https://github.com/koreader/koreader....lua#L194-L205
https://github.com/koreader/koreader...ua#L1002-L1054 So basically it replaces paragraphs/br tags with new line, and strips the rest. No CSS involved at all. You can probably tinker with those two functions in util.lua, to get what you want, but that'd require you to build your own .apk. |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 141
Karma: 2382428
Join Date: Feb 2013
Location: California
Device: OnePlus 6 phone, Kobo Clara HD, Libra H2O
|
Thanks for pointing the way. I'm using KOReader on a Kobo device, not an Android one, FWIW. But that probably doesn't matter if I'm changing the code and compiling as long as I do it for Kobo. But I don't expect to do that. I was hoping for a CSS solution to this.
|
![]() |
![]() |
![]() |
#4 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,741
Karma: 730681
Join Date: Oct 2014
Location: Antwerp
Device: Kobo Aura H2O
|
That particular bit of code is ~4 years old, so you could also try to rejig it with the newer HTML widget. Could you upload a scrambled sample document that demonstrates the problem?
On Kobo you don't need to build anything to play around with the code btw. For most things like this you can just edit the Lua files directly on the device itself. But be careful, they will be overwritten if you update so you'd better make sure to keep a copy if you do. ![]() |
![]() |
![]() |
![]() |
#5 | |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 141
Karma: 2382428
Join Date: Feb 2013
Location: California
Device: OnePlus 6 phone, Kobo Clara HD, Libra H2O
|
Quote:
There's probably no need for the scrambled epub. Any epub with an opf file with multiple paragraphs of description in the <dc:description> tag will do. This is not a bug or something specific to a particular book. It's universal. Look at what KOReader displays when you bring up that description text the way I mentioned above. There is no spacing between paragraphs or indentation of the first line. In other words, all the paragraphs vertically render so that it looks like there is only one long paragraph. That's why I was hoping to use css properties like margin to create some distance between paragraphs, at least as long as the styles didn't affect anything in the text of the books themselves. The Nickel reader seems to do this by whatever means it uses. I can get around this in KOReader by putting a paragraph containing only a space Code:
<p> </p> ![]() |
|
![]() |
![]() |
Advert | |
|
![]() |
#6 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,741
Karma: 730681
Join Date: Oct 2014
Location: Antwerp
Device: Kobo Aura H2O
|
Quote:
![]() |
|
![]() |
![]() |
![]() |
#7 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 141
Karma: 2382428
Join Date: Feb 2013
Location: California
Device: OnePlus 6 phone, Kobo Clara HD, Libra H2O
|
I've attached a scrambled epub.
Alas, ScrambleEbook removed the description text I'm writing about from the opf. So I replaced it with some Lorem Ipsum stuff. The effect is the same as what I'd mentioned earlier. You'll see that when displaying Book Information > Description that there's no vertical spacing between paragraphs of the text. My hope was to be able to use CSS to create that space. |
![]() |
![]() |
![]() |
#8 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 141
Karma: 2382428
Join Date: Feb 2013
Location: California
Device: OnePlus 6 phone, Kobo Clara HD, Libra H2O
|
Perhaps making it easier for everyone, I took pictures of the screen I'm referring to.
In picture 1, you can see that there's space between the paragraphs. I put that into the metadata in the Calibre "Edit metadata" window by executing a CR in the description text field between each paragraph which causes Calibre to insert a <p> tag with no content other than a space in each such case. Picture 2 shows the way it renders when each paragraph (defined by what's between <p> tags) is not separated by that extra CR/empty <p>. I want it to look like picture 1 without having to edit the html of the metadata to achieve that. I don't mind doing the edits, but that causes excess vertical spacing in the Nickel reader because the latter provides spacing between paragraphs to begin with. I can provide samples of anything else that you might like to see with regard to this, too. |
![]() |
![]() |
![]() |
#9 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,741
Karma: 730681
Join Date: Oct 2014
Location: Antwerp
Device: Kobo Aura H2O
|
I only took a quick peek, but as @Galunid proposed perhaps the to plain text algorithm would behave more as expected like this (certainly a lot quicker than putting in an HTML widget):
Code:
diff --git a/frontend/util.lua b/frontend/util.lua index 863ce849..6293e5c6 100644 --- a/frontend/util.lua +++ b/frontend/util.lua @@ -1002,8 +1002,8 @@ This may fail on complex HTML (with styles, scripts, comments), but should be fi function util.htmlToPlainText(text) -- Replace <br> and <p> with \n text = text:gsub("%s*<%s*br%s*/?>%s*", "\n") -- <br> and <br/> - text = text:gsub("%s*<%s*p%s*>%s*", "\n") -- <p> - text = text:gsub("%s*</%s*p%s*>%s*", "\n") -- </p> + text = text:gsub("%s*<%s*p%s*>%s*", "\n\n") -- <p> + text = text:gsub("%s*</%s*p%s*>%s*", "\n\n") -- </p> text = text:gsub("%s*<%s*p%s*/>%s*", "\n") -- standalone <p/> -- Remove all HTML tags text = text:gsub("<[^>]*>", "") |
![]() |
![]() |
![]() |
#10 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 141
Karma: 2382428
Join Date: Feb 2013
Location: California
Device: OnePlus 6 phone, Kobo Clara HD, Libra H2O
|
![]() |
![]() |
![]() |
![]() |
#11 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,741
Karma: 730681
Join Date: Oct 2014
Location: Antwerp
Device: Kobo Aura H2O
|
Discussion in https://github.com/koreader/koreader/pull/7027
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Adding Book Descriptions, Missing Covers | niagara94 | Library Management | 11 | 02-24-2013 09:12 PM |
Get Book Descriptions WITHOUT going to Amazon | Jesseoffshore | Amazon Kindle | 6 | 05-03-2012 11:09 AM |
Showing Metadata book descriptions from Calibre? | Avid Fan | Amazon Kindle | 5 | 02-29-2012 04:59 PM |
Touch Book descriptions in Kobo Touch library | symon79 | Kobo Reader | 2 | 01-27-2012 02:17 AM |
Adding book descriptions to kindle | buzzandfuzz | Calibre | 0 | 06-14-2010 04:19 PM |