10-13-2024, 09:40 AM | #1 |
frumious Bandersnatch
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? |
10-13-2024, 01:38 PM | #2 |
creator of calibre
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?
|
10-13-2024, 02:53 PM | #3 |
frumious Bandersnatch
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? |
10-13-2024, 03:21 PM | #4 |
Grand Sorcerer
Posts: 12,032
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
It might be too big a hammer, but the Comments Cleaner plugin might do what you want.
|
10-13-2024, 03:44 PM | #5 |
Grand Sorcerer
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> Clicking the HTML source tab I see: 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: 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> |
10-13-2024, 11:01 PM | #6 |
creator of calibre
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.
|
10-14-2024, 11:43 AM | #7 |
Grand Sorcerer
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 |
Thread Tools | Search this Thread |
|
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 |