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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//! MTEXT format string parser and serializer.
//!
//! This module provides utilities for parsing AutoCAD MTEXT formatted strings
//! into a structured representation of paragraphs and styled text spans, and
//! for serializing such structures back to MTEXT format strings.
//!
//! # MTEXT Format
//!
//! MTEXT uses an RTF-like formatting syntax where the entire formatted block
//! is enclosed in braces `{...}`. Control codes start with `\` followed by
//! a letter and take optional semicolon-separated arguments.
//!
//! # Supported Control Codes
//!
//! | Code | Description |
//! |------|-------------|
//! | `\P` | Paragraph break |
//! | `\N` | New column break |
//! | `\X` | Wrap at dimension line |
//! | `\~` | Non-breaking space |
//! | `\U+XXXX` | Unicode escape |
//! | `\L` / `\l` | Underline on / off |
//! | `\O` / `\o` | Overline on / off |
//! | `\K` / `\k` | Strikethrough on / off |
//! | `\C<n>;` | ACI color index |
//! | `\c<n>;` | True-color RGB (packed BGR) |
//! | `\H<n>;` / `\H<n>x;` | Height absolute / relative |
//! | `\W<n>;` / `\W<n>x;` | Width factor absolute / relative |
//! | `\T<n>;` / `\T<n>x;` | Tracking absolute / relative |
//! | `\Q<n>;` | Oblique angle |
//! | `\A<n>;` | Line alignment (0=bottom, 1=middle, 2=top) |
//! | `\f<family>|b0/b1|i0/i1|...;` | Font with bold/italic |
//! | `\F<N><name>.shx;` | Font by SHX name |
//! | `\F<n>;` | Fraction style (0–3) |
//! | `\S<num>/<den>;` | Stacking (fractions, limits) |
//! | `\p q<l/r/c/j/d>;` | Paragraph alignment (left/right/center/justified/distributed) |
//! | `\p i<n>;` | First line indent (inches) |
//! | `\p l<n>;` | Left margin (inches) |
//! | `\p r<n>;` | Right margin (inches) |
//! | `\p b<n>;` | Spacing before paragraph (inches) |
//! | `\p a<n>;` | Spacing after paragraph (inches) |
//! | `\p se<n>;` | Exact line spacing (inches) |
//! | `\p sm<n>;` | Line spacing as multiple of font height |
//! | `\p t<n1,n2,...>;` | Tab stop positions |
//! | `\p...;` | Paragraph properties (sub-codes comma-separated) |
//! | `\b<n>;` | Legacy strikethrough (1=on, 0=off) |
//! | `{...}` | Style group (push/pop context) |
//! | `%%c` | Diameter symbol (Ø) |
//! | `%%d` | Degree symbol (°) |
//! | `%%p` | Plus-minus symbol (±) |
//! | `%%%%` | Literal percent sign (%) |
//!
//! # Escaping
//!
//! - `\\` → literal backslash
//! - `\{` → literal opening brace
//! - `\}` → literal closing brace
//!
//! # Example
//!
//! ```
//! use acadrust::entities::mtext_format::{
//! parse_mtext, MTextDocument, MTextParagraph, MTextSpan, SpanProperties, MTextColor,
//! };
//!
//! // Parse an MTEXT format string
//! let doc = parse_mtext("{\\C1;Red text\\C0;; normal}", false);
//! assert_eq!(doc.paragraphs.len(), 1);
//! assert_eq!(doc.paragraphs[0].spans.len(), 2);
//!
//! // Access span properties
//! let red_span = &doc.paragraphs[0].spans[0];
//! assert_eq!(red_span.text, "Red text");
//! assert_eq!(red_span.properties.color, Some(MTextColor::Index(1)));
//!
//! // Get plain text
//! let plain = doc.to_plain_text();
//! assert_eq!(plain, "Red text normal");
//!
//! // Build programmatically
//! let mut doc = MTextDocument::new();
//! let mut para = MTextParagraph::new();
//!
//! let mut props = SpanProperties::default();
//! props.color = Some(MTextColor::Index(5));
//! para.push_span(MTextSpan::new("Blue", props));
//! para.push_span(MTextSpan::plain(" text"));
//!
//! doc.push_paragraph(para);
//!
//! // Serialize back to MTEXT format
//! let output = doc.to_mtext_string();
//! assert!(output.contains("\\C5;"));
//! ```
pub use parse_mtext;
pub use parse_plain_text;
pub use ;