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-11-2022, 03:57 AM   #1
TreeFrogBandit
Junior Member
TreeFrogBandit began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Feb 2020
Device: none
Short title template function

Hi everyone, sorry if this has already been answered. I have quite a lot of academic titles in my library and they have really long titles. I want to shorten the titles so they will fit on the covers that I generate for using the generate cover plugin.

I can use {title:shorten(50,,0)} to only give me the first 50 characters of each title, but it's not very aesthetically pleasing - because it cuts off the end of words most of the time.

Is there a function I can use to return the first n words of a title (based on separation by spaces) or automatically returns everything before the colon that nearly always sneaks into academic titles?
TreeFrogBandit is offline   Reply With Quote
Old 06-11-2022, 05:30 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: 12,358
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by TreeFrogBandit View Post
Is there a function I can use to return the first n words of a title (based on separation by spaces)
This.
Code:
{title:sublist(0,4, )}
Note that the spaces are significant.
Quote:
or automatically returns everything before the colon that nearly always sneaks into academic titles?
This.
Code:
{title:sublist(0,1,:)}
You can also combine the two, taking the first N words of the title before a colon. N == 4 in this example.
Code:
{title:'sublist(sublist($, 0, 1, ':'), 0, 4, ' ')'}
chaley is offline   Reply With Quote
Advert
Old 06-11-2022, 05:37 AM   #3
TreeFrogBandit
Junior Member
TreeFrogBandit began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Feb 2020
Device: none
Excellent! Thanks
TreeFrogBandit is offline   Reply With Quote
Reply

Tags
custom columns, custom covers, template editor, template language


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Contribution: DDC Headings template function isra00 Library Management 0 02-28-2022 01:14 PM
BuiltinAdd template language function DyckBook Editor 4 10-19-2021 04:21 PM
Using built-in template functions in a custom template function ilovejedd Library Management 4 01-28-2018 12:20 PM
Problem with contains function in save template MicaOlaAdams Calibre 5 10-21-2016 10:25 AM
how to use re() function in Template Program Mode? msciwoj Library Management 3 07-07-2016 03:55 PM


All times are GMT -4. The time now is 12:39 AM.


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