calibreUserManual,Release2.55.0
Thrillers
.. Crime
.. Horror
etc.
Byusingthehierarchyfeature,youcanseethesegenresinthetagbrowserintreeform,asshowninthescreenimage.
Inthisexampletheoutermostlevel(Genre)isacustomcolumnthatcontainsthegenres.Genrescontainingsub-genres
appearwithasmalltrianglenexttothem.Clickingonthattrianglewillopentheitemandshowthesub-genres,asyou
canseewithHistoryandScienceFiction.
Clickingonagenrecansearchforallbooks withthatgenreorchildrenofthatgenre. . Forexample, , clickingon
ScienceFictioncangiveallthreeofthechildgenres,AlternateHistory,Military, andSpaceOpera. . Clickingon
AlternateHistorywillgivebooksinthatgenre,ignoringthoseinMilitaryandSpaceOpera. Ofcourse,abookcan
havemultiplegenres.IfabookhasbothSpaceOperaandMilitarygenres,thenyouwillseethatbookifyouclickon
eithergenre.Searchingisdiscussedinmoredetailbelow.
AnotherthingyoucanseefromtheimageisthatthegenreMilitaryappearstwice,onceunderHistoryandonceunder
ScienceFiction.Becausethegenresareinahierarchy,thesearetwoseparategenres.Abookcanbeinone,theother,
or(doubtfullyinthiscase)both.Forexample,thebooksinWinstonChurchill’s“TheSecondWorldWar”couldbein
“History.Military”.DavidWeber’sHonorHarringtonbookscouldbein“ScienceFiction.Military”,andforthatmatter
alsoin“ScienceFiction.SpaceOpera.”
Onceagenreexists,thatisatleastonebookhasthatgenre,youcaneasilyapplyittootherbooksbydraggingthe
booksfromthelibraryviewontothegenreyouwantthebookstohave. Youcanalsoapplygenresinthemetadata
editors;moreonthisbelow.
Setup
Bynow,yourquestionmightbe“Howwasallofthisup?”Therearethreesteps:1)createthecustomcolumn,2)tell
calibrethatthenewcolumnistobetreatedasahierarchy,and3)addgenres.
Youcreatethecustomcolumnintheusualway,usingPreferences->Addyourowncolumns. Thisexampleuses
“#genre”asthelookupnameand“Genre”asthecolumnheading. Thecolumntypeis“Comma-separatedtext,like
tags,showninthetagbrowser.”
Thenafterrestartingcalibre,youmusttellcalibrethatthecolumnistobetreatedasahierarchy.GotoPreferences->
LookandFeel->TagBrowserandenterthelookupname“#genre”intothe“Categorieswithhierarchicalitems”box.
PressApply,andyouaredonewithsettingup.
1.9. Tutorials
127
Converter pdf to powerpoint - C# Create PDF from PowerPoint Library to convert pptx, ppt to PDF in C#.net, ASP.NET MVC, WinForms, WPF
Online C# Tutorial for Creating PDF from Microsoft PowerPoint Presentation
change pdf to ppt; converting pdf to powerpoint slides
Converter pdf to powerpoint - VB.NET Create PDF from PowerPoint Library to convert pptx, ppt to PDF in vb.net, ASP.NET MVC, WinForms, WPF
VB.NET Tutorial for Export PDF file from Microsoft Office PowerPoint
convert pdf slides to powerpoint online; how to add pdf to powerpoint slide
calibreUserManual,Release2.55.0
Atthepointtherearenogenresinthecolumn.Weareleftwiththelaststep:howtoapplyagenretoabook.Agenre
doesnotexistincalibreuntilitappearsonatleastonebook.Tolearnhowtoapplyagenreforthefirsttime,wemust
gointosomedetailaboutwhatagenrelookslikeinthemetadataforabook.
Ahierarchyof‘things’isbuiltbycreatinganitemconsistingofphrasesseparatedbyperiods. Continuingthegenre
example,theseitemswould“History.Military”,“Mysteries.Vampire”,“ScienceFiction.SpaceOpera”,etc. Thusto
createanewgenre, youpickabookthatshouldhavethatgenre, edititsmetadata, andenterthenewgenreinto
thecolumnyoucreated. Continuingourexample, , ifyouwanttoassignanewgenre“Comics”withasub-genre
“Superheroes”toabook,youwould‘editmetadata’forthat(comic)book,choosetheCustommetadatatab,andthen
enter“Comics.Superheroes”asshowninthefollowing(ignoretheothercustomcolumns):
Afterdoingtheabove,youseeinthetagbrowser:
128
Chapter1. Sections
C#: How to Use SDK to Convert Document and Image Using XDoc.
You may use our converter SDK to easily convert PDF, Word, Excel, PowerPoint, Tiff, and Dicom files to raster images like Jpeg, Png, Bmp and Gif.
convert pdf file to powerpoint presentation; embed pdf into powerpoint
C# PDF Convert: How to Convert MS PPT to Adobe PDF Document
Microsoft PowerPoint to PDF. |. Home ›› XDoc.Converter ›› C# Converter: PowerPoint to PDF. You maybe interested: PDF in C#,
converting pdf to powerpoint online; convert pdf to powerpoint using
calibreUserManual,Release2.55.0
Fromhereon,toapplythisnewgenretoabook(acomicbook,presumably),youcaneitherdragthebookontothe
genre,oraddittothebookusingeditmetadatainexactlythesamewayasdoneabove.
Searching
Theeasiestwaytosearchforgenresisusingthetagbrowser,clickingonthegenreyouwishtosee. Clickingona
genrewithchildrenwillshowyoubookswiththatgenreandallchildgenres.However,thismightbringupaquestion.
Justbecauseagenrehaschildrendoesn’tmeanthatitisn’tagenreinitsownright.Forexample,abookcanhavethe
genre“History”butnot“History.Military”.Howdoyousearchforbookswithonly“History”?
Thetagbrowsersearchmechanismknowsifanitemhaschildren. Ifitdoes,clickingontheitemcyclesthrough
5searchesinsteadofthenormalthree. Thefirstisthenormalgreenplus,whichshowsyoubookswiththatgenre
only(e.g.,History). Thesecondisadoubledplus(shownabove),whichshowsyoubookswiththatgenreandall
sub-genres(e.g.,HistoryandHistory.Military). Thethirdisthenormalredminus,whichshowsyoubookswithout
thatexactgenre.Thefourthisadoubledminus,whichshowsyoubookswithoutthatgenreorsub-genres.Thefifthis
backtothebeginning,nomark,meaningnosearch.
Restrictions
Ifyousearchforagenrethencreateasavedsearchforit,youcanusethe‘restrictto’boxtocreateavirtuallibraryof
bookswiththatgenre.Thisisusefulifyouwanttodoothersearcheswithinthegenreortomanage/updatemetadata
forbooksinthegenre. Continuingourexample,youcancreateasavedsearchnamed‘History.Japanese’byfirst
clickingonthegenreJapaneseinthetagbrowsertogetasearchintothesearchbox,enteringHistory.Japaneseintothe
savedsearchbox,thenpushingthe“savesearch”button(thegreenboxwiththewhiteplus,ontheright-handside).
1.9. Tutorials
129
XDoc.Converter for .NET, Support Documents and Images Conversion
file converter SDK supports various commonly used document and image file formats, including Microsoft Office (2003 and 2007) Word, Excel, PowerPoint, PDF, Tiff
convert pdf to powerpoint online for; how to convert pdf into powerpoint presentation
Online Convert PowerPoint to PDF file. Best free online export
Online Powerpoint to PDF Converter. Download Free Trial. Convert a PPTX/PPT File to PDF. Just upload your file by clicking on the blue
pdf to powerpoint; drag and drop pdf into powerpoint
calibreUserManual,Release2.55.0
Aftercreatingthesavedsearch,youcanuseitasarestriction.
UsefulTemplateFunctions
Youmightwanttousethegenreinformationinatemplate,suchaswithsavetodiskorsendtodevice.
Thequestionmightthenbe“HowdoIgettheoutermostgenrenameornames?” Acalibretemplate
function,subitems,isprovidedtomakedoingthiseasier.
Forexample,assumeyouwanttoaddtheoutermostgenreleveltothesave-to-disktemplatetomakegenre
folders,asin“History/TheGatheringStorm-Churchill,Winston”. Todothis,youmustextractthefirst
levelofthehierarchyandaddittothefrontalongwithaslashtoindicatethatitshouldmakeafolder.
Thetemplatebelowaccomplishesthis:
{#genre:subitems(0,1)||/}{title} - {authors}
SeeThetemplatelanguage(page132)formoreinformationabouttemplatesandthesubitems()function.
1.9.2 XPathTutorial
Inthistutorial,youwillbegivenagentleintroductiontoXPath
74
,aquerylanguagethatcanbeusedtoselectarbitrary
partsofHTML
75
documentsincalibre.XPathisawidelyusedstandard,andgooglingitwillyieldatonofinformation.
Thistutorial,however,focusesonusingXPathforebookrelatedtaskslikefindingchapterheadingsinanunstructured
HTMLdocument.
74
http://en.wikipedia.org/wiki/XPath
75
http://en.wikipedia.org/wiki/HTML
130
Chapter1. Sections
RasterEdge XDoc.PowerPoint for .NET - SDK for PowerPoint Document
Able to view and edit PowerPoint rapidly. Convert. Convert PowerPoint to PDF. Convert PowerPoint to HTML5. Convert PowerPoint to Tiff. Convert PowerPoint to Jpeg
convert pdf to powerpoint slide; how to convert pdf to ppt
C# WinForms Viewer: Load, View, Convert, Annotate and Edit
View PDF in WPF; C#.NET: View Word in WPF; C#.NET: View Excel in WPF; C#.NET: View PowerPoint in WPF; C#.NET: View Tiff in WPF. XDoc.Converter for C#; XDoc.PDF
conversion of pdf into ppt; converter pdf to powerpoint
calibreUserManual,Release2.55.0
Contents
• Selectingbytagname(page131)
• Selectingbyattributes(page131)
• Selectingbytagcontent(page132)
• Sampleebook(page132)
• XPathbuilt-infunctions(page132)
Selectingbytagname
Thesimplestformofselectionistoselecttagsbyname.Forexample,supposeyouwanttoselectallthe<h2>tagsin
adocument.TheXPathqueryforthisissimply:
//h:h2
(Selects all <h2tags)
Theprefix//meanssearchatanylevelofthedocument. Nowsupposeyouwanttosearchfor<span>tagsthatare
inside<a>tags.Thatcanbeachievedwith:
//h:a/h:span
(Selects <spantags inside <atags)
Ifyouwanttosearchfortagsataparticularlevelinthedocument,changetheprefix:
/h:body/h:div/h:p (Selects <ptags that are e children n of <divtags that are
children of f the <bodytag)
This will matchonly y <p>A A very short ebook to demonstrate e the e use of XPath.</p> > in the
Sampleebook(page132)butnotanyoftheother<p>tags. Theh: : prefixintheaboveexamplesisneededto
matchXHTMLtags. Thisisbecauseinternally,calibrerepresentsallcontentasXHTML.InXHTMLtagshavea
namespace,andh:isthenamespaceprefixforHTMLtags.
Nowsupposeyouwanttoselectboth<h1>and<h2>tags. Todothat,weneedaXPathconstructcalledpredicate.
Apredicateissimplyatestthatisusedtoselecttags.Testscanbearbitrarilypowerfulandasthistutorialprogresses,
youwillseemorepowerfulexamples.Apredicateiscreatedbyenclosingthetestexpressioninsquarebrackets:
//
*
[name()='h1' or name()='h2']
ThereareseveralnewfeaturesinthisXPathexpression.Thefirstistheuseofthewildcard
*
.Itmeansmatchanytag.
Nowlookatthetestexpressionname()=’h1’ or name()=’h2’.name()isanexampleofabuilt-infunction.It
simplyevaluatestothenameofthetag.Sobyusingit,wecanselecttagswhosenamesareeitherh1orh2.Notethat
thename()functionignoresnamespacessothatthereisnoneedfortheh:prefix. XPathhasseveralusefulbuilt-in
functions.Afewmorewillbeintroducedinthistutorial.
Selectingbyattributes
Toselecttagsbasedontheirattributes,theuseofpredicatesisrequired:
//
*
[@style]
(Select all tags s that have a style attribute)
//
*
[@class="chapter"]
(Select all tags s that have class="chapter")
//h:h1[@class="bookTitle"] (Select all h1 tags that have class="bookTitle")
Here,the@operatorreferstotheattributesofthetag.YoucanusesomeoftheXPathbuilt-infunctions(page132)to
performmoresophisticatedmatchingonattributevalues.
1.9. Tutorials
131
C# powerpoint - Convert PowerPoint to PDF in C#.NET
RasterEdge Visual C# .NET PowerPoint to PDF converter library control (XDoc.PowerPoint) is a mature and effective PowerPoint document converting utility.
pdf to ppt; convert pdf into ppt
VB.NET PDF Converter Library SDK to convert PDF to other file
editing if they integrate this VB.NET PDF converter control with for converting MicroSoft Office Word, Excel and PowerPoint document to PDF file in VB
convert pdf into powerpoint; and paste pdf into powerpoint
calibreUserManual,Release2.55.0
Selectingbytagcontent
UsingXPath,youcanevenselecttagsbasedonthetexttheycontain.Thebestwaytodothisistousethepowerof
regularexpressionsviathebuilt-infunctionre:test():
//h:h2[re:test(.'chapter|section''i')] (Selects <h2tags that contain n the e words chapter or
section)
Herethe.operatorreferstothecontentsofthetag,justasthe@operatorreferredtoitsattributes.
Sampleebook
<html>
<head>
<title>A very y short t ebook</title>
<meta name="charset" value="utf-8" />
</head>
<body>
<h1 class="bookTitle">A very y short ebook</h1>
<style="text-align:right">Written by y Kovid Goyal</p>
<div class="introduction">
<p>A very y short t ebook to demonstrate the use of XPath.</p>
</div>
<h2 class="chapter">Chapter One</h2>
<p>This is s a a truly fascinating chapter.</p>
<h2 class="chapter">Chapter Two</h2>
<p>A worthy continuation n of f a a fine e tradition.</p>
</body>
</html>
XPathbuilt-infunctions
name() Thenameofthecurrenttag.
contains() contains(s1, , s2)returnstrueifs1containss2.
re:test() re:test(src, , pattern, flags)returnstrueifthestringsrcmatchestheregularexpressionpat-
tern.Aparticularlyusefulflagisi,itmakesmatchingcaseinsensitive.Agoodprimeronthesyntaxforregular
expressionscanbefoundatregexpsyntax
76
1.9.3 Thecalibretemplatelanguage
Thecalibretemplatelanguageisusedinvariousplaces. Itisusedtocontrolthefolderstructureandfilenamewhen
savingfilesfromthecalibrelibrarytothediskoreBookreader.Itisalsousedtodefine“virtual”columnsthatcontain
datafromothercolumnsandsoon.
Thebasictemplatelanguageisverysimple,buthasverypowerfuladvancedfeatures.Thebasicideaisthatatemplate
consistsoftextandnamesincurlybracketsthatarethenreplacedbythecorrespondingmetadatafromthebookbeing
processed.So,forexample,thedefaulttemplateusedforsavingbookstodeviceincalibreis:
{author_sort}/{title}/{title} {authors}
76
https://docs.python.org/2.7/library/re.html
132
Chapter1. Sections
calibreUserManual,Release2.55.0
Forthebook“TheFoundation”by“IsaacAsimov”itwillbecome:
Asimov, Isaac/The Foundation/The e Foundation Isaac c Asimov
Theslashesaretext,whichisputintothetemplatewhereitappears.Forexample,ifyourtemplateis:
{author_sort} Some Important Text {title}/{title} {authors}
Forthebook“TheFoundation”by“IsaacAsimov”itwillbecome:
Asimov, Isaac Some Important Text The e Foundation/The e Foundation Isaac Asimov
Youcanuseallthevariousmetadatafieldsavailableincalibreinatemplate,includinganycustomcolumnsyouhave
createdyourself.Tofindoutthetemplatenameforacolumnsimplyhoveryourmouseoverthecolumnheader.Names
forcustomfields(columnsyouhavecreatedyourself)alwayshavea#asthefirstcharacter. Forseriestypecustom
fields,thereisalwaysanadditionalfieldnamed#seriesname_indexthatbecomestheseriesindexforthatseries.
Soifyouhaveacustomseriesfieldnamed#myseries,therewillalsobeafieldnamed#myseries_index.
Inadditiontothecolumnbasedfields,youalsocanuse:
{formats} list of f formats s available in the calibre e library for a book
{identifiers:select(isbn)} The ISBN number of f the book
Ifaparticularbookdoesnothaveaparticularpieceofmetadata,thefieldinthetemplateisautomaticallyremovedfor
thatbook.Consider,forexample:
{author_sort}/{series}/{title} {series_index}
Ifabookhasaseries,thetemplatewillproduce:
Asimov, Isaac/Foundation/Second d Foundation 3
andifabookdoesnothaveaseries:
Asimov, Isaac/Second d Foundation
(calibreautomaticallyremovesmultipleslashesandleadingortrailingspaces).
Advancedformatting
Youcandomorethanjustsimplesubstitutionwiththetemplates.Youcanalsoconditionallyincludetextandcontrol
howthesubstituteddataisformatted.
First,conditionallyincludingtext. Therearecaseswhereyoumightwanttohavetextappearintheoutputonlyif
afieldisnotempty. Acommoncaseisseriesandseries_index,whereyouwanteithernothingorthetwo
valueswithahyphenbetweenthem.Calibrehandlesthiscaseusingaspecialfieldsyntax.
Forexample,assumeyouwanttousethetemplate:
{series} {series_index} {title}
Ifthebookhasnoseries,theanswerwillbe- - title. . Manypeoplewouldrathertheresultbesimplytitle,
withoutthehyphens.Todothis,usetheextendedsyntax{field:|prefix_text|suffix_text}.Whenyou
usethissyntax,iffieldhasthevalueSERIESthentheresultwillbeprefix_textSERIESsuffix_text.Iffield
hasnovalue,thentheresultwillbetheemptystring(nothing);theprefixandsuffixareignored.Theprefixandsuffix
cancontainblanks.Donotusesubtemplates(‘{...}‘)orfunctions(seebelow)astheprefixorthesuffix.
Usingthissyntax,wecansolvetheaboveseriesproblemwiththetemplate:
1.9. Tutorials
133
calibreUserManual,Release2.55.0
{series}{series_index:| - - | | - }{title}
Thehyphenswillbeincludedonlyifthebookhasaseriesindex,whichitwillhaveonlyifithasaseries.
Notes:youmustincludethe:characterifyouwanttouseaprefixorasuffix.Youmusteitheruseno|charactersor
bothofthem;usingone,asin{field:| - },isnotallowed. . ItisOKnottoprovideanytextforonesideorthe
other,suchasin{series:|| - }.Using{title:||}isthesameasusing{title}.
Second: formatting. . Supposeyouwantedtoensurethattheseries_indexisalwaysformattedasthreedigitswith
leadingzeros.Thiswoulddothetrick:
{series_index:0>3s} Three digits with leading zeros
Ifinsteadofleadingzerosyouwantleadingspaces,use:
{series_index:>3s} Three e digits with leading spaces
Fortrailingzeros,use:
{series_index:0<3s} Three digits with trailing zeros
Ifyouuseseriesindiceswithsubvalues(e.g.,1.1),youmightwanttoensurethatthedecimalpointslineup. For
example,youmightwanttheindices1and2.5toappearas01.00and02.50sothattheywillsortcorrectly.Todothis,
use:
{series_index:0>5.2f} Five e characters, consisting of f two o digits with leading g zeros, , a decimal l point, then digits s after the decimal point
Ifyouwantonlythefirsttwolettersofthedata,use:
{author_sort:.2Only the first two o letter of f the author sort name
Thecalibretemplatelanguagecomesfrompythonandformoredetailsonthesyntaxoftheseadvancedformatting
operations,lookatthePythondocumentation
77
.
Advancedfeatures
Usingtemplatesincustomcolumns
Therearesometimescaseswhereyouwanttodisplaymetadatathatcalibredoesnotnormallydisplay, ortodis-
playdatainawaydifferentfromhowcalibrenormallydoes. Forexample,youmightwanttodisplaytheISBN,a
fieldthatcalibredoesnotdisplay. Youcanusecustomcolumnsforthisbycreatingacolumnwiththetype‘col-
umnbuiltfromothercolumns’(hereaftercalledcompositecolumns),andenteringatemplate. Result: : calibrewill
displayacolumnshowingtheresultofevaluatingthattemplate. TodisplaytheISBN,createthecolumnandenter
{identifiers:select(isbn)}intothetemplatebox.Todisplayacolumncontainingthevaluesoftwoseries
customcolumnsseparatedbyacomma,use{#series1:||,}{#series2}.
Compositecolumnscanuseanytemplateoption,includingformatting.
Youcannotchangethedatacontainedinacompositecolumn.Ifyoueditacompositecolumnbydouble-clickingon
anyitem,youwillopenthetemplateforediting,nottheunderlyingdata. EditingthetemplateontheGUIisaquick
wayoftestingandchangingcompositecolumns.
77 https://docs.python.org/2/library/string.html#format-string-syntax
134
Chapter1. Sections
calibreUserManual,Release2.55.0
Usingfunctionsintemplates-single-functionmode
Supposeyouwanttodisplaythevalueofafieldinuppercase,whenthatfieldisnormallyintitlecase.Youcandothis
(andmanymorethings)usingthefunctionsavailablefortemplates.Forexample,todisplaythetitleinuppercase,use
{title:uppercase()}.Todisplayitintitlecase,use{title:titlecase()}.
Functionreferencesappearintheformatpart,goingafterthe: andbeforethefirst|ortheclosing}. Ifyouhave
bothaformatandafunctionreference,thefunctioncomesafteranother:.Functionsmustalwaysendwith().Some
functionstakeextravalues(arguments),andthesegoinsidethe().
Functionsarealwaysappliedbeforeformatspecifications. Seefurtherdownforanexampleofusingbothaformat
andafunction,wherethisorderisdemonstrated.
The
syntax
for
using
functions
is
{field:function(arguments)},
or
{field:function(arguments)|prefix|suffix}. Arguments s are separated d by commas. . Commas
insideargumentsmustbepreceededbyabackslash(‘\’). Thelast(oronly)argumentcannotcontainaclosing
parenthesis(‘)’).Functionsreturnthevalueofthefieldusedinthetemplate,suitablymodified.
Important: Ifyouhaveprogrammingexperience,pleasenotethatthesyntaxinthismode(singlefunction)isnot
whatyoumightexpect. Stringsarenotquoted. Spacesaresignificant. . Allargumentsmustbeconstants;thereisno
sub-evaluation. Donotusesubtemplates(‘{... }‘)asfunctionarguments. . Instead,usetemplateprogrammode
(page137)andgeneralprogrammode(page158).
Manyfunctionsuseregularexpressions.Inallcases,regularexpressionmatchingiscase-insensitive.
Thefunctionsavailablearelistedbelow.Notethatthedefinitivedocumentationforfunctionsisavailableinthesection
Functionclassification(page142):
• lowercase()–returnvalueofthefieldinlowercase.
• uppercase()–returnthevalueofthefieldinuppercase.
• titlecase()–returnthevalueofthefieldintitlecase.
• capitalize()–returnthevaluewiththefirstletteruppercaseandtherestlowercase.
• contains(pattern, , text if match, text if not match)–checksiffieldcontainsmatches
fortheregularexpressionpattern. Returnstextifmatchifmatchesarefound, , otherwiseitreturnstextifno
match.
• count(separator)–interpretsthevalueasalistofitems s separatedbyseparator, returningthenum-
berofitemsinthelist. Mostlistsuseacommaastheseparator,butauthorsusesanampersand. . Examples:
{tags:count(,)},{authors:count(&)}
• format_number(template)–interpretsthevalueasanumberandformatthatnumberusingapython
formattingtemplatesuchas“{0:5.2f}”or“{0:,d}”or“${0:5,.2f}”. Thefield_namepartofthetemplatemust
bea0(zero)(the“{0:”intheaboveexamples).Seethetemplatelanguageandpythondocumentationformore
examples.Returnstheemptystringifformattingfails.
• human_readable()–expectsthevaluetobeanumberandreturnsastringrepresentingthatnumberinKB,
MB,GB,etc.
• ifempty(text)–ifthefieldisnotempty,returnthevalueofthefield.Otherwisereturntext.
• in_list(separator, , pattern, found_val, not_found_val)–interpretthefieldasalistof
itemsseparatedbyseparator,comparingthepatternagainsteachvalueinthelist.Ifthepatternmatchesavalue,
returnfound_val,otherwisereturnnot_found_val.
• language_codes(lang_strings)–returnthelanguagecodesforthestringspassedinlang_strings.
Thestringsmustbeinthelanguageofthecurrentlocale.Lang_stringsisacomma-separatedlist.
1.9. Tutorials
135
calibreUserManual,Release2.55.0
• language_strings(lang_codes, , localize)–returnthestringsforthelanguagecodespassedin
lang_codes. Iflocalizeiszero,returnthestringsinEnglish. Iflocalizeisnotzero,returnthestringsinthe
languageofthecurrentlocale.Lang_codesisacomma-separatedlist.
• list_item(index, , separator)–interpretthefieldasalistofitemsseparatedbyseparator,returning
theindex‘thitem.Thefirstitemisnumberzero.Thelastitemcanbereturnedusing‘list_item(-1,separator).If
theitemisnotinthelist,thentheemptyvalueisreturned.Theseparatorhasthesamemeaningasinthecount
function.
• lookup(pattern, , field, pattern, field, ..., else_field)–likeswitch,exceptthear-
gumentsarefield(metadata)names,nottext.Thevalueoftheappropriatefieldwillbefetchedandused.Note
thatbecausecompositecolumnsarefields,youcanusethisfunctioninonecompositefieldtousethevalueof
someothercompositefield.Thisisextremelyusefulwhenconstructingvariablesavepaths(morelater).
• re(pattern, , replacement)–returnthefieldafterapplyingtheregularexpression. . Allinstancesof
patternarereplacedwithreplacement.Asinallofcalibre,thesearepython-compatibleregularexpressions.
• select(key)–interpretthefieldasacomma-separatedlistofitems, , withtheitems beingoftheform
“id:value”.Findthepairwiththeidequaltokey,andreturnthecorrespondingvalue.Thisfunctionisparticularly
usefulforextractingavaluesuchasanisbnfromthesetofidentifiersforabook.
• shorten(left t chars, middle text, right chars)–Returnashortenedversionofthefield,
consistingofleftcharscharactersfromthebeginningofthefield,followedbymiddletext,followedbyright
charscharactersfromtheendofthestring. Leftcharsandrightcharsmustbeintegers. Forexample,assume
thetitleofthebookisAncientEnglishLawsintheTimesofIvanhoe,andyouwantittofitinaspaceofat
most15characters.Ifyouuse{title:shorten(9,-,5)},theresultwillbeAncientE-nhoe.Ifthefield’s
lengthislessthanleft chars+right chars+thelengthofmiddle text,thenthefieldwillbeused
intact.Forexample,thetitleTheDomewouldnotbechanged.
• str_in_list(val, , separator, string, found_val, not_found_val)–treatvalasalist
ofitemsseparatedbyseparator,comparingthestringagainsteachvalueinthelist.Ifthestringmatchesavalue,
returnfound_val,otherwisereturnnot_found_val. Ifthestringcontainsseparators,thenitisalsotreatedasa
listandeachvalueischecked.
• subitems(val, , start_index, end_index)–Thisfunctionisusedtobreakapartlistsoftag-like
hierarchicalitemssuchasgenres.Itinterpretsthevalueasacomma-separatedlistoftag-likeitems,whereeach
itemisaperiod-separatedlist. Returnsanewlistmadebyfirstfindingalltheperiod-separatedtag-likeitems,
thenforeachsuchitemextractingthecomponentsfromstart_indextoend_index,thencombiningtheresults
backtogether.Thefirstcomponentinaperiod-separatedlisthasanindexofzero.Ifanindexisnegative,then
itcountsfromtheendofthelist.Asaspecialcase,anend_indexofzeroisassumedtobethelengthofthelist.
Examples:
Assuming a #genre column n containing g "A.B.C":
{#genre:subitems(0,1)} returns "A"
{#genre:subitems(0,2)} returns "A.B"
{#genre:subitems(1,0)} returns "B.C"
Assuming a #genre column n containing g "A.B.C, , D.E":
{#genre:subitems(0,1)} returns "A, D"
{#genre:subitems(0,2)} returns "A.B, D.E"
• sublist(val, , start_index, end_index, separator)–interpretthevalueasa a listofitems
separatedbyseparator,returninganewlistmadefromtheitemsfromstart_index‘to‘end_index.Thefirstitem
isnumberzero.Ifanindexisnegative,thenitcountsfromtheendofthelist.Asaspecialcase,anend_indexof
zeroisassumedtobethelengthofthelist.Examplesassumingthatthetagscolumn(whichiscomma-separated)
contains“A,B,C”:
{tags:sublist(0,1,\,)} returns "A"
{tags:sublist(-1,0,\,)} returns "C"
{tags:sublist(0,-1,\,)} returns "A, B"
136
Chapter1. Sections
Documents you may be interested
Documents you may be interested