-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhtml_sugar.rs
More file actions
109 lines (107 loc) · 4.58 KB
/
html_sugar.rs
File metadata and controls
109 lines (107 loc) · 4.58 KB
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
106
107
108
109
//! HTML syntactic sugar extras.
use crate::ss::ast_data::HeadingType;
use crate::ss::SemanticScope;
use crate::ss::SymbolicModeType;
use crate::ss::ast_traits::SyntacticallyEq;
use super::*;
pub fn html_syntactic_sugar_extras() -> Vec<cmd_decl::CmdDeclaration> {
let table_row = CmdDeclBuilder::new(Ident::from("\\row").unwrap())
.parent_layout_mode(LayoutMode::Block)
.parent(Ident::from("\\table").unwrap())
.arguments(arguments! {
for (internal, metadata, cmd_payload) match {
(.. as nodes) => {
Node::Cmd(CmdCall {
identifier: cmd_payload.identifier,
attributes: cmd_payload.attributes.unwrap_or_default(),
arguments: nodes
})
},
}
})
.to_html(to_html! {
fn (env, scope, cmd) {
let children = cmd.arguments
.into_iter()
.flat_map(|x| {
if let Some(block) = x.clone().into_curly_brace_children() {
if block.len() == 1 && block[0].is_cmd_with_name("\\td") {
return block
.into_iter()
.map(|x| x.to_html(env, scope))
.collect_vec()
}
return vec![
crate::html::Node::Element(crate::html::Element {
name: String::from("td"),
attributes: HashMap::default(),
children: block
.into_iter()
.map(|x| x.to_html(env, scope))
.collect_vec(),
})
]
}
return vec![x.to_html(env, scope)]
})
.collect_vec();
crate::html::Node::Element(crate::html::Element {
name: String::from("tr"),
attributes: HashMap::default(),
children,
})
}
})
.finish();
// let table_row = CmdDeclBuilder::new(Ident::from("\\liX").unwrap())
// .parent_layout_mode(LayoutMode::Block)
// .parent(Ident::from("\\ul").unwrap())
// .arguments(arguments! {
// for (internal, metadata, cmd_payload) match {
// (.. as nodes) => {
// Node::Cmd(CmdCall {
// identifier: cmd_payload.identifier,
// attributes: cmd_payload.attributes.unwrap_or_default(),
// arguments: nodes
// })
// },
// }
// })
// .to_html(to_html! {
// fn (env, scope, cmd) {
// let children = cmd.arguments
// .into_iter()
// .flat_map(|x| {
// if let Some(block) = x.clone().into_curly_brace_children() {
// if block.len() == 1 && block[0].is_cmd_with_name("\\td") {
// return block
// .into_iter()
// .map(|x| x.to_html(env, scope))
// .collect_vec()
// }
// return vec![
// crate::html::Node::Element(crate::html::Element {
// name: String::from("td"),
// attributes: HashMap::default(),
// children: block
// .into_iter()
// .map(|x| x.to_html(env, scope))
// .collect_vec(),
// })
// ]
// }
// return vec![x.to_html(env, scope)]
// })
// .collect_vec();
// crate::html::Node::Element(crate::html::Element {
// name: String::from("tr"),
// attributes: HashMap::default(),
// children,
// })
// }
// })
// .finish();
vec![
table_row,
]
}