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 06-24-2020, 11:44 PM   #1
Jabbergeist
Junior Member
Jabbergeist began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Apr 2020
Device: Windows 10 PC: Calibre
Using {comments} in Cover Generation

Hi all,
I did some digging and didn't see any topics about this, but I'm not so good with Calibre's template language or html so this might be a dumb question. I'm trying to get Calibre cover generator to display the text from the book's comments field in the cover's subtitle area. I tried simply using "{comments}" and that seems to work... except the cover displays <div> and <p> html tags also.

Here's an imgur link to an example picture: https://imgur.com/a/vzY8BBZ

Anyone know if this is solvable?
Jabbergeist is offline   Reply With Quote
Old 06-25-2020, 12:25 AM   #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,526
Karma: 24495948
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
No, I'm afraid not, the cover generator cant render HTML only plain text.
kovidgoyal is offline   Reply With Quote
Old 06-25-2020, 12:55 AM   #3
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,475
Karma: 156982136
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by kovidgoyal View Post
No, I'm afraid not, the cover generator can't render HTML only plain text.
Is there any way to easily strip the HTML? I suppose you could use BeautifulSoup get_text but not what the OP wanted.
DNSB is offline   Reply With Quote
Old 06-25-2020, 01:18 AM   #4
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,526
Karma: 24495948
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
It might be possible by defining a column built from other columns that strips the html using a template function and then using that column in the cover generator. I dont recall if the cover generator has direct support for template functions, if so you can skip the creation of the extra column.
kovidgoyal is offline   Reply With Quote
Old 06-25-2020, 12:25 PM   #5
Jabbergeist
Junior Member
Jabbergeist began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Apr 2020
Device: Windows 10 PC: Calibre
Quote:
Originally Posted by kovidgoyal View Post
It might be possible by defining a column built from other columns that strips the html using a template function and then using that column in the cover generator. I dont recall if the cover generator has direct support for template functions, if so you can skip the creation of the extra column.
I wondered if that kind of thing was possible. I was looking through the function documentation and initially thought shorten() would help, but it looks like that removes text from the middle, not the ends. Can you point me toward a resource that would help me figure out how to implement this kind of function?
Jabbergeist is offline   Reply With Quote
Old 06-25-2020, 01:05 PM   #6
Jabbergeist
Junior Member
Jabbergeist began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Apr 2020
Device: Windows 10 PC: Calibre
Never mind- I figured out how to do it by setting up a custom column using the function {comments:substr(9,-10)} and setting that column as the source for the subtitle text in the cover generator.

Thanks for the help!
Jabbergeist is offline   Reply With Quote
Old 06-26-2020, 07:44 AM   #7
Carmelocotonto
Connoisseur
Carmelocotonto began at the beginning.
 
Carmelocotonto's Avatar
 
Posts: 94
Karma: 12
Join Date: Nov 2018
Location: Salamanca
Device: kobo Clara HD, Onyxboox C67
Quote:
Originally Posted by Jabbergeist View Post
Never mind- I figured out how to do it by setting up a custom column using the function {comments:substr(9,-10)} and setting that column as the source for the subtitle text in the cover generator.

Thanks for the help!
Sorry for my question but where is the source for the subtitle text in the cover generator?. I would like to add my custom column: wordcount. Thanks.

Edit. Oh, you are talking about a plugin, no original Calibre, aren't you?

Last edited by Carmelocotonto; 06-26-2020 at 08:23 AM.
Carmelocotonto is offline   Reply With Quote
Old 06-26-2020, 12:02 PM   #8
Jabbergeist
Junior Member
Jabbergeist began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Apr 2020
Device: Windows 10 PC: Calibre
Quote:
Originally Posted by Carmelocotonto View Post
Sorry for my question but where is the source for the subtitle text in the cover generator?. I would like to add my custom column: wordcount. Thanks.

Edit. Oh, you are talking about a plugin, no original Calibre, aren't you?
Nope, I am speaking of the built-in cover generator. To get to it, right click on your book and choose "edit metadata individually." There should be a button near the middle of the window labeled "generate cover." If you left click on it, Calibre will create a simple cover for you using some basic metadata and some random graphical presets.

To customize the cover generation, right-click on the "generate cover" button and click on the "customize" option that will pop up. There will be four tabs to choose from in this window, and the last tab, "text," will allow you to set templates for the title, subtitle, and footer.
Jabbergeist is offline   Reply With Quote
Old 06-26-2020, 06:46 PM   #9
Carmelocotonto
Connoisseur
Carmelocotonto began at the beginning.
 
Carmelocotonto's Avatar
 
Posts: 94
Karma: 12
Join Date: Nov 2018
Location: Salamanca
Device: kobo Clara HD, Onyxboox C67
Quote:
Originally Posted by Jabbergeist View Post
Nope, I am speaking of the built-in cover generator. To get to it, right click on your book and choose "edit metadata individually." There should be a button near the middle of the window labeled "generate cover." If you left click on it, Calibre will create a simple cover for you using some basic metadata and some random graphical presets.

To customize the cover generation, right-click on the "generate cover" button and click on the "customize" option that will pop up. There will be four tabs to choose from in this window, and the last tab, "text," will allow you to set templates for the title, subtitle, and footer.
Oh yes, right-click. No idea. Thanks. I will try.
Carmelocotonto is offline   Reply With Quote
Old 06-26-2020, 08:47 PM   #10
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: 20,994
Karma: 27620706
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Click image for larger version

Name:	Annotation 2020-06-27 094251.jpg
Views:	206
Size:	103.1 KB
ID:	180224

BR
BetterRed is offline   Reply With Quote
Old 06-19-2024, 10:20 AM   #11
Actaeus
Junior Member
Actaeus began at the beginning.
 
Posts: 1
Karma: 10
Join Date: Jun 2024
Device: Kobo Clara 2
Registered just to post this solution.

Jabbergeist's solution works, but it has changed a little bit due to the way calibre has also.

A working solution for Calibre 7.xx that works in the FOOTER TEMPLATE is:

Quote:
program:

#Load Comments
comments = field('comments');

#Eliminate first 8 and last 10 to kill DIV and P text then kill all remaining HTML Tags
comments = substr(comments, 21, -22);
comments = re(comments, '<[^>]*>', '');

# Show at most two authors, on separate lines.
authors = field('authors');
num = count(authors, ' &amp; ');
authors = sublist(authors, 0, 2, ' &amp; ');
authors = list_re(authors, ' &amp; ', '(.+)', '<b>\1');
authors = re(authors, ' &amp; ', '<br>');
authors = re(authors, '&amp;&amp;', '&amp;');

# Combine Comments and Authors
comments & '<br><br>' & authors
Actaeus is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Caliber Book Cover generation problem Honeychem Conversion 2 08-06-2015 12:03 PM
Comments in the Cover Browser? Plaquard Calibre 8 05-27-2015 10:00 PM
Cover comments please? BeccaPrice Writers' Corner 79 06-28-2013 09:19 AM
Cover generation, selecting image, from CLI richieadler Plugins 3 11-04-2012 12:32 AM
Ended Kindle 2nd Generation (Nearly New) + Cover a.anonymous Flea Market 3 11-11-2010 07:15 PM


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


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