Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > KOReader

Notices

Reply
 
Thread Tools Search this Thread
Old 12-19-2020, 05:53 PM   #1
mirage
Zealot
mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.
 
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.
mirage is offline   Reply With Quote
Old 12-20-2020, 01:05 AM   #2
Galunid
Zealot
Galunid herds cats with both ease and graceGalunid herds cats with both ease and graceGalunid herds cats with both ease and graceGalunid herds cats with both ease and graceGalunid herds cats with both ease and graceGalunid herds cats with both ease and graceGalunid herds cats with both ease and graceGalunid herds cats with both ease and graceGalunid herds cats with both ease and graceGalunid herds cats with both ease and graceGalunid herds cats with both ease and grace
 
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.
Galunid is offline   Reply With Quote
Advert
Old 12-20-2020, 02:08 AM   #3
mirage
Zealot
mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.
 
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.
mirage is offline   Reply With Quote
Old 12-20-2020, 04:44 PM   #4
Frenzie
Wizard
Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.
 
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.
Frenzie is offline   Reply With Quote
Old 12-21-2020, 12:56 AM   #5
mirage
Zealot
mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.
 
Posts: 141
Karma: 2382428
Join Date: Feb 2013
Location: California
Device: OnePlus 6 phone, Kobo Clara HD, Libra H2O
Quote:
Originally Posted by Frenzie View Post
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.
OK. Thanks. I should have realized that there's no need to compile since I realized that the lua files are present on the device in that form. I can play with that code.

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>
between all paragraphs with text in the opf for the aforementioned tag. I do this in Calibre, but it probably doesn't matter if I do it there or in Sigil or whatever text editor. That renders vertical space between the paragraphs with content, but I have to go to the trouble of doing it and then the Nickel reader renders the same thing with far too much space because it already handles that rendering with plenty of space to begin with. That's not exactly a catastrophic problem, particularly since I mostly read in KOReader. But why not obsess over it if I can?
mirage is offline   Reply With Quote
Advert
Old 12-21-2020, 04:52 AM   #6
Frenzie
Wizard
Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.
 
Posts: 1,741
Karma: 730681
Join Date: Oct 2014
Location: Antwerp
Device: Kobo Aura H2O
Quote:
Originally Posted by mirage View Post
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.
Whether or not there's a need for a scrambled EPUB, there's a need to not make us waste time trying to find or create an EPUB that displays the relevant properties.
Frenzie is offline   Reply With Quote
Old 12-21-2020, 03:20 PM   #7
mirage
Zealot
mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.
 
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.
Attached Files
File Type: epub ERfd Efdskd - Efire, Rfdklj.epub (488.5 KB, 118 views)
mirage is offline   Reply With Quote
Old 12-21-2020, 04:01 PM   #8
mirage
Zealot
mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.
 
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.
Attached Thumbnails
Click image for larger version

Name:	1.jpg
Views:	154
Size:	131.8 KB
ID:	184174   Click image for larger version

Name:	2.jpg
Views:	148
Size:	132.0 KB
ID:	184175  
mirage is offline   Reply With Quote
Old 12-22-2020, 06:18 AM   #9
Frenzie
Wizard
Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.
 
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("<[^>]*>", "")
Frenzie is offline   Reply With Quote
Old 12-22-2020, 11:51 AM   #10
mirage
Zealot
mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.mirage ought to be getting tired of karma fortunes by now.
 
Posts: 141
Karma: 2382428
Join Date: Feb 2013
Location: California
Device: OnePlus 6 phone, Kobo Clara HD, Libra H2O
mirage is offline   Reply With Quote
Old 12-22-2020, 02:12 PM   #11
Frenzie
Wizard
Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.
 
Posts: 1,741
Karma: 730681
Join Date: Oct 2014
Location: Antwerp
Device: Kobo Aura H2O
Discussion in https://github.com/koreader/koreader/pull/7027
Frenzie is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 12:20 PM.


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