Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 10-13-2024, 09: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:	187
Size:	13.1 KB
ID:	211388   Click image for larger version

Name:	Screenshot_2.png
Views:	184
Size:	17.5 KB
ID:	211389  
Jellby is offline   Reply With Quote
Old 10-13-2024, 01: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,558
Karma: 24495948
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 online now   Reply With Quote
Old 10-13-2024, 02: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, 03: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: 12,032
Karma: 7257323
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, 03: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: 12,032
Karma: 7257323
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:	45
Size:	17.1 KB
ID:	211392

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

Name:	Clipboard02.png
Views:	48
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:	43
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
Old 10-13-2024, 11: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,558
Karma: 24495948
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 online now   Reply With Quote
Old 10-14-2024, 11: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: 12,032
Karma: 7257323
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, 23 views)
chaley is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

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


All times are GMT -4. The time now is 04:26 AM.


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