calibreUserManual,Release2.55.0
1.5.8 MiscellaneousTools
Thereareafewmoretoolsthatcanbeusefulwhileyoueditthebook.
TheTableofContentsView
TheTableofContentsviewshowsyouthecurrenttableofcontentsinthebook.Doubleclickingonanyentryopens
theplacethatentrypointstoinaneditor. YoucanrightclicktoedittheTableofContents, , refreshtheviewor
expand/collapseallitems.AccessthisviewviaView->TableofContents.
Checkingthespellingofwordsinthebook
YoucanrunaspellingcheckerviaTools->Checkspelling.
1.5. EditingE-books
87
Change pdf to ppt - 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
convert pdf to powerpoint online for; pdf to powerpoint converter online
Change pdf to ppt - 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
how to change pdf to powerpoint on; convert pdf back to powerpoint
calibreUserManual,Release2.55.0
Wordsareshownwiththenumberoftimestheyoccurinthebookandthelanguagethewordbelongsto. Language
informationistakenfromthebooksmetadataandfromlangattributesintheHTMLfiles. Thisallowsthespell
checkertoworkwellevenwithbooksthatcontaintextinmultiplelanguages. Forexample,inthefollowingHTML
extract,thewordcolorwillbecheckedusingAmericanEnglishandthewordcolourusingBritishEnglish:
<div lang="en_US">color <span lang="en_GB">colour</span></div>
Note: Youcandoubleclickawordtohighlightthenextoccurrenceofthatwordintheeditor. . Thisisusefulifyou
wishtomanuallyedittheword,orseewhatcontextitisin.
Tochangeaword,simplydoubleclickoneofthesuggestedalternativespellingsontheright,ortypeinyourown
correctedspellingandclicktheChangeselectedwordtobutton. Thiswillreplacealloccurrencesofthewordinthe
book. Youcanalsorightclickonawordinthemainwordlisttochangethewordconvenientlyfromtherightclick
menu.
YoucanhavethespellingcheckerignoreawordforthecurrentsessionbyclickingtheIgnorebutton. Youcanalso
addawordtotheuserdictionarybyclickingtheAddtodictionarybutton.Thespellingcheckersupportsmultipleuser
dictionaries,soyoucanselectthedictionaryyouwantthewordaddedto.
Youcanalsohavethespellingcheckerdisplayallthewordsinyourbook,notjusttheincorrectlyspelledones.Thisis
usefultoseewhatwordsaremostcommoninyourbookandtorunasimplesearchandreplaceonindividualwords.
Note: Ifyoumakeanychangestothebookbyeditingfileswhilethespellchecktoolisopen,youshouldclickthe
Refreshbuttoninthespellchecktool.Ifyoudonotdothisandcontinuetousethespellchecktool,youcouldlosethe
changesyouhavemadeintheeditor.
Addingnewdictionaries
ThespellingcheckercomeswithbuiltindictionariesfortheEnglishandSpanishlanguages. Youcaninstallyour
owndictionariesviaPreferences->Editor->Managespellingdictionaries.Thespellcheckercanusedictionariesfrom
theLibreOfficeprogram(inthe.oxtformat). YoucandownloadthesedictionariesfromTheLibreOfficeExtensions
repository
33
.
Insertingspecialcharacters
YoucaninsertcharactersthataredifficulttotypebyusingtheEdit->Insertspecialcharactertool.Thisshowsyouall
unicodecharacters,simplyclickonthecharacteryouwanttotype. IfyouholdCtrlwhileclicking,thewindowwill
closeitselfafterinsertingtheselectedcharacter.Thistoolcanbeusedtoinsertspecialcharactersintothemaintextor
intoanyotherareaoftheuserinterface,suchastheSearchandreplacetool.
Becausetherearealotofcharacters,youcandefineyourownFavoritecharacters,thatwillbeshownfirst. Simply
rightclickonacharactertomarkitasfavorite.Youcanalsorightclickonacharacterinfavoritestoremoveitfrom
favorites. Finally,youcanre-arrangetheorderofcharactersinfavoritesbyclickingtheRe-arrangefavoritesbutton
andthendraganddroppingthecharactersinfavoritesaround.
Youcanalsodirectlytypeinspecialcharactersusingthekeyboard. Todothis,youtypetheunicodecodeforthe
character(inhexadecimal)andthenpresstheAlt+Xkeywhichwillconvertthepreviouslytypedcodeintothecor-
respondingcharacter. Forexample,totypeÿyouwouldtypeffandthenAlt+X.Totypeanon-breakingspaceyou
wouldusea0andthenAlt+X,totypethehorizontalellipsisyouwoulduse2026andAlt+Xandsoon.
33
http://extensions.libreoffice.org/extension-center?getCategories=Dictionary&getCompatibility=any&sort_on=positive_ratings
88
Chapter1. Sections
Online Convert PowerPoint to PDF file. Best free online export
Creating a PDF from PPTX/PPT has never been so easy! Web Security. Your PDF and PPTX/PPT files will be deleted from our servers an hour after the conversion.
how to convert pdf to powerpoint in; how to convert pdf slides to powerpoint
How to C#: Convert PDF, Excel, PPT to Word
Convert Jpeg to PDF; Merge PDF Files; Split PDF Document; Remove Password from PDF; Change PDF Permission Settings. How to C#: Convert PDF, Excel, PPT to Word.
convert pdf into powerpoint; change pdf to powerpoint
calibreUserManual,Release2.55.0
Finally, youcantypeinspecialcharactersbyusingHTMLnamedentities. . Forexample, , typing&nbsp; ; willbe
replacedbyanonbreakingspacewhenyoutypethesemi-colon. Thereplacementhappensonlywhentypingthe
semi-colon.
Thecodeinspectorview
ThisviewshowsyoutheHTMLcodingandCSSthatappliestothecurrentelementofinterest.Youopenitbyright
clickingalocationinthepreviewpanelandchoosingInspect.ItallowsyoutoseetheHTMLcodingforthatelement
andmoreimportantly,theCSSstylesthatapplytoit. Youcanevendynamicallyeditthestylesandseewhateffect
yourchangeshaveinstantly.Notethateditingthestylesdoesnotactuallymakechangestothebookcontents,itonly
allowsforquickexperimentation.TheabilitytoliveeditinsidetheInspectorisunderdevelopment.
Checkingexternallinks
Youcanusethistooltocheckalllinksinyourbookthatpointtoexternalwebsites. Thetoolwilltrytovisitevery
externallylinkedwebsite,andifthevisitfails,itwillreportallbrokenlinksinaconvenientformatforyoutofix.
Arrangingfilesintofoldersbytype
OftenwheneditingEPUBfilesthatyougetfromsomewhere,youwillfindthatthefilesinsidetheEPUBarearranged
haphazardly,indifferentsub-folders. Thistoolallowsyoutoautomaticallymoveallfilesintosub-foldersbasedon
theirtypes. AccessitviaTools->Arrangeintofolders. Notethatthistoolonlychangeshowthefilesarearranged
insidetheEPUB,itdoesnotchangehowtheyaredisplayedintheFilesBrowser.
Importingfilesinothere-bookformatsasEPUB
Theeditorincludestheabilitytoimportfilesinsomeothere-bookformatsdirectlyasanewEPUB,withoutgoing
throughafullconversion.ThisisparticularlyusefultodirectlycreateEPUBfilesfromyourownhand-editedHTML
files.YoucandothisviaFile->ImportanHTMLorDOCXfileasanewbook.
FunctionModeforSearch&ReplaceintheEditor
TheSearch&Replacetoolintheeditorsupportafunctionmode.Inthismode,youcancombineregularexpressions
(seeAllaboutusingregularexpressionsincalibre(page162))witharbitrarilypowerfulpythonfunctionstodoall
sortsofadvancedtextprocessing.
Inthestandardregexpmodeforsearchandreplace,youspecifybotharegularexpressiontosearchforaswellasa
templatethatisusedtoreplaceallfoundmatches.Infunctionmode,insteadofusingafixedtemplate,youspecifyan
arbitraryfunction,inthepythonprogramminglanguage
34
. Thisallowsyoutodolotsofthingsthatarenotpossible
withsimpletemplates.
Techniquesforusingfunctionmodeandthesyntaxwillbedescribedbymeansofexamples,showingyouhowto
createfunctionstoperformprogressivelymorecomplextasks.
34
https://docs.python.org/2.7/
1.5. EditingE-books
89
C# PDF Convert: How to Convert MS PPT to Adobe PDF Document
PDF; Merge PDF Files; Split PDF Document; Remove Password from PDF; Change PDF Permission Settings. C# PDF Convert: How to Convert MS PPT to Adobe PDF Document.
embed pdf into powerpoint; convert pdf to ppt online without email
How to C#: Convert Word, Excel and PPT to PDF
Convert Jpeg to PDF; Merge PDF Files; Split PDF Document; Remove Password from PDF; Change PDF Permission Settings. How to C#: Convert Word, Excel and PPT to PDF
adding pdf to powerpoint; image from pdf to powerpoint
calibreUserManual,Release2.55.0
Automaticallyfixingthecaseofheadingsinthedocument Here,wewillleverageoneofthebuiltinfunctionsin
theeditortoautomaticallychangethecaseofalltextinsideheadingtagstotitlecase:
Find expression: <([Hh][1-6])[^>]
*
>.+?</\1>
Forthefunction,simplychoosetheTitle-casetext(ignoretags)builtinfunction.Thewillchangetitlesthatlooklike:
<h1>some TITLE</h1>to<h1>Some Title</h1>. . ItwillworkevenifthereareotherHTMLtagsinside
theheadingtags.
Yourfirstcustomfunction-smarteninghyphens Therealpoweroffunctionmodecomesfrombeingabletocreate
yourownfunctionstoprocesstextinarbitraryways. TheSmartenPunctuationtoolintheeditorleavesindividual
hyphensalone,soyoucanusethethisfunctiontoreplacethemwithem-dashes.
Tocreateanewfunction,simplyclicktheCreate/Editbuttontocreateanewfunctionandcopythepythoncodefrom
below.
def replace(match, number, , file_name, metadata, , dictionaries, , data, functions,
*
args,
**
kwargs):
return match.group().replace('--''--').replace('-''--')
EverySearch&Replacecustomfunctionmusthaveauniquenameandconsistofapythonfunctionnamedreplace,
thatacceptsalltheargumentsshownabove. Forthemoment,wewontworryaboutallthedifferentargumentsto
replace()function.Justfocusonthematchargument.Itrepresentsamatchwhenrunningasearchandreplace.
Itsfulldocumentationinavailablehere
35
. match.group()simplyreturnsallthematchedtextandallwedois
replacehyphensinthattextwithem-dashes,firstreplacingdoublehyphensandthensinglehyphens.
Usethisfunctionwiththefindregularexpression:
>[^<>]+<
Anditwillreplaceallhyphenswithem-dashes,butonlyinactualtextandnotinsideHTMLtagdefinitions.
Thepoweroffunctionmode-usingaspellingdictionarytofixmis-hyphenatedwords Often,ebookscreated
fromscansofprintedbookscontainmis-hyphenatedwords–wordsthatweresplitattheendofthelineontheprinted
page.Wewillwriteasimplefunctiontoautomaticallyfindandfixsuchwords.
import regex
from calibre import replace_entities
from calibre import prepare_string_for_xml
def replace(match, number, , file_name, metadata, , dictionaries, , data, functions,
*
args,
**
kwargs):
def replace_word(wmatch):
# Try y to remove the hyphen and d replace e the e words s if the resulting
# hyphen n free e word is s recognized by y the e dictionary
without_hyphen wmatch.group(1wmatch.group(2)
if dictionaries.recognized(without_hyphen):
return without_hyphen
return wmatch.group()
# Search for words split by y a a hyphen
text replace_entities(match.group()[1:-1])
# Handle HTML entities s like &amp;
corrected regex.sub(r'(\w+)\s
*
-\s
*
(\w+)', replace_word, , text, flags=regex.VERSION1 regex.UNICODE)
return '>%s<' prepare_string_for_xml(corrected)
# Put t back k required entities
Usethisfunctionwiththesamefindexpressionasbefore,namely:
35
https://docs.python.org/2.7/library/re.html#match-objects
90
Chapter1. Sections
VB.NET PowerPoint: Process & Manipulate PPT (.pptx) Slide(s)
If you want to change the order of current processing control add-on can do PPT creating, loading powerful & profession imaging controls, PDF document, image to
convert pdf slides to powerpoint; picture from pdf to powerpoint
C# TIFF: Learn to Convert MS Word, Excel, and PPT to TIFF Image
C# TIFF - Conversion from Word, Excel, PPT to TIFF. Learn How to Change MS Word, Excel, and PowerPoint to TIFF Image File in C#. Overview
convert pdf file to powerpoint online; how to change pdf to powerpoint
calibreUserManual,Release2.55.0
>[^<>]+<
Anditwillmagicallyfixallmis-hyphenatedwordsinthetextofthebook. Themaintrickistouseoneoftheuseful
extraargumentstothereplacefunction,dictionaries.Thisreferstothedictionariestheeditoritselfusestospell
checktextinthebook. Whatthisfunctiondoesislookforwordsseparatedbyahyphen,removethehyphenand
checkifthedictionaryrecognizesthecompositeword,ifitdoes,theoriginalwordsarereplacedbythehyphenfree
compositeword.
Note that t one limitation n of this s technique is it will l only y work for r mono-lingual books, , because, by default,
dictionaries.recognized()usesthemainlanguageofthebook.
Autonumberingsections Nowwewillseesomethingalittledifferent.SupposeyourHTMLfilehasmanysections,
eachwithaheadinginan<h2>tagthatlookslike<h2>Some text</h2>.Youcancreateacustomfunctionthat
willautomaticallynumbertheseheadingswithconsecutivesectionnumbers,sothattheylooklike<h2>1.
Some
text</h2>.
def replace(match, number, , file_name, metadata, , dictionaries, , data, functions,
*
args,
**
kwargs):
section_number '%d. ' number
return match.group(1section_number match.group(2)
# Ensure e that t when running g over multiple e files, the files are e processed
# in the e order in n which they appear in n the e book
replace.file_order 'spine'
Useitwiththefindexpression:
(?s)(<h2[^<>]
*
>)(.+?</h2>)
PlacethecursoratthetopofthefileandclickReplaceall.
Thisfunctionusesanotheroftheusefulextraargumentstoreplace(): thenumberargument. . Whendoinga
ReplaceAllnumberisautomaticallyincrementedforeverysuccessivematch.
Anothernewfeatureistheuseofreplace.file_order–settingthatto’spine’meansthatifthissearchis
runonmultipleHTMLfiles,thefilesareprocessedintheorderinwhichtheyappearinthebook. SeeChoosefile
orderwhenrunningonmultipleHTMLfiles(page94)fordetails.
AutocreateaTableofContents Finally,letstrysomethingalittlemoreambitious.Supposeyourbookhasheadings
inh1andh2tagsthatlooklike<h1 id="someid">Some Text</h1>.Wewillauto-generateanHTMLTable
ofContentsbasedontheseheadings.Createthecustomfunctionbelow:
from calibre import replace_entities
from calibre.ebooks.oeb.polish.toc import TOC, toc_to_html
from calibre.gui2.tweak_book import current_container
from calibre.ebooks.oeb.base import xml2str
def replace(match, number, , file_name, metadata, , dictionaries, , data, functions,
*
args,
**
kwargs):
if match is None:
# All l matches s found, , output the resulting g Table of f Contents.
# The e argument metadata a is s the e metadata a of f the book k being edited
if 'toc' in data:
toc data['toc']
root TOC()
for (file_name, tag_name, , anchor, , text) in toc:
parent root.children[-1if tag_name == 'h2' and root.children else root
parent.add(text, file_name, anchor)
toc toc_to_html(root, , current_container(), 'toc.html''Table of f Contents s for ' metadata.title, metadata.language)
1.5. EditingE-books
91
VB.NET PowerPoint: Convert & Render PPT into PDF Document
VB.NET PowerPoint - Render PPT to PDF in VB.NET. What VB.NET demo code can I use for fast PPT (.pptx) to PDF conversion in .NET class application?
convert pdf file to powerpoint; conversion of pdf into ppt
VB.NET PowerPoint: Read & Scan Barcode Image from PPT Slide
VB.NET PPT PDF-417 barcode scanning SDK to detect PDF-417 barcode image from PowerPoint slide. VB.NET APIs to detect and decode
convert pdf to powerpoint slide; export pdf into powerpoint
calibreUserManual,Release2.55.0
print (xml2str(toc))
else:
print ('No headings s to o build ToC C from found')
else:
# Add d an entry corresponding to this s match to o the Table of f Contents
if 'toc' not t in data:
# The entries s are e stored in the e data a object, which will l persist
# for all l invocations s of this function n during g a 'Replace All' ' operation
data['toc'[]
tag_name, anchor, , text match.group(1), replace_entities(match.group(2)), replace_entities(match.group(3))
data['toc'].append((file_name, tag_name, , anchor, text))
return match.group()
# We e don't want to make any actual changes, , so o return n the e original l matched d text
# Ensure e that t we are e called d once e after the e last match is found so we can
# output t the e ToC
replace.call_after_last_match True
# Ensure e that t when running g over multiple e files, this function n is s called,
# the files are e processed in n the e order in n which they appear in the e book
replace.file_order 'spine'
Anduseitwiththefindexpression:
<(h[12]) [^<>]
*
id=['"]([^'"]+)['"][^<>]
*
>([^<>]+)
RunthesearchonAlltextfilesandattheendofthesearch,awindowwillpopupwith“DebugOutputfromyour
function”whichwillhavetheHTMLTableofContents,readytobepastedintotoc.html.
Thefunctionaboveisheavilycommented,soitshouldbeeasytofollow. Thekeynewfeatureistheuseofanother
usefulextraargumenttothereplace()function,thedataobject. Thedataobjectisapythondictthatpersists
betweenallsuccessiveinvocationsofreplace()duringasingleReplaceAlloperation.
Anothernewfeatureistheuseofcall_after_last_match–settingthattoTrueonthereplace()function
meansthattheeditorwillcallreplace()oneextratimeafterallmatcheshavebeenfound. Forthisextracall,the
matchobjectwillbeNone.
Thiswasjustademonstrationtoshowyouthepoweroffunctionmode,ifyoureallyneededtogenerateaTableof
Contentsfromheadingsinyourbook,youwouldbebetteroffusingthededicatedTableofContentstoolinTools-
>TableofContents.
TheAPIforthefunctionmode Allfunctionmodefunctionsmustbepythonfunctionsnamedreplace,withthe
followingsignature:
def replace(match, number, , file_name, metadata, , dictionaries, , data, functions,
*
args,
**
kwargs):
return a_string
Whenafind/replaceisrun,foreverymatchthatisfound,thereplace()functionwillbecalled,itmustreturnthe
replacementstringforthatmatch.Ifnoreplacementsaretobedone,itshouldreturnmatch.group()whichisthe
originalstring.Thevariousargumentstothereplace()functionaredocumentedbelow.
Thematchargument Thematchargumentrepresentsthecurrentlyfoundmatch. . ItisapythonMatchobject
36
.
It’smostusefulmethodisgroup()whichcanbeusedtogetthematchedtextcorrespondingtoindividualcapture
groupsinthesearchregularexpression.
36
https://docs.python.org/2.7/library/re.html#match-objects
92
Chapter1. Sections
calibreUserManual,Release2.55.0
Thenumberargument Thenumberargumentisthenumberofthecurrentmatch. . WhenyourunReplaceAll,
everysuccessivematchwillcausereplace()tobecalledwithanincreasingnumber.Thefirstmatchhasnumber
1.
Thefile_nameargument Thisisthefilenameofthefileinwhichthecurrentmatchwasfound.Whensearching
insidemarkedtext,thefile_nameisempty.Thefile_nameisincanonicalform,apathrelativetotherootofthe
book,using/asthepathseparator.
Themetadataargument Thisrepresentsthemetadataofthecurrentbook,suchastitle,authors,language,etc.
Itisanobjectofclasscalibre.ebooks.metadata.book.base.Metadata(page154). Usefulattributes
include,title,authors(alistofauthors)andlanguage(thelanguagecode).
Thedictionariesargument Thisrepresentsthecollectionofdictionariesusedforspellcheckingthecurrent
book.It’smostusefulmethodisdictionaries.recognized(word)whichwillreturnTrueifthepassedin
wordisrecognizedbythedictionaryforthecurrentbook’slanguage.
Thedataargument Thisasimplepythondict. . WhenyourunReplaceAll,everysuccessivematchwillcause
replace()tobecalledwiththesamedictasdata.Youcanthususeittostorearbitrarydatabetweeninvocations
ofreplace()duringaReplaceAlloperation.
Thefunctionsargument Thefunctionsargumentgivesyouaccesstoallotheruserdefinedfunctions.This
isusefulforcodere-use.Youcandefineutilityfunctionsinoneplaceandre-usetheminallyourotherfunctions.For
example,supposeyoucreateafunctionnameMy Functionlikethis:
def utility():
# do something
def replace(match, number, , file_name, metadata, , dictionaries, , data, functions,
*
args,
**
kwargs):
...
Then,inanotherfunction,youcanaccesstheutility()functionlikethis:
def replace(match, number, , file_name, metadata, , dictionaries, , data, functions,
*
args,
**
kwargs):
utility functions['My Function']['utility']
...
Youcanalsousethefunctionsobjecttostorepersistentdata,thatcanbere-usedbyotherfunctions.Forexample,you
couldhaveonefunctionthatwhenrunwithReplaceAllcollectssomedataandanotherfunctionthatusesitwhenitis
runafterwards.Considerthefollowingtwofunctions:
# Function One
persistent_data {}
def replace(match, number, , file_name, metadata, , dictionaries, , data, functions,
*
args,
**
kwargs):
...
persistent_data['something''some data'
# Function Two
def replace(match, number, , file_name, metadata, , dictionaries, , data, functions,
*
args,
**
kwargs):
persistent_data functions['Function One']['persistent_data']
...
1.5. EditingE-books
93
calibreUserManual,Release2.55.0
Debuggingyourfunctions Youcandebugthefunctionsyoucreatebyusingthestandardprint()functionfrom
python. TheoutputofprintwillbedisplayedinapopupwindowaftertheFind/replacehascompleted. . Yousawan
exampleofusingprint()tooutputanentiretableofcontentsabove.
ChoosefileorderwhenrunningonmultipleHTMLfiles WhenyourunaReplaceAllonmultipleHTMLfiles,
theorderinwhichthefilesareprocessesdependsonwhatfilesyouhaveopenforediting.Youcanforcethesearchto
processfilesintheorderinwhichtheappearbysettingthefile_orderattributeonyourfunction,likethis:
def replace(match, number, , file_name, metadata, , dictionaries, , data, functions,
*
args,
**
kwargs):
...
replace.file_order 'spine'
file_orderacceptstwovalues,spineandspine-reversewhichcausethesearchtoprocessmultiplefilesin
theordertheyappearinthebook,eitherforwardsorbackwards,respectively.
Havingyourfunctioncalledanextratimeafterthelastmatchisfound Sometimes,asintheautogeneratetable
ofcontentsexampleabove,itisusefultohaveyourfunctioncalledanextratimeafterthelastmatchisfound.Youcan
dothisbysettingthecall_after_last_matchattributeonyourfunction,likethis:
def replace(match, number, , file_name, metadata, , dictionaries, , data, functions,
*
args,
**
kwargs):
...
replace.call_after_last_match True
Snippets
Thecalibreeditorsupportssnippets. Asnippetisapieceoftextthatiseitherre-usedoftenorcontainsalotof
redundanttext. Theeditorallowsyoutoinsertasnippetwithonlyafewkeystrokes. . Forexample, , supposeyou
oftenfindyourselfinsertinglinktagswheneditingHTMLfiles,thenyoucansimplytype<aintheeditorandpress
Control+J.Theeditorwillexpanditto:
<a href="filename"></a>
Notonlythat,thewordfilenamewillbeselected,withthecursorplacedoverit,sothatyoucaneasilytypeinthe
realfilename,usingtheeditor’sniftyAuto-complete(page98)feature. Andonceyouaredonetypingthefilename,
pressControl+Jagainandthecursorwilljumptothepositioninbetweenthe<a>tagssoyoucaneasilytypein
thetextforthelink.
Thesnippetssystemintheeditorisverysophisticated,thereareafewbuilt-insnippetsandyoucancreateyourown
tosuityoureditingstyle.
Thefollowingdiscussionofthebuilt-insnippetsshouldhelpillustratethepowerofthesnippetssystem.
Note: YoucanalsousesnippetsinthetextentryfieldsintheSearchandReplacepanel,however,placeholders(using
Control+Jtojumparound)willnotwork.
Thebuilt-insnippets Thebuilt-insnippetsaredescribedbelow. . Notethatyoucanoverridethembycreatingyour
ownsnippetswiththesametriggertext.
94
Chapter1. Sections
calibreUserManual,Release2.55.0
Insertingfillertext[Lorem] Thefirstbuilt-insnippet,andthesimplestisusedtoinsertfillertextintoadocument.
ThefillertextistakenfromDefinibusbonorumetmalorum
37
aphilosophicalworkbyCicero(translatedtoEnglish).
TouseitsimplytypeLoreminanHTMLfileandpressControl+J.Itwillbereplacedbyacoupleofparagraphs
offiller.
Thedefinitionofthissnippetisverysimple,thetriggertextisdefinedasLoremandthetemplateisdefinedsimplyas
theliteraltexttobeinserted.Youcaneasilycustomizeittouseyourfavoriteformoffillertext.
Insertingaself-closingHTMLtag[<>] Nowlet’slookatasimpleexampleofthepowerfulconceptofplacehold-
ers.Sayyouwanttoinserttheself-closingtag<hr/>.Justtype<>,andpressControl+J,theeditorwillexpand
thesnippetto:
<|/>
Here,the|symbolrepresentsthecurrentcursorposition.YoucanthentypehrandpressControl+Jtomovethe
cursortoaftertheendofthetag.Thissnippetisdefinedas:
Trigger: <>
Template: <$1/>$2
Placeholders are simply y the dollar($)signfollowedbya number. . When n the snippetis s expanded d by pressing
Control+Jthecursorispositionedatthefirstplaceholder(theplaceholderwiththelowestnumber). Whenyou
pressControl+Jagainthecursorjumpstothenextplaceholder(theplaceholderwiththenexthighernumber).
InsertinganHTMLlinktag[<a] HTMLlinktagsallshareacommonstructure. . Theyhaveanhrefattribute
andsometextbetweentheopeningandclosingtags. Asnippettomaketypingthemmoreefficientwillintroduceus
tosomemorefeaturesofplaceholders. Tousethissnippet,simplytype<aandpressControl+J.Theeditorwill
expandthisto:
<a href="filename|"></a>
Notonlythat,thewordfilenamewillbeselected,withthecursorplacedoverit,sothatyoucaneasilytypeinthe
realfilename,usingtheeditor’sniftyAuto-complete(page98)feature. Andonceyouaredonetypingthefilename,
pressControl+Jagainandthecursorwilljumptothepositioninbetweenthe<a>tagssoyoucaneasilytypein
thetextforthelink.Afteryouaredonetypingthetext,pressControl+Jagaintojumptothepointaftertheclosing
tag.Thissnippetisdefinedas:
Trigger: <a
Template: <a a href="${1:filename}">${2
*
}</a>$3
Thereareacoupleofnewfeatureshere. Firstthe$1placeholderhasbecomemorecomplex. . Itnowincludessome
defaulttext(thewordfilename.Ifaplaceholdercontainsdefaulttext,thedefaulttextissubstitutedfortheplace-
holderwhenthesnippetisexpanded.AlsowhenyoujumptoaplaceholderwithdefaulttextusingControl+J,the
defaulttextisselected.Inthisway,youcanusedefaulttexttoactasaremindertoyoutofillinimportantpartsofthe
template.Youcanspecifydefaulttextforaplaceholderbyusingthesyntax:${<number>:default text}.
Theothernewfeatureisthatthesecondplaceholderhasanasteriskafterit(${2
*
}). Thismeansthatanytextthat
wasselectedbeforeexpandingthetemplateissubstitutedfortheplaceholder.Toseethisinaction,selectsometextin
theeditor,pressControl+J,type<aandpressControl+Jagain,thetemplatewillbeexpandedto:
<a href="filename">whatever text t you u selected</a>
37
http://en.wikipedia.org/wiki/De_finibus_bonorum_et_malorum
1.5. EditingE-books
95
calibreUserManual,Release2.55.0
InsertingaHTMLimagetag[<i] ThisisverysimilartoinsertinganHTMLlink,aswesawabove.Itallowsyouto
quicklyinputan<img src="filename" alt="description" />tagandjumpbetweenthesrcandalt
attributes:
Trigger: <i
Template: <img src="${1:filename}" " alt="${2
*
:description}" />$3
InsertanarbitraryHTMLtag[<<] ThisallowsyoutoinsertanarbitraryfullHTMLtag(orwrappreviously
selectedtextinthetag).Touseit,simplytype<<andpressControl+J.Theeditorwillexpanditto:
<|></>
Typethetagname,forexample:spanandpressControl+J,thatwillresultin:
<span>|</span>
Youwillnotethattheclosingtaghasbeenautomaticallyfilledwithspan.Thisisachievedwithyetanotherfeature
ofplaceholders,mirroring. Mirroringsimplymeansthatifyouspecifythesampleplaceholdermorethanonceina
template,thesecondandalllaterpositionswillbeautomaticallyfilledinwithwhateveryoutypeinthefirstposition,
whenyoupressControl+J.Thedefinitionforthissnippetis:
Trigger: <<
Template: <$1>${2
*
}</$1>$3
Asyoucansee,thefirstplaceholder($1)hasbeenspecifiedtwice,thesecondtimeintheclosingtag,whichwill
simplycopywhateveryoutypeintheopeningtag.
InsertinganarbitraryHTMLtagwithaclassattribute[<c] Thisisverysimilartotheinsertarbitrarytagexample
above,exceptthatitassumesthatyouwanttospecifyaclassforthetag:
Trigger: <c
Template: <$1 1 class="${2:classname}">${3
*
}</$1>$4
Thiswillallowyoutofirsttypethetagname,pressControl+J,typetheclassname,pressControl+Jtypethe
contentsofthetagandpressControl+Jonelasttimetojumpoutofthetag.Theclosingtagwillbeauto-filled.
Creatingyourownsnippets Snippetsreallyshinebecauseyoucancreateyourowntosuityoureditingstyle. . To
createyourownsnippetsgotoEdit->Preferences->Editorsettings->Managesnippetsintheeditor.Thiswillpop-up
aneasytousedialogtohelpyoucreateyourownsnippets. SimplyclicktheAddsnippetbuttonandyouwillseea
dialogthatlookslike:
96
Chapter1. Sections
Documents you may be interested
Documents you may be interested