Skip to main content

Module text

Module text 

Source
Expand description

Language-aware text normalization shared by print and EPUB output.

Applied at render time, never stored in the model, so the author’s text stays as typed and changing the book language re-quotes everything.

Structs§

Carry
What smarten carries from one run of a paragraph to the next (the text between formatting changes), so quotes after a change open and close correctly. Each paragraph, title or caption starts from Carry::default().
Quotes
Quotation style for a language.
SmartenOptions
Options for smarten.

Functions§

german_nbsp
German: non-breaking (thin would be nicer, NBSP is safer across readers) spaces inside common abbreviations and between numbers and units.
normalize
Everything print and EPUB apply to a run of manuscript text: smarten for the language, then for German german_nbsp. primary is the primary language subtag (crate::Lang::primary); carry as for smarten.
normalize_with
normalize with other options than the language’s own, e.g. Quotes::DE_GUILLEMETS for a German book set with guillemets.
opening_split
Where a chapter’s first paragraph splits for a drop cap, as byte offsets into s: (initial_end, lead_in_end). The initial runs up to and including the first letter or digit (so it carries any opening quote before it); the lead-in is the rest of that word and two more whitespace-separated words (a lone dash counts as a word), or all of s if there are fewer. None when s has no letter or digit. Print and EPUB both split with this, so they cannot disagree; each decides for itself what may stand before the letter.
smarten
Convert typewriter punctuation to typographic punctuation.