Expand description
A set of utilites used across crates. Note that these call some external commands:
latexmk(and by extension xelatex)pdftocairo(only if required to convert a pdf image – will gracefully fallback if not present)
The following are not necessary for normal operation, but are useful in development:
epubcheckpdftotext
If used in combination with bookbinder, the following packages are needed for LaTex calls:
-titlesec
-caption
-geometry
-ulem
-textcase
-xpatch
-amsmath
-amssymb
-bookmark
-booktabs
-etoolbox
-fancyhdr
-fancyvrb
-footnotehyper
-listings
-longtable
-unicode-math
-upquote
-xcolor
-xurl
-fontspec
-graphicx
-microtype
-hyperref
-fmtcount
-appendix
Modules§
- fonts
- Bundle some default fonts and make them accessible, as well as standardising access to system fonts.
Enums§
- Mime
Type - A mimetype relevant to book production
Traits§
- Guess
Mime Type - Helper to guess the mimetype of paths
- Mime
Type Helper - Various helpful functions for analysing filepaths
Functions§
- call_
latex - call lualatex on a particular str and return the pdf
- call_
latex_ verbose - call lualatex on a particular str and return the pdf, displaying lualatex’s output as it goes
- convert_
pdf_ to_ svg - convert a pdf file to an svg; requires that pdftocairo (part of poppler) be installed. Note that we can’t link poppler without licensing difficulties, so there are no plans to incorporate this as a dependency.
- convert_
svg_ file_ to_ png - Convert an svg file to a png with a resolution of
dpior the default - convert_
svg_ to_ jpg - Convert a svg str to a jpg file
- convert_
svg_ to_ png - Convert a svg str to a png file
- convert_
to_ jpg - Convert an image at path
filepathto a jpeg; generally common raster formats as well as svg and pdf are supported, but note that eps files are not - display_
isbn - present a nicely-printed version of an isbn-13
- epubcheck
- Call
epubcheckon a file to check that it is a valid epub - escape_
to_ html - escape
inputfor html output - escape_
to_ latex - escape
inputfor latex output - get_
current_ year - get the current year as a string
- number_
to_ letter - given a number, return the corresponding letter e.g. 0 -> A, 1 -> B, 2 -> C. Returns an error if the number is greater than 25
- number_
to_ roman - given a number, return it in roman format e.g. 1 -> I, 10 -> X, etc
- number_
to_ words - given a number, return its equivalent in words
- simplify_
svg - Use usvg to simplify an svg; this is most important in that text is rendered as paths
- validate_
isbn - Validate that a
strcan be interpreted as an isbn-13. A str will be valid whatever its non-digit components so long as it has at least 13 digits and the last digit is the correct checksum, for the first 12 (or first 12 after a preceding13) This allows, for example, the validation of prefixed or hyphenated isbns: