hyphenation
Standard Knuth-Liang hyphenation based on the TeX UTF-8 patterns.
[]
= "0.6"
Documentation
Quickstart
use ;
use ;
// Load hyphenation data for American English from the pattern repository.
let english_us = load.unwrap;
// Compute the byte indices of valid hyphenation points within a word.
let indices = "hyphenation".opportunities;
assert_eq!;
// Build an iterator that breaks a word according to standard hyphenation practices.
let h: Standard = "hyphenation".hyphenate;
// Collect the lazy hyphenator `h` into substring slices over the original string.
let v: = h.collect;
assert_eq!;
// Hyphenation works with full text as well as individual words.
use FullTextHyphenation;
let text_indices = "Word hyphenation by computer.".fulltext_opportunities;
assert_eq!;
let h2: Standard = "Word hyphenation by computer.".fulltext_hyphenate;
let v2: = h2.collect;
assert_eq!;
// Mark hyphenation opportunities with soft hyphens,
// and render the result to a new String.
let h3 = "anfractuous".hyphenate;
let s3: String = h3.punctuate.collect;
assert_eq!;
Unicode Normalization
For preference, hyphenation
should operate on strings in a known normalization form, as described by the Unicode Standard Annex #15 and provided by the unicode-normalization
crate. This is particularly important when working with non-ASCII languages that feature combining marks.
(Notably exempt from such concerns are English_US
and English_GB
, for which normalization is ordinarily inconsequential.)
The normalization form expected by hyphenation
is determined at build time. By default, hyphenation
is compiled to work with strings in Normalization Form C; you may specify another form in your Cargo manifest, like so:
[]
= "0.6.0"
= ["nfd"]
The features
field takes a list containing the desired normalization form; namely, the value of features
must be one of the following:
["none"]
, to use the TeX UTF-8 patterns as they are;["nfc"]
, for canonical composition;["nfd"]
, for canonical decomposition;["nfkc"]
, for compatibility composition;["nfkd"]
, for compatibility decomposition.
License
hyphenation
© 2016 tapeinosyne, dual-licensed under the terms of either:
- The Apache License, Version 2.0
- The MIT license
texhyphen
hyphenation patterns © their respective owners; see lic.txt
files for licensing information.