tui_markup/parser/
item.rs

1use crate::parser::LSpan;
2
3use crate::generator::{Tag, TagG};
4
5/// AST item.
6///
7/// In parsing stage, each line of source code will be parsed as a `Vec<Item>`, so the final result is `Vec<Vec<Item>>`.
8///
9/// Tag conversion stage, Each tag will be converted from [`LSpan`] into [Tag] type the generator needed,
10/// by using [`TagConvertor`][crate::generator::TagConvertor] of the generator.
11///
12/// In generating stage, generator will convert `Vec<Vec<Item<'_, Tag>>>>` to final output.
13#[derive(Debug, Clone, PartialEq)]
14pub enum Item<'a, Tag = LSpan<'a>> {
15    /// Plain text(escaped) without any style.
16    PlainText(LSpan<'a>),
17    /// A styled element, contains a series tag name and subitems.
18    Element(Vec<Tag>, Vec<Item<'a, Tag>>),
19}
20
21/// Item type for tag convertor C.
22pub type ItemC<'a, C> = Item<'a, Tag<'a, C>>;
23
24/// Item type for generator G.
25pub type ItemG<'a, G> = Item<'a, TagG<'a, G>>;