Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 08-03-2024, 05:35 PM   #1
d3m0sth3n3s
Member
d3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toys
 
d3m0sth3n3s's Avatar
 
Posts: 23
Karma: 5854
Join Date: Jun 2012
Location: Spain
Device: Kindle DX, Kindle Paperwhite, and Kindle Scribe
Convert comments field to HTML in bulk

Hi!

I have read in these forums that while comments are displayed/edited as HTML they are not always stored internally as HTML code, depending on where they originally come from. Sometimes they are just stored as plain text. After you edit a comment using the calibre metadata editor it is always stored as HTML internally.

That said, is there any way to get all the comments in a bunch of books converted to HTML the same way the metadata editor would do? Some template that performs this operation in bulk?
d3m0sth3n3s is offline   Reply With Quote
Old 08-03-2024, 06:06 PM   #2
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 30,453
Karma: 58055868
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
While you may paste plain text, there is always HTML on that tab.
It is just simple. <p>words</p>
Same as you would get by 'using the remove formatting (of selected text)
theducks is online now   Reply With Quote
Old 08-03-2024, 06:25 PM   #3
d3m0sth3n3s
Member
d3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toys
 
d3m0sth3n3s's Avatar
 
Posts: 23
Karma: 5854
Join Date: Jun 2012
Location: Spain
Device: Kindle DX, Kindle Paperwhite, and Kindle Scribe
Quote:
Originally Posted by theducks View Post
While you may paste plain text, there is always HTML on that tab.
It is just simple. <p>words</p>
I know that. The thing is I’m not talking about manually pasting text (for an individual e-book) into the Comments field using the calibre GUI metadata editor.

I have lots of e-books in ePub format whose Comments field was filled during the import process and it is stored internally in plain text (in the Comments field in the calibre database). I want to convert the Comments format for those e-books to HTML prior to some regex Search & Replace tweak. To that end, I need that all my e-books have their Comments field stored internally in HTML.
d3m0sth3n3s is offline   Reply With Quote
Old 08-03-2024, 06:48 PM   #4
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 76,494
Karma: 136564766
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by d3m0sth3n3s View Post
I know that. The thing is I’m not talking about manually pasting text (for an individual e-book) into the Comments field using the calibre GUI metadata editor.

I have lots of e-books in ePub format whose Comments field was filled during the import process and it is stored internally in plain text (in the Comments field in the calibre database). I want to convert the Comments format for those e-books to HTML prior to some regex Search & Replace tweak. To that end, I need that all my e-books have their Comments field stored internally in HTML.
Why do you need all of your comments to be HTML?

All of your comments are converted to HTML if they are not HTML. So you don't need to convert them. Select a book you think has the comments not in HTML. Press the E key and then under the blurb, click the HTML Source tab. You'll see that it is HTML.
JSWolf is offline   Reply With Quote
Old 08-03-2024, 06:55 PM   #5
d3m0sth3n3s
Member
d3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toys
 
d3m0sth3n3s's Avatar
 
Posts: 23
Karma: 5854
Join Date: Jun 2012
Location: Spain
Device: Kindle DX, Kindle Paperwhite, and Kindle Scribe
Quote:
Originally Posted by JSWolf View Post
All of your comments are converted to HTML if they are not HTML. So you don't need to convert them. Select a book you think has the comments not in HTML. Press the E key and then under the blurb, click the HTML Source tab. You'll see that it is HTML.
No, you are mistaken. That is what the Qt GUI component implementing the Comments metadata editor shows you, not what it is really stored in the calibre database. Check this:

Quote:
Originally Posted by kovidgoyal View Post
That's probably because it is actually just a <p><br> (the markup you see via the edit metadata dialog is not an accurate representation of what is present internally as it is roundtripped through Qt's text edit widget.
d3m0sth3n3s is offline   Reply With Quote
Old 08-03-2024, 06:58 PM   #6
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 76,494
Karma: 136564766
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by d3m0sth3n3s View Post
No, you are mistaken. That is what the Qt GUI component implementing the Comments metadata editor shows you, not what it is really stored in the calibre database. Check this:
If it doesn't store the blurb as HTML, then how is text being made bold? I've some blurbs from the eBook that have some text bold.

Why is it you need the blurb to be HTML?
JSWolf is offline   Reply With Quote
Old 08-03-2024, 07:13 PM   #7
d3m0sth3n3s
Member
d3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toys
 
d3m0sth3n3s's Avatar
 
Posts: 23
Karma: 5854
Join Date: Jun 2012
Location: Spain
Device: Kindle DX, Kindle Paperwhite, and Kindle Scribe
Quote:
Originally Posted by JSWolf View Post
If it doesn't store the blurb as HTML, then how is text being made bold?
It’s bold because calibre stores it as HTML But that is AFTER you edited the Comments field with the GUI metadata editor. If it was imported as plain text and you left the Comments field untouched in the GUI it is kept as plain text internally in calibre database. The HTML code you see in the Comments metadata editor is not an accurate representation of the real information stored in the database. That can be plain text!
d3m0sth3n3s is offline   Reply With Quote
Old 08-03-2024, 07:47 PM   #8
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 40,603
Karma: 157444382
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Odd. When I download metadata, it shows bold, italic, underlines, etc. and those seem to survive closing and re-opening calibre. Perhaps what is stored in the database is not HTML code but the HTML code seems to survive that storage.
DNSB is offline   Reply With Quote
Old 08-03-2024, 09:28 PM   #9
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 21,008
Karma: 27620706
Join Date: Mar 2012
Location: Sydney Australia
Device: none
I have books with plain text comments

Click image for larger version

Name:	Screenshot 2024-08-04 103538.jpg
Views:	191
Size:	221.3 KB
ID:	209927

I'll try to find a way to HTML-ise them in bulk.

@d3m0sth3n3s - I suggest you ask un_pogaz if the Comments Cleaner plugin can convert plain text to simple HTML.

BR

Last edited by BetterRed; 08-03-2024 at 09:48 PM.
BetterRed is online now   Reply With Quote
Old 08-04-2024, 12:42 AM   #10
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,565
Karma: 24495948
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
THere isnt any such tool, though I dont really understand why you need it. All such a tool would do is mostly just wrap blocks in <p> or <div> tags ( dont recall the details).
kovidgoyal is offline   Reply With Quote
Old 08-04-2024, 06:09 AM   #11
d3m0sth3n3s
Member
d3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toys
 
d3m0sth3n3s's Avatar
 
Posts: 23
Karma: 5854
Join Date: Jun 2012
Location: Spain
Device: Kindle DX, Kindle Paperwhite, and Kindle Scribe
Quote:
Originally Posted by kovidgoyal View Post
THere isnt any such tool, though I dont really understand why you need it. All such a tool would do is mostly just wrap blocks in <p> or <div> tags ( dont recall the details).
I want to use a Search & Replace regex that relies on the comments to be in HTML to add some structure and styling to them in bulk. It doesn’t work well for plain text comments so I intended to HTML-ize them as a prior step.

I’m thinking that I would be better coding a more complex template that takes plain text comments into account. Just more work, I’m afraid.

PS: I know it’s not a big problem, it just seems inconsistent to me that the calibre database may store imported comments without styles both in HTML code and in plain text just because you edited them in the GUI metadata editor or not.
d3m0sth3n3s is offline   Reply With Quote
Old 08-04-2024, 07:32 AM   #12
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 21,008
Karma: 27620706
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by d3m0sth3n3s View Post
I want to use a Search & Replace regex that relies on the comments to be in HTML to add some structure and styling to them in bulk. It doesn’t work well for plain text comments so I intended to HTML-ize them as a prior step.

I’m thinking that I would be better coding a more complex template that takes plain text comments into account. Just more work, I’m afraid.

PS: I know it’s not a big problem, it just seems inconsistent to me that the calibre database may store imported comments without styles both in HTML code and in plain text just because you edited them in the GUI metadata editor or not.
It has nothing to do with whether they were edited - mainly tto do with what was embedded in the format file that was used to create the book in the calibre library.

The books in my Test library that have plain text comments would have acquired them from the format files I added… e.g. Book 801 came as a PDF from The Lancet website - calibre extracts the Description property from the PDF metadata and puts it in the Comments column, viz:

Code:
The Lancet, Corrected proof. doi:10.1016/S0140-6736(22)01585-9
Whereas Book 671 came as an EPUB from Verso, the Comments were extracted from the OPF file in the EPUB, viz:

Code:
<description xmlns="http://purl.org/dc/elements/1.1/">&lt;i&gt;&amp;amp;ldquo;It would be an endless task to trace the variety of meannesses, cares, and sorrows, into which women are plunged by the prevailing opinion that they were created rather to feel than reason, and that all the power they obtain, must be obtained by their charms and weakness.&amp;amp;rdquo;&lt;/i&gt;&amp;#8212;Mary Wollstonecraft &lt;br&gt;Composed in 1790, Mary Wollstonecraft&amp;amp;rsquo;s seminal feminist tract &lt;i&gt;A Vindication of the Rights of Woman&lt;/i&gt; broke new ground in its demand for women&amp;amp;rsquo;s education. A Vindication remains one of history&amp;amp;rsquo;s most important and elegant broadsides against sexual oppression. In her introduction, renowned socialist feminist Sheila Rowbotham casts Wollstonecraft&amp;amp;rsquo;s life and work in a new light.</description>
BR
BetterRed is online now   Reply With Quote
Old 08-04-2024, 08:41 AM   #13
d3m0sth3n3s
Member
d3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toys
 
d3m0sth3n3s's Avatar
 
Posts: 23
Karma: 5854
Join Date: Jun 2012
Location: Spain
Device: Kindle DX, Kindle Paperwhite, and Kindle Scribe
Quote:
Originally Posted by BetterRed View Post
It has nothing to do with whether they were edited - mainly to do with what was embedded in the format file that was used to create the book in the calibre library.
Yes, you are right. My explanation was incomplete/misleading.

I just think that if calibre turns a simple comment into HTML code just by, for example, simply adding a comma with no styling involved, whenever you edit comments with the GUI metadata editor, then it would be better for consistency to just store them all in HTML from the very beginning, no matter how comments were defined in the description embedded within the source e-book file you import into your library. That’s just my opinion on the subject.

Last edited by d3m0sth3n3s; 08-04-2024 at 08:44 AM.
d3m0sth3n3s is offline   Reply With Quote
Old 08-04-2024, 04:36 PM   #14
un_pogaz
Chalut o/
un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.
 
un_pogaz's Avatar
 
Posts: 421
Karma: 145424
Join Date: Dec 2017
Device: Kobo
The Plugin Comments Cleaner can convert plain text Comments to HTML comment.
(caution: default settings do many other things)

To search the Not-HTML comment use the query:
Code:
comments:true and not comments:"^</div>"
and to quickly know at a the first glance if a book has Not-HTML comment, go to "Preference > Look & Feel > Column colors" and sélectionné les options
  • If the Column 'Comments' is defined
  • If the Column 'Comments' do not contain the value "</div>"

Note: A html comment has at least one </div>

Last edited by un_pogaz; 08-05-2024 at 06:05 AM.
un_pogaz is offline   Reply With Quote
Old 08-05-2024, 07:23 PM   #15
d3m0sth3n3s
Member
d3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toysd3m0sth3n3s shares his or her toys
 
d3m0sth3n3s's Avatar
 
Posts: 23
Karma: 5854
Join Date: Jun 2012
Location: Spain
Device: Kindle DX, Kindle Paperwhite, and Kindle Scribe
Quote:
Originally Posted by un_pogaz View Post
The Plugin Comments Cleaner can convert plain text Comments to HTML comment.
(caution: default settings do many other things)
Thank you! It works for me.

Also, the tricks to highlight books without HTML comments are quite useful, too.
d3m0sth3n3s is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bulk convert HTML characters for epub christopher88 ePub 13 12-02-2013 01:23 PM
Metadata Comments Field - How to best tweak the html? Chris_Snow Library Management 5 08-13-2013 03:58 AM
Comments field emeybee Calibre 1 05-27-2010 03:01 PM
Comments field banjomike Calibre 7 04-08-2010 03:18 PM
Comments field hyperact Calibre 3 12-28-2008 02:38 PM


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


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