1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! Token model for the UEB Grade-2 encoder.
//!
//! A document is parsed into a flat token stream. The document engine walks
//! it, managing inter-word mode/indicators, while delegating intra-word
//! contraction to the `ContractionEngine`.
/// §9 typeform applied to a styled character (italic/bold/underline).
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Typeform {
/// §9.x italic — symbol indicator `⠨⠆`.
Italic,
/// §9.x bold — symbol indicator `⠘⠆`.
Bold,
/// §9.x bold+italic — nested bold and italic indicators.
BoldItalic,
/// §9.x underline — symbol indicator `⠸⠆`.
Underline,
/// §9.x script — symbol indicator `⠈⠆`.
Script,
/// §9.5 first transcriber-defined typeform — e.g. typewriter font.
Transcriber1,
/// §9.5 second transcriber-defined typeform — e.g. double underline.
Transcriber2,
/// §9.5 third transcriber-defined typeform — e.g. crossed-out text.
Transcriber3,
/// §9.5 fourth transcriber-defined typeform — e.g. dotted underline.
Transcriber4,
/// §9.6.2 fifth transcriber-defined typeform — significant small capitals.
Transcriber5,
/// §9.8 italic text that is also underlined — nested indicators.
ItalicUnderline,
/// §9.8 bold text that is also underlined — nested indicators.
BoldUnderline,
/// §9.8 bold-italic text that is also underlined — nested indicators.
BoldItalicUnderline,
}
/// A parsed unit of English source text.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum EnglishToken {
/// A maximal run of ASCII letters (original case preserved).
Word(Vec<char>),
/// UEB §10.13: an originally unhyphenated word split by an explicit `\n`.
WordDivision {
/// The logical word with the newline removed.
chars: Vec<char>,
/// Character index at which the braille line breaks.
break_at: usize,
},
/// A maximal run of ASCII digits.
Number(Vec<char>),
/// A single non-letter, non-digit, non-space character.
Symbol(char),
/// One unit of inter-word whitespace.
Space,
/// UEB §10.13 Note: line-end division after an existing hyphen/dash.
LineBreak,
/// §9: a single styled letter (its plain base char + typeform). It carries a
/// symbol-level typeform indicator and acts as a contraction boundary, so the
/// surrounding plain letters contract among themselves (`𝐛right` → bold-b then
/// the `right` groupsign).
Styled(char, Typeform),
/// §11 technical notation delimited by `$...$` in testcase source. The delimiters
/// are markup only; UEB owns the enclosed expression when the surrounding context
/// is English.
Technical(Vec<char>),
}