Skip to main content

sevenmark_parser/ast/
table.rs

1use serde::Serialize;
2
3use super::{Element, Expression, Parameters, Span};
4
5/// 테이블 요소 {{{#table ...}}}
6#[derive(Debug, Clone, Serialize)]
7pub struct TableElement {
8    #[cfg_attr(not(feature = "include_locations"), serde(skip_serializing))]
9    pub span: Span,
10    pub parameters: Parameters,
11    pub children: Vec<TableRowItem>,
12}
13
14/// 테이블 행 콘텐츠 아이템 (행 또는 조건부)
15#[derive(Debug, Clone, Serialize)]
16pub enum TableRowItem {
17    Row(TableRowElement),
18    Conditional(ConditionalTableRows),
19}
20
21/// 테이블 행
22#[derive(Debug, Clone, Serialize)]
23pub struct TableRowElement {
24    #[cfg_attr(not(feature = "include_locations"), serde(skip_serializing))]
25    pub span: Span,
26    pub parameters: Parameters,
27    pub children: Vec<TableCellItem>,
28}
29
30/// 테이블 셀 콘텐츠 아이템 (셀 또는 조건부)
31#[derive(Debug, Clone, Serialize)]
32pub enum TableCellItem {
33    Cell(TableCellElement),
34    Conditional(ConditionalTableCells),
35}
36
37/// 테이블 셀
38#[derive(Debug, Clone, Serialize)]
39pub struct TableCellElement {
40    #[cfg_attr(not(feature = "include_locations"), serde(skip_serializing))]
41    pub span: Span,
42    pub parameters: Parameters,
43    #[serde(skip_serializing_if = "Vec::is_empty")]
44    pub x: Vec<Element>,
45    #[serde(skip_serializing_if = "Vec::is_empty")]
46    pub y: Vec<Element>,
47    pub children: Vec<Element>,
48}
49
50/// 조건부 테이블 행 ({{{#if condition :: [[row]]...}}})
51#[derive(Debug, Clone, Serialize)]
52pub struct ConditionalTableRows {
53    #[cfg_attr(not(feature = "include_locations"), serde(skip_serializing))]
54    pub span: Span,
55    pub condition: Expression,
56    pub rows: Vec<TableRowElement>,
57}
58
59/// 조건부 테이블 셀 ({{{#if condition :: [[cell]]...}}})
60#[derive(Debug, Clone, Serialize)]
61pub struct ConditionalTableCells {
62    #[cfg_attr(not(feature = "include_locations"), serde(skip_serializing))]
63    pub span: Span,
64    pub condition: Expression,
65    pub cells: Vec<TableCellElement>,
66}