Crate bookbinder_common

Crate bookbinder_common 

Source
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:

  • epubcheck
  • pdftotext

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§

MimeType
A mimetype relevant to book production

Traits§

GuessMimeType
Helper to guess the mimetype of paths
MimeTypeHelper
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 dpi or 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 filepath to 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 epubcheck on a file to check that it is a valid epub
escape_to_html
escape input for html output
escape_to_latex
escape input for 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 str can 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 preceding 13) This allows, for example, the validation of prefixed or hyphenated isbns: