1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//! # Boxworks
//!
//! Boxworks is an in-progress implementation of the typesetting engine inside TeX.
//! It is independent of the TeX language.
//! One of the main goals of Boxworks is to support creating new typesetting
//! languages that use this engine to perform the actual typesetting.

pub mod ds;
pub mod tex;

pub trait TextPreprocessor {
    fn add_word(&mut self, word: &str, list: &mut Vec<ds::Horizontal>);

    fn add_space(&mut self, list: &mut Vec<ds::Horizontal>);

    fn add_text(&mut self, text: &str, list: &mut Vec<ds::Horizontal>) {
        for word in text.split_inclusive(' ') {
            self.add_word(word.trim_matches(' '), list);
            if word.ends_with(" ") {
                self.add_space(list);
            }
        }
    }
}