Skip to content

Commit 3a52132

Browse files
committed
docs: Update README
1 parent b2366f4 commit 3a52132

File tree

1 file changed

+78
-1
lines changed

1 file changed

+78
-1
lines changed

README.md

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,79 @@
11
# css-inline
2-
Inline CSS into style attributes
2+
A crate for inlining CSS into HTML documents. When you send HTML emails you need to use "style" attributes instead of "style" tags.
3+
4+
For example, this HTML:
5+
6+
```html
7+
<html>
8+
<head>
9+
<title>Test</title>
10+
<style>
11+
h1, h2 { color:blue; }
12+
strong { text-decoration:none }
13+
p { font-size:2px }
14+
p.footer { font-size: 1px}
15+
</style>
16+
</head>
17+
<body>
18+
<h1>Big Text</h1>
19+
<p>
20+
<strong>Solid</strong>
21+
</p>
22+
<p class="footer">Foot notes</p>
23+
</body>
24+
</html>
25+
```
26+
27+
Will be turned into this:
28+
29+
```html
30+
<html>
31+
<head>
32+
<title>Test</title>
33+
</head>
34+
<body>
35+
<h1 style="color:blue;">Big Text</h1>
36+
<p style="font-size:2px;">
37+
<strong style="text-decoration:none;">Solid</strong>
38+
</p>
39+
<p style="font-size:1px;">Foot notes</p>
40+
</body>
41+
</html>
42+
```
43+
44+
To use it in your project add the following line to your `dependencies` section in project's `Cargo.toml` file:
45+
46+
```toml
47+
cssinline = "0.1"
48+
```
49+
50+
## Example:
51+
52+
```rust
53+
use cssinline
54+
55+
const HTML: &str = r#"<html>
56+
<head>
57+
<title>Test</title>
58+
<style>
59+
h1, h2 { color:blue; }
60+
strong { text-decoration:none }
61+
p { font-size:2px }
62+
p.footer { font-size: 1px}
63+
</style>
64+
</head>
65+
<body>
66+
<h1>Big Text</h1>
67+
<p>
68+
<strong>Solid</strong>
69+
</p>
70+
<p class="footer">Foot notes</p>
71+
</body>
72+
</html>"#;
73+
74+
fn main() -> Result<(), css_inline::InlineError> {
75+
let inlined = css_inline::inline(HTML)?;
76+
// Do something with inlined HTML, e.g. send an email
77+
Ok(())
78+
}
79+
```

0 commit comments

Comments
 (0)