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 02-20-2024, 01:31 AM   #1
tgiladi
Enthusiast
tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.
 
Posts: 26
Karma: 30486
Join Date: Dec 2023
Device: Kindle Oasis
Template language - Conditionally including text

Hi,
I followed the instructions here: https://manual.calibre-ebook.com/template_lang.html and successfully managed to set the save to disk setting to my preferences:
Code:
{series} {series_index:0>2s|#| - }{title} - {authors}
This works very well when saving to disk, so I thought I could use the same technique when customizing my jacket.xhtml template. What I am trying to achieve is having the book's name in it's original language, below the Ttitle. For this I am using a custom column, and I am able to show it without issue if there is data in that column. But what I can't figure out how to do is to have that name in parenthesis like so: (original name). If I add parenthesis to the code, then they would show anyway, even if there is no data in the custom column. I tried this code:
Code:
{_original_name:|(|)}
but it is not working and I get an error when I try to polish the book with this code: ValueError: Invalid format specifier '|(|)' for object of type 'str'

Is there another way to include the parenthesis around the conditional text only if there is data in the custom column?
tgiladi is offline   Reply With Quote
Old 02-20-2024, 09:26 AM   #2
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: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by tgiladi View Post
Hi,
I followed the instructions here: https://manual.calibre-ebook.com/template_lang.html and successfully managed to set the save to disk setting to my preferences:
Code:
{series} {series_index:0>2s|#| - }{title} - {authors}
This works very well when saving to disk, so I thought I could use the same technique when customizing my jacket.xhtml template. What I am trying to achieve is having the book's name in it's original language, below the Ttitle. For this I am using a custom column, and I am able to show it without issue if there is data in that column. But what I can't figure out how to do is to have that name in parenthesis like so: (original name). If I add parenthesis to the code, then they would show anyway, even if there is no data in the custom column. I tried this code:
Code:
{_original_name:|(|)}
but it is not working and I get an error when I try to polish the book with this code: ValueError: Invalid format specifier '|(|)' for object of type 'str'

Is there another way to include the parenthesis around the conditional text only if there is data in the custom column?
I suspect the parser in the jacket processor is not handling the conditional formatting specification correctly. As a workaround, put the parenthesis into your custom column. Or create a new "column built from other columns" that formats the text however you want.
chaley is offline   Reply With Quote
Old 02-20-2024, 12:56 PM   #3
tgiladi
Enthusiast
tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.
 
Posts: 26
Karma: 30486
Join Date: Dec 2023
Device: Kindle Oasis
Thank you for your suggestions! I opted for the custom column built from another column and formatted it to include the parenthesis. This is what I am including in my jacket now and it works exactly as I wanted it.
tgiladi is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Template language changes chaley Library Management 132 03-03-2024 06:34 PM
Template Language Question jvorzimmer Library Management 5 11-20-2021 01:26 PM
Template Language phossler Calibre 8 01-12-2016 04:37 PM
Template language query. Removing all text after a set of characters da_jane Calibre 1 12-14-2012 01:37 PM
Help with template language Pepin33 Calibre 8 11-11-2012 08:32 AM


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


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