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

Go Back   MobileRead Forums > E-Book Software > Calibre > Related Tools

Notices

Reply
 
Thread Tools Search this Thread
Old 04-14-2021, 04:00 AM   #1
jmendes
j2m2
jmendes began at the beginning.
 
jmendes's Avatar
 
Posts: 5
Karma: 10
Join Date: Sep 2019
Location: Portugal
Device: ipad, epub
The footer template (cover generation settings)

Hi,
I want to add a line with the publisher information to the footer template.
How can I do it?

Now the footer template looks like:
Quote:
program:
# Show at most two authors, on separate lines.
authors = field('authors');
num = count(authors, ' & ');
authors = sublist(authors, 0, 2, ' & ');
authors = list_re(authors, ' &amp; ', '(.+)', '<b>\1');
authors = re(authors, ' &amp; ', ' <br>');
re(authors, '&amp; &amp;', ' <br>')
If I add the two lines in bold, the only field that appears is the publisher.

Quote:
program:
# Show at most two authors, on separate lines.
authors = field('authors');
publisher = field('publisher');
num = count(authors, ' &amp; ');
authors = sublist(authors, 0, 2, ' &amp; ');
authors = list_re(authors, ' &amp; ', '(.+)', '<b>\1');
authors = re(authors, ' &amp; ', ' <br>');
re(authors, '&amp; &amp;', ' <br>');
re(publisher, '&amp; &amp;', ' <br>');
Thank you in advance,
Jose
jmendes is offline   Reply With Quote
Old 04-24-2021, 12:45 AM   #2
chinax
Member
chinax composes epic poetry in binary.chinax composes epic poetry in binary.chinax composes epic poetry in binary.chinax composes epic poetry in binary.chinax composes epic poetry in binary.chinax composes epic poetry in binary.chinax composes epic poetry in binary.chinax composes epic poetry in binary.chinax composes epic poetry in binary.chinax composes epic poetry in binary.chinax composes epic poetry in binary.
 
Posts: 24
Karma: 90156
Join Date: Jul 2017
Device: Nook Glowlight, Sony DPT-CP1
simplest solution is adding:
Quote:
strcat(authors, '<br>', field('publisher'));
at the end.

i've done a little explainer which hopefully adds clarity for you or anyone who passes by, but the important bit is above. these comments are probably best read in your template tester!

Quote:
program:
# ok so you know pound signs are comments
authors = field('authors');
publisher = field('publisher');
# these two lines let us call a metadata field by a normal name throughout the program. my "short
# answer" avoids needing this second line by using the built-in field() name instead of assigning
# a nickname, since we don't really transform publisher the way we transform the list of authors

num = count(authors, ' &amp; ');
authors = sublist(authors, 0, 2, ' &amp; ');
# counts the number of authors (we've told it to add one for every '&' sign)
# then reorganizes them into a list ("sublist")

authors = list_re(authors, ' &amp; ', '(.+)', '<b>\1');
authors = re(authors, ' &amp; ', ' <br>');
# these two perform search and replace on the list of authors to remove
# separators and add bold <b> & line break <br> tags in their place

authors = re(authors, '&amp; &amp;', ' <br>');
# this is for if there's accidentally two '&&' signs after the first S&R. it wasn't
# assigned a variable because it was the final output before, but now needs 'authors ='
# since we'll want this incorporated into 'authors' when we use it again below

# re(publisher, '&amp; &amp;', ' <br>'); --- you don't need this. never more than 1 publisher, so no '&&' to replace

# finally, we always 'print' whatever comes last, so you'll have to string everything together with strcat()
# i italicized the publisher to distinguish them but you can remove that if you want
strcat(authors, '<br>', '<i>', publisher)

without comments:
Quote:
program:

authors = field('authors');
publisher = field('publisher');
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;', ' <br>');
strcat(authors, '<br>', '<i>', publisher)
chinax is offline   Reply With Quote
Old 05-02-2021, 08:40 AM   #3
jmendes
j2m2
jmendes began at the beginning.
 
jmendes's Avatar
 
Posts: 5
Karma: 10
Join Date: Sep 2019
Location: Portugal
Device: ipad, epub
Many thanks for your help!
jmendes is offline   Reply With Quote
Reply

Tags
footer template, template

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cover author and pubdate in footer Yeriel Calibre 0 01-19-2021 06:33 AM
Image in PDF footer template ciarant Conversion 2 05-04-2015 06:34 PM
Template Generation BetterRed Library Management 4 10-02-2014 06:40 AM


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


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