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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//! Typed HTML support for Rust.
//!
//! # Philosophy
//!
//! HTML is easy to get started with, but hard to get right. There are several
//! hundred element kinds, element attributes, and deeply nested hierachies - with
//! some relationships even being conditional on each other. Remembering all of this
//! is difficult and error-prone, but luckily we don't have to remember any of this
//! by using the type system! Rust's type system enables us to model the entire HTML
//! spec, allowing us to catch all errors ahead of time during compilation.
//!
//! This project comes in layers. The bottom-most layer is the HTML spec itself. We
//! download it, and parse it into definition files. We then take these definitions,
//! and use it to generate the `html-sys` crate. This crate is semantically correct,
//! and knows how to render itself to string representations. We then combine
//! `html-sys` with `web-sys` (wip) to create a higher-level HTML interface,
//! complete with support for events. This can be used to manipulate HTML both in
//! browser (wip) and non-browser contexts.
//!
//! # Examples
//!
//! We can create HTML structures one-by-one:
//! ```rust
//! # #![allow(unused)]
//! #![recursion_limit = "512"]
//!
//! use html::text_content::OrderedList;
//! let tree = OrderedList::builder()
//! .list_item(|li| li.text("nori").class("cat"))
//! .list_item(|li| li.text("chashu").class("cat"))
//! .build();
//! let string = tree.to_string();
//! ```
//! But we can also use Rust's native control flow structures such as loops to
//! iterate over items and create HTML:
//! ```rust
//! # #![allow(unused)]
//! #![recursion_limit = "512"]
//!
//! use html::text_content::OrderedList;
//! let mut ol = OrderedList::builder();
//! for name in ["hello", "world"] {
//! ol.list_item(|li| li.text(name));
//! }
//! let tree = ol.build();
//! ```
//!
//! We can also create elements separately and append them later:
//! ```rust
//! # #![allow(unused)]
//! #![recursion_limit = "512"]
//!
//! use html::text_content::{OrderedList, ListItem};
//! let mut ol = OrderedList::builder();
//! let li = ListItem::builder().text("hello").build();
//! ol.push(li);
//! let tree = ol.build();
//! ```
// #![deny(missing_debug_implementations, nonstandard_style)]
use Cow;
pub use *;
pub use content;
pub use edits;
pub use embedded;
pub use forms;
pub use inline_text;
pub use interactive;
pub use media;
pub use metadata;
pub use root;
pub use scripting;
pub use tables;
pub use text_content;
pub use web_components;
/// Render an HTML element to a string.
///
/// This API is similar to `Display`, but it takes a `depth` argument which
/// allows rendered items to be indented.
///
/// Users of this crate are expected to keep using the `Display` interface as
/// normal. This trait only exists for internal bookkeeping.
/// An HTML Element