Hyphenator

Struct Hyphenator 

Source
pub struct Hyphenator { /* private fields */ }
Expand description

Hyphenates words using TeX’s pattern-matching algorithm (Knuth-Liang).

Construct with Hyphenator::plain_tex_en_us for the standard plain TeX English patterns, or load custom patterns with Hyphenator::load_patterns.

Implementations§

Source§

impl Hyphenator

Source

pub fn plain_tex_en_us() -> Self

Construct a hyphenator loaded with plain TeX’s English (US) patterns and exceptions.

Source

pub fn load_patterns(&mut self, patterns: &str)

Load hyphenation patterns from a whitespace-separated string in TeX pattern format.

Source

pub fn insert_exceptions(&mut self, hyphenated_words: &str)

Add multiple hyphenation exceptions. These are separate words separated by whitespace, with each word satisfying the format in Self::insert_exception.

Source

pub fn insert_exception(&mut self, hyphenated_word: &str)

Add a hyphenation exception. The word is given with hyphens marking the allowed break points, e.g. "hy-phen-ation".

Source

pub fn hypthenate<L: LowerCaser>( &self, lower_caser: &L, word: &str, target: &mut String, )

Hyphenate a word, returning it with - inserted at each valid break point.

Source

pub fn calculate_indices<L: LowerCaser>( &self, lower_caser: &L, word: &str, ) -> impl Iterator<Item = usize>

Return the set of character indices before which a hyphen may be inserted.

Trait Implementations§

Source§

impl Default for Hyphenator

Source§

fn default() -> Hyphenator

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.