Skip to content

Commit ed91a85

Browse files
committed
docs: Use shorter examples
1 parent 3eb3d1a commit ed91a85

File tree

15 files changed

+48
-76
lines changed

15 files changed

+48
-76
lines changed

README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ For instance, the crate transforms HTML like this:
1515
```html
1616
<html>
1717
<head>
18-
<title>Test</title>
1918
<style>h1 { color:blue; }</style>
2019
</head>
2120
<body>
@@ -28,9 +27,7 @@ into:
2827

2928
```html
3029
<html>
31-
<head>
32-
<title>Test</title>
33-
</head>
30+
<head></head>
3431
<body>
3532
<h1 style="color:blue;">Big Text</h1>
3633
</body>
@@ -60,7 +57,6 @@ The Minimum Supported Rust Version is 1.60.
6057
```rust
6158
const HTML: &str = r#"<html>
6259
<head>
63-
<title>Test</title>
6460
<style>h1 { color:blue; }</style>
6561
</head>
6662
<body>
@@ -103,7 +99,6 @@ You can also skip CSS inlining for an HTML tag by adding the `data-css-inline="i
10399

104100
```html
105101
<head>
106-
<title>Test</title>
107102
<style>h1 { color:blue; }</style>
108103
</head>
109104
<body>
@@ -116,7 +111,6 @@ The `data-css-inline="ignore"` attribute also allows you to skip `link` and `sty
116111

117112
```html
118113
<head>
119-
<title>Test</title>
120114
<!-- Styles below are ignored -->
121115
<style data-css-inline="ignore">h1 { color:blue; }</style>
122116
</head>

benchmarks/benchmarks.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[
22
{
33
"name": "simple",
4-
"html": "<html><head><title>Test</title><style>h1, h2 { color:blue; }strong { text-decoration:none }p { font-size:2px }p.footer { font-size: 1px}</style></head><body><h1>Big Text</h1><p><strong>Solid</strong></p><p class=\"footer\">Foot notes</p></body></html>"
4+
"html": "<html><head><style>h1, h2 { color:blue; }strong { text-decoration:none }p { font-size:2px }p.footer { font-size: 1px}</style></head><body><h1>Big Text</h1><p><strong>Solid</strong></p><p class=\"footer\">Foot notes</p></body></html>"
55
},
66
{
77
"name": "merging",
8-
"html": "<html><head><title>Test</title><style>h1, h2 { color:blue; }strong { text-decoration:none }p { font-size:2px }p.footer { font-size: 1px}</style></head><body><h1 style=\"background-color: black;\">Big Text</h1><p style=\"background-color: black;\"><strong style=\"background-color: black;\">Solid</strong></p><p class=\"footer\" style=\"background-color: black;\">Foot notes</p></body></html>"
8+
"html": "<html><head><style>h1, h2 { color:blue; }strong { text-decoration:none }p { font-size:2px }p.footer { font-size: 1px}</style></head><body><h1 style=\"background-color: black;\">Big Text</h1><p style=\"background-color: black;\"><strong style=\"background-color: black;\">Solid</strong></p><p class=\"footer\" style=\"background-color: black;\">Foot notes</p></body></html>"
99
},
1010
{
1111
"name": "big_email_1",

bindings/python/README.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ For instance, the library transforms HTML like this:
1616
```html
1717
<html>
1818
<head>
19-
<title>Test</title>
2019
<style>h1 { color:blue; }</style>
2120
</head>
2221
<body>
@@ -29,9 +28,7 @@ into:
2928

3029
```html
3130
<html>
32-
<head>
33-
<title>Test</title>
34-
</head>
31+
<head></head>
3532
<body>
3633
<h1 style="color:blue;">Big Text</h1>
3734
</body>
@@ -65,7 +62,6 @@ import css_inline
6562

6663
HTML = """<html>
6764
<head>
68-
<title>Test</title>
6965
<style>h1 { color:blue; }</style>
7066
</head>
7167
<body>
@@ -78,7 +74,6 @@ inlined = css_inline.inline(HTML)
7874
#
7975
# <html>
8076
# <head>
81-
# <title>Test</title>
8277
# <style>h1 { color:blue; }</style>
8378
# </head>
8479
# <body>
@@ -119,7 +114,6 @@ You can also skip CSS inlining for an HTML tag by adding the `data-css-inline="i
119114

120115
```html
121116
<head>
122-
<title>Test</title>
123117
<style>h1 { color:blue; }</style>
124118
</head>
125119
<body>
@@ -132,7 +126,6 @@ The `data-css-inline="ignore"` attribute also allows you to skip `link` and `sty
132126

133127
```html
134128
<head>
135-
<title>Test</title>
136129
<!-- Styles below are ignored -->
137130
<style data-css-inline="ignore">h1 { color:blue; }</style>
138131
</head>

bindings/python/tests-py/test_inlining.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
def make_html(style: str, body: str) -> str:
11-
return "<html><head><title>Test</title><style>{style}</style></head><body>{body}</body></html>".format(
11+
return "<html><head><style>{style}</style></head><body>{body}</body></html>".format(
1212
style=style, body=body
1313
)
1414

@@ -37,9 +37,7 @@ def make_html(style: str, body: str) -> str:
3737
({"keep_style_tags": True}, make_html(SAMPLE_STYLE, SAMPLE_INLINED)),
3838
(
3939
{"keep_style_tags": False},
40-
"<html><head><title>Test</title></head><body>{body}</body></html>".format(
41-
body=SAMPLE_INLINED
42-
),
40+
"<html><head></head><body>{body}</body></html>".format(body=SAMPLE_INLINED),
4341
),
4442
),
4543
)

bindings/ruby/README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ For instance, the library transforms HTML like this:
1414
```html
1515
<html>
1616
<head>
17-
<title>Test</title>
1817
<style>h1 { color:blue; }</style>
1918
</head>
2019
<body>
@@ -27,9 +26,7 @@ into:
2726

2827
```html
2928
<html>
30-
<head>
31-
<title>Test</title>
32-
</head>
29+
<head></head>
3330
<body>
3431
<h1 style="color:blue;">Big Text</h1>
3532
</body>
@@ -88,7 +85,6 @@ You can also skip CSS inlining for an HTML tag by adding the `data-css-inline="i
8885

8986
```html
9087
<head>
91-
<title>Test</title>
9288
<style>h1 { color:blue; }</style>
9389
</head>
9490
<body>
@@ -101,7 +97,6 @@ The `data-css-inline="ignore"` attribute also allows you to skip `link` and `sty
10197

10298
```html
10399
<head>
104-
<title>Test</title>
105100
<!-- Styles below are ignored -->
106101
<style data-css-inline="ignore">h1 { color:blue; }</style>
107102
</head>

bindings/ruby/spec/css_inline_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
require_relative "../lib/css_inline"
55

66
def make_html(style, body)
7-
"<html><head><title>Test</title><style>#{style}</style></head><body>#{body}</body></html>"
7+
"<html><head><style>#{style}</style></head><body>#{body}</body></html>"
88
end
99

1010
SAMPLE_STYLE = """
@@ -29,7 +29,7 @@ def make_html(style, body)
2929

3030
test_cases = [
3131
["keep style tags", { keep_style_tags: true }, make_html(SAMPLE_STYLE, SAMPLE_INLINED)],
32-
["drop style tags", {}, "<html><head><title>Test</title></head><body>#{SAMPLE_INLINED}</body></html>"]
32+
["drop style tags", {}, "<html><head></head><body>#{SAMPLE_INLINED}</body></html>"]
3333
]
3434

3535
RSpec.describe 'CssInline' do

bindings/wasm/README.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ For instance, the library transforms HTML like this:
1414
```html
1515
<html>
1616
<head>
17-
<title>Test</title>
1817
<style>h1 { color:blue; }</style>
1918
</head>
2019
<body>
@@ -27,9 +26,7 @@ into:
2726

2827
```html
2928
<html>
30-
<head>
31-
<title>Test</title>
32-
</head>
29+
<head></head>
3330
<body>
3431
<h1 style="color:blue;">Big Text</h1>
3532
</body>
@@ -60,8 +57,7 @@ var inlined = inline(
6057
`
6158
<html>
6259
<head>
63-
<title>Test</title>
64-
<style>h1 { color:red; }</style>
60+
<style>h1 { color:red }</style>
6561
</head>
6662
<body>
6763
<h1>Test</h1>
@@ -85,7 +81,6 @@ You can also skip CSS inlining for an HTML tag by adding the `data-css-inline="i
8581

8682
```html
8783
<head>
88-
<title>Test</title>
8984
<style>h1 { color:blue; }</style>
9085
</head>
9186
<body>
@@ -99,7 +94,6 @@ The `data-css-inline="ignore"` attribute also allows you to skip `link` and `sty
9994

10095
```html
10196
<head>
102-
<title>Test</title>
10397
<!-- Styles below are ignored -->
10498
<style data-css-inline="ignore">h1 { color:blue; }</style>
10599
</head>

bindings/wasm/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ pub mod tests {
138138

139139
#[wasm_bindgen_test]
140140
fn default_config() {
141-
let result = inline("<html><head><title>Test</title><style>h1 { color:red; }</style></head><body><h1>Test</h1></body></html>", JsValue::undefined()).expect("Inlines correctly");
142-
assert_eq!(result, "<html><head><title>Test</title></head><body><h1 style=\"color:red;\">Test</h1></body></html>");
141+
let result = inline("<html><head><style>h1 { color:red; }</style></head><body><h1>Test</h1></body></html>", JsValue::undefined()).expect("Inlines correctly");
142+
assert_eq!(result, "<html><head></head><body><h1 style=\"color:red;\">Test</h1></body></html>");
143143
}
144144

145145
#[wasm_bindgen_test]
@@ -149,7 +149,7 @@ pub mod tests {
149149
..Options::default()
150150
};
151151
let options = serde_wasm_bindgen::to_value(&options).expect("Valid value");
152-
let result = inline("<html><head><title>Test</title><style>h1 { color:red; }</style></head><body><h1>Test</h1></body></html>", options).expect("Inlines correctly");
153-
assert_eq!(result, "<html><head><title>Test</title><style>h1 { color:red; }</style></head><body><h1 style=\"color:red;\">Test</h1></body></html>");
152+
let result = inline("<html><head><style>h1 { color:red; }</style></head><body><h1>Test</h1></body></html>", options).expect("Inlines correctly");
153+
assert_eq!(result, "<html><head><style>h1 { color:red; }</style></head><body><h1 style=\"color:red;\">Test</h1></body></html>");
154154
}
155155
}

bindings/wasm/tests-ts/css_inline.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ describe("CSS inliner", () => {
66
it("h1 style should be applied", function () {
77
expect(
88
inline(
9-
"<html><head><title>Test</title><style>h1 { color:red; }</style></head><body><h1>Test</h1></body></html>"
9+
"<html><head><style>h1 { color:red; }</style></head><body><h1>Test</h1></body></html>"
1010
)
1111
).to.equal(
12-
'<html><head><title>Test</title></head><body><h1 style="color:red;">Test</h1></body></html>'
12+
'<html><head></head><body><h1 style="color:red;">Test</h1></body></html>'
1313
);
1414
});
1515
it("style tag is kept", function () {
1616
expect(
1717
inline(
18-
"<html><head><title>Test</title><style>h1 { color:red; }</style></head><body><h1>Test</h1></body></html>",
18+
"<html><head><style>h1 { color:red; }</style></head><body><h1>Test</h1></body></html>",
1919
{ keep_style_tags: true }
2020
)
2121
).to.equal(
22-
'<html><head><title>Test</title><style>h1 { color:red; }</style></head><body><h1 style="color:red;">Test</h1></body></html>'
22+
'<html><head><style>h1 { color:red; }</style></head><body><h1 style="color:red;">Test</h1></body></html>'
2323
);
2424
});
2525
});

css-inline/src/html/document.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,9 @@ mod tests {
307307
fn test_collect_styles() {
308308
let doc = Document::parse_with_options(
309309
r#"
310-
<head
311-
><title>Test</title>
310+
<head>
312311
<style>h1 { color:blue; }</style>
313-
<style>h1 { color:red; }</style>
312+
<style>h1 { color:red }</style>
314313
<style data-css-inline='ignore'>h1 { color:yellow; }</style>
315314
</head>"#
316315
.as_bytes(),
@@ -319,7 +318,7 @@ mod tests {
319318
let styles = doc.styles().collect::<Vec<_>>();
320319
assert_eq!(styles.len(), 2);
321320
assert_eq!(styles[0], "h1 { color:blue; }");
322-
assert_eq!(styles[1], "h1 { color:red; }");
321+
assert_eq!(styles[1], "h1 { color:red }");
323322
}
324323

325324
#[test]

0 commit comments

Comments
 (0)