Skip to content

Commit 9c90567

Browse files
committed
docs: Improve documentation
1 parent d0e52cc commit 9c90567

File tree

1 file changed

+32
-53
lines changed

1 file changed

+32
-53
lines changed

src/lib.rs

Lines changed: 32 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,10 @@
99
//! <html>
1010
//! <head>
1111
//! <title>Test</title>
12-
//! <style>
13-
//! h1, h2 { color:blue; }
14-
//! strong { text-decoration:none }
15-
//! p { font-size:2px }
16-
//! p.footer { font-size: 1px}
17-
//! </style>
12+
//! <style>h1 { color:blue; }</style>
1813
//! </head>
1914
//! <body>
2015
//! <h1>Big Text</h1>
21-
//! <p>
22-
//! <strong>Solid</strong>
23-
//! </p>
24-
//! <p class="footer">Foot notes</p>
2516
//! </body>
2617
//! </html>
2718
//! ```
@@ -30,38 +21,23 @@
3021
//!
3122
//! ```html
3223
//! <html>
33-
//! <head>
34-
//! <title>Test</title>
35-
//! </head>
24+
//! <head><title>Test</title></head>
3625
//! <body>
3726
//! <h1 style="color:blue;">Big Text</h1>
38-
//! <p style="font-size:2px;">
39-
//! <strong style="text-decoration:none;">Solid</strong>
40-
//! </p>
41-
//! <p style="font-size:1px;">Foot notes</p>
4227
//! </body>
4328
//! </html>
4429
//! ```
4530
//!
46-
//! ## Example:
31+
//! ## Usage
4732
//!
4833
//! ```rust
4934
//! const HTML: &str = r#"<html>
5035
//! <head>
5136
//! <title>Test</title>
52-
//! <style>
53-
//! h1, h2 { color:blue; }
54-
//! strong { text-decoration:none }
55-
//! p { font-size:2px }
56-
//! p.footer { font-size: 1px}
57-
//! </style>
37+
//! <style>h1 { color:blue; }</style>
5838
//! </head>
5939
//! <body>
6040
//! <h1>Big Text</h1>
61-
//! <p>
62-
//! <strong>Solid</strong>
63-
//! </p>
64-
//! <p class="footer">Foot notes</p>
6541
//! </body>
6642
//! </html>"#;
6743
//!
@@ -72,35 +48,38 @@
7248
//! }
7349
//! ```
7450
//!
75-
//! Or if you need more control over inlining you could use `CSSInliner`:
51+
//! ### Features
52+
//!
53+
//! `css-inline` does minimum work by default:
54+
//!
55+
//! - No CSS transformation;
56+
//! - No "style" or "link" tags removal;
57+
//!
58+
//! It also loads external stylesheets via network or filesystem, but this behavior is configurable.
59+
//!
60+
//! ### Configuration
61+
//!
62+
//! `css-inline` can be configured by using `InlineOptions` and `CSSInliner`:
7663
//!
7764
//! ```rust
78-
//! const HTML: &str = r#"<html>
79-
//! <head>
80-
//! <title>Test</title>
81-
//! <style>
82-
//! h1, h2 { color:blue; }
83-
//! strong { text-decoration:none }
84-
//! p { font-size:2px }
85-
//! p.footer { font-size: 1px}
86-
//! </style>
87-
//! </head>
88-
//! <body>
89-
//! <h1>Big Text</h1>
90-
//! <p>
91-
//! <strong>Solid</strong>
92-
//! </p>
93-
//! <p class="footer">Foot notes</p>
94-
//! </body>
95-
//! </html>"#;
65+
//! use css_inline;
9666
//!
97-
//!fn main() -> Result<(), css_inline::InlineError> {
98-
//! let inliner = css_inline::CSSInliner::compact();
99-
//! let inlined = inliner.inline(HTML)?;
100-
//! // Do something with inlined HTML, e.g. send an email
101-
//! Ok(())
67+
//! fn main() -> Result<(), css_inline::InlineError> {
68+
//! let options = css_inline::InlineOptions {
69+
//! load_remote_stylesheets: false,
70+
//! ..Default::default()
71+
//! };
72+
//! let inliner = css_inline::CSSInliner(options);
73+
//! let inlined = inliner.inline(HTML);
74+
//! // Do something with inlined HTML, e.g. send an email
75+
//! Ok(())
10276
//! }
103-
//!```
77+
//! ```
78+
//!
79+
//! - `remove_style_tags`. Remove "style" tags after inlining.
80+
//! - `base_url`. Base URL to resolve relative URLs
81+
//! - `load_remote_stylesheets`. Whether remote stylesheets should be loaded or not
82+
//!
10483
#![warn(
10584
clippy::doc_markdown,
10685
clippy::redundant_closure,

0 commit comments

Comments
 (0)