unidok_repr/into_ir/
html.rs1use crate::ast::html::*;
2use crate::ast::AstData;
3use crate::ir::html::*;
4use crate::IntoIR;
5
6use super::utils::collapse_text;
7
8impl<'a> IntoIR<'a> for HtmlNodeAst {
9 type IR = HtmlNode<'a>;
10
11 fn into_ir(self, text: &'a str, data: &mut AstData) -> Self::IR {
12 match self {
13 HtmlNodeAst::Element(e) => HtmlNode::Element(e.into_ir(text, data)),
14 HtmlNodeAst::CData(c) => HtmlNode::CData(c.into_ir(text, data)),
15 HtmlNodeAst::Comment(c) => HtmlNode::Comment(c.text),
16 HtmlNodeAst::Doctype(d) => HtmlNode::Doctype(d.into_ir(text, data)),
17 }
18 }
19}
20
21impl<'a> IntoIR<'a> for DoctypeAst {
22 type IR = &'a str;
23
24 fn into_ir(self, text: &'a str, data: &mut AstData) -> Self::IR {
25 self.text.into_ir(text, data)
26 }
27}
28
29impl<'a> IntoIR<'a> for CDataSectionAst {
30 type IR = &'a str;
31
32 fn into_ir(self, text: &'a str, data: &mut AstData) -> Self::IR {
33 self.text.into_ir(text, data)
34 }
35}
36
37impl<'a> IntoIR<'a> for HtmlElemAst {
38 type IR = HtmlElem<'a>;
39
40 fn into_ir(self, text: &'a str, data: &mut AstData) -> Self::IR {
41 HtmlElem {
42 macros: vec![],
43 name: self.name,
44 attrs: self.attrs.into_ir(text, data),
45 content: self.content.into_ir(text, data),
46 close: self.close,
47 }
48 }
49}
50
51impl<'a> IntoIR<'a> for AttrAst {
52 type IR = Attr<'a>;
53
54 fn into_ir(self, text: &'a str, data: &mut AstData) -> Self::IR {
55 Attr { key: self.key.into_ir(text, data), value: self.value }
56 }
57}
58
59impl<'a> IntoIR<'a> for ElemContentAst {
60 type IR = ElemContent<'a>;
61
62 fn into_ir(self, text: &'a str, data: &mut AstData) -> Self::IR {
63 match self {
64 ElemContentAst::Blocks(b) => ElemContent::Blocks(b.into_ir(text, data)),
65 ElemContentAst::Inline(i) => ElemContent::Inline(collapse_text(i).into_ir(text, data)),
66 ElemContentAst::Verbatim(v) => ElemContent::Verbatim(v),
67 }
68 }
69}