View Single Post
Old 10-14-2024, 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: 12,511
Karma: 8065348
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, 136 views)

Last edited by chaley; 01-06-2025 at 05:46 AM. Reason: Fix error in template. Qt should be qt.
chaley is offline   Reply With Quote