![]() |
#1 |
Junior Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9
Karma: 752
Join Date: Feb 2014
Device: none
|
Need a little help manipulating title for generating covers
I've got several books that have a title and subtitle, as in:
No Contest: The Case Against Competition I'd like the "No Contest" to be used in the title template and the "The Case Against Competition" to be used in the subtitle template. The default setting is for the subtitle template to print the series and something else, so I'd like to change that. I tried doing some string manipulation, but my rudimentary Python skills are failing, and the manual doesn't offer much help for a seemingly simple operation. |
![]() |
![]() |
![]() |
#2 |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,601
Karma: 29709834
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
@bittenfig - Is subtitle a separate column (custom)?
Are you referring to the built-in generate cover feature or the optional ==>> [GUI Plugin] Generate Cover plug-in? BR |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Junior Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9
Karma: 752
Join Date: Feb 2014
Device: none
|
@BetterRed: Yes, by "subtitle" I'm referring to the template used in the generate cover feature, not custom metadata. If you click and hold "Generate Cover", the customization option appears. Under the "Text" tab, you can change the subtitle and title templates, which is what I'm trying to do. I just need it to grab the title (as in title the metadata) and for the title template, just use whatever is before ": ", and for the subtitle template use whatever is after ": " for the titles that do contain ": ".
|
![]() |
![]() |
![]() |
#4 | |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,601
Karma: 29709834
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
@bittenfig - OK, what you need is a Regular Expression to pull apart the title column into the two components main title and subtitle, embedded within a Template.
See ==>> All about using regular expressions in calibre See ==>> The calibre template language — Single Function Mode. Scroll down and you'll see this function Quote:
But there are regular contributors here who have expertise at both, hopefully one or other should be able to provide the magic bullets. You might find something useful in this thread ==>> Plugboard, template, and custom composite column recipes BR Last edited by BetterRed; 10-16-2014 at 06:19 PM. |
|
![]() |
![]() |
![]() |
#5 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
Hey, BR, thanks for the recommendation.
![]() @bittenfig, I thiink this should give you what you want. title: Just regex the title and replace ":.*" with nothing. Code:
program: strcat( '<b>', re( field('title'), ':.*$', '' ) ) Use the default template (converted to general program mode) but first check for title-contains-a-colon. If so we use the title and replace "^[^:]*:" with nothing, if not, we continue as we did before. (You can also replace the test block with a blank, or do whatever else you would've otherwise done if the title doesn't have a colon.) Code:
program: contains( field('title'), ':', re( field('title'), '^[^:]*:', '' ), test( field('series'), strcat( '<i>',field('series'),'</i> - ', raw_field('formatted_series_index') ), '' ) ) ![]() Last edited by eschwartz; 10-19-2014 at 11:24 AM. |
![]() |
![]() |
Advert | |
|
![]() |
Tags |
generate cover, metadata, python, templates |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Title bulk edit match - to remove series info from title | Rob557 | Library Management | 30 | 12-09-2014 06:06 AM |
Pubit!/Add Title Previewer shows ellipsis in title bar | schooner1892 | General Discussions | 0 | 09-15-2012 07:04 PM |
Manipulating Catalogue Outputs | LMF | Calibre | 1 | 01-13-2012 06:40 PM |
Generating Author and title from directory structure | Nerumshah | Library Management | 8 | 11-25-2011 02:29 PM |
manipulating/converting pdfs under linux | johnnytruant | iRex | 3 | 02-02-2009 02:57 PM |