Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 10-13-2024, 08:40 AM   #1
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,536
Karma: 19000001
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Inconsistent styling of comments in book details

I have books with apparently the same comment formatting, but which are displayed differently in the book details panel: some have spaces between paragraphs, some don't. I can't find a reason for this. A couple of examples:

No spacing:


Spacing:


(left: book details panel; right: edit metadata dialog, HTML source tab.)

I don't see anything relevant in the HTML, do you? This is just after starting up calibre, no edits have been done.

There's the global styling mentioned here (https://www.mobileread.com/forums/sh...d.php?t=325867). But is there also some per-book styling? Or what is going on?
Attached Thumbnails
Click image for larger version

Name:	Screenshot_1.png
Views:	150
Size:	13.1 KB
ID:	211388   Click image for larger version

Name:	Screenshot_2.png
Views:	143
Size:	17.5 KB
ID:	211389  
Jellby is offline   Reply With Quote
Old 10-13-2024, 12:38 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 44,416
Karma: 23977332
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
It's likely something in the underlying html that gets stripped out byt the conversion betwene normal and HTML view. try switching to normal view then back to html then clicking ok, does rendering normalise?
kovidgoyal is offline   Reply With Quote
Advert
Old 10-13-2024, 01:53 PM   #3
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,536
Karma: 19000001
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Hmm... Going to HTML and and back to normal view makes the spacing appear in normal view, but no change in the panel. Of course, because I didn't make any edit. If I make some change (e.g. delete a letter), then the spacing appears alright. Interestingly, if in normal view I select all text and clear formatting... the spacing disappears, but that's a red herring, because the spacing is still there once I go to HTML and back or save.

Is there some easy way to apply this normalization to all books?
Jellby is offline   Reply With Quote
Old 10-13-2024, 02:21 PM   #4
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,962
Karma: 7225107
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Jellby View Post
Is there some easy way to apply this normalization to all books?
It might be too big a hammer, but the Comments Cleaner plugin might do what you want.
chaley is offline   Reply With Quote
Old 10-13-2024, 02:44 PM   #5
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,962
Karma: 7225107
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
FWIW: I found an example in my test library. Starting out, the raw HTML for a comment is
Code:
<div>05/07/13<div>Dernière page lue : Emplacement 6514 (99%)</div></div>
Looking at the comment in Edit Metadata I see the text shown in this image:
Click image for larger version

Name:	Clipboard01.png
Views:	24
Size:	17.1 KB
ID:	211392

Clicking the HTML source tab I see:
Click image for larger version

Name:	Clipboard02.png
Views:	27
Size:	8.6 KB
ID:	211393

The source HTML is now transformed. <p> tags are added around the date and the nested <div> is changed to <p>.

The Normal view is now:
Click image for larger version

Name:	Clipboard03.png
Views:	24
Size:	17.2 KB
ID:	211394

Adding a space after the date to force the comment to be saved, the raw HTML becomes
Code:
<div>\n<p>05/07/13 </p>\n<p>Dernière page lue : Emplacement 6514 (99%)</p></div>
It seems like the transformation also includes pretty-printing the HTML.
chaley is offline   Reply With Quote
Advert
Old 10-13-2024, 10:01 PM   #6
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 44,416
Karma: 23977332
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Yes, the transformation is quite extensive, it has to be because the Qt rich text editor really badly mangles HTML, so calibre tries hard to reverse as much of the damage as possible. I dont think there is a bulk tool to apply that normalisation builtin but as chaley suggested the Comment cleaner plugin might do the trick.
kovidgoyal is offline   Reply With Quote
Old Yesterday, 10:43 AM   #7
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,962
Karma: 7225107
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Here is an action chain that uses the same method as calibre's comments editor to transform (clean) comments. Add it to Action Chains, which will create a chain "Clean comments for selected books". Apply it by selecting some books then running the chain. If you are brave, select your entire library.

As it uses calibre's method it shouldn't change anything that calibre's editor wouldn't change. That said, make a backup of your library before using it.

This is the template it uses to do the work.
Code:
python:
def evaluate(book, context):
	from Qt.core import QTextEdit
	from calibre.gui2.comments_editor import fix_html

	e = QTextEdit()
	e.setHtml(book.comments)
	ans = fix_html(e.toHtml(), e.toPlainText())
	return ans
Attached Files
File Type: zip Clean_comments_for_selected_books.zip (579 Bytes, 2 views)
chaley is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Styling book comments (description) with CSS tgiladi Library Management 24 03-10-2024 12:21 PM
Display composite columns with comments in book details chaley Library Management 5 03-08-2023 04:01 AM
How to format all books comments (book details panel) ? Cyril Gabard Calibre 38 12-07-2019 04:43 PM
[Nook] Comments not showing in book details ienosos Devices 10 02-02-2019 07:44 AM
Changing font size in Book Details Comments BookJunkieLI Library Management 5 02-13-2012 09:42 AM


All times are GMT -4. The time now is 08:22 PM.


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