unicode-linebreak

Crates.iounicode-linebreak
lib.rsunicode-linebreak
version0.1.5
sourcesrc
created_at2018-12-10 20:45:01.729575
updated_at2023-07-25 11:49:38.560848
descriptionImplementation of the Unicode Line Breaking Algorithm
homepagehttps://github.com/axelf4/unicode-linebreak
repositoryhttps://github.com/axelf4/unicode-linebreak
max_upload_size
id101192
size89,796
Axel Forsman (axelf4)

documentation

README

unicode-linebreak

Implementation of the Line Breaking Algorithm described in Unicode Standard Annex #14.

test Documentation

Given an input text, locates "line break opportunities", or positions appropriate for wrapping lines when displaying text.

Example

use unicode_linebreak::{linebreaks, BreakOpportunity::{Mandatory, Allowed}};

let text = "a b \nc";
assert!(linebreaks(text).eq([
	(2, Allowed),   // May break after first space
	(5, Mandatory), // Must break after line feed
	(6, Mandatory)  // Must break at end of text, so that there always is at least one LB
]));

Development

After cloning the repository or modifying LineBreak.txt the tables have to be (re-)generated:

# Generate src/tables.rs
(cd gen-tables && cargo run)
# Run tests to make sure it was successful
cargo test
Commit count: 29

cargo fmt