Skip to content

Commit c80a665

Browse files
committed
feat: Support the data-css-inline=keep attribute
Signed-off-by: Dmitry Dygalo <[email protected]>
1 parent 7a45a20 commit c80a665

File tree

12 files changed

+123
-0
lines changed

12 files changed

+123
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Added
66

77
- A way to customize resolving remote stylesheets.
8+
- Support for the `data-css-inline="keep"` attribute to enforce keeping the `style` tag.
89

910
### Changed
1011

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,21 @@ The `data-css-inline="ignore"` attribute also allows you to skip `link` and `sty
126126
</body>
127127
```
128128

129+
Alternatively, you may keep `style` from being removed by using the `data-css-inline="keep"` attribute.
130+
This is useful if you want to keep `@media` queries for responsive emails in separate `style` tags:
131+
132+
```html
133+
<head>
134+
<!-- Styles below are not removed -->
135+
<style data-css-inline="keep">h1 { color:blue; }</style>
136+
</head>
137+
<body>
138+
<h1>Big Text</h1>
139+
</body>
140+
```
141+
142+
Such tags will be kept in the resulting HTML even if the `keep_style_tags` option is set to `false`.
143+
129144
If you'd like to load stylesheets from your filesystem, use the `file://` scheme:
130145

131146
```rust

bindings/c/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## [Unreleased]
44

5+
### Added
6+
7+
- Support for the `data-css-inline="keep"` attribute to enforce keeping the `style` tag.
8+
59
### Fixed
610

711
- Lookups for previous / next siblings, affecting selectors like `nth-child`. [#324](https://github.com/Stranger6667/css-inline/issues/324)

bindings/c/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,21 @@ The `data-css-inline="ignore"` attribute also allows you to skip `link` and `sty
141141
</body>
142142
```
143143

144+
Alternatively, you may keep `style` from being removed by using the `data-css-inline="keep"` attribute.
145+
This is useful if you want to keep `@media` queries for responsive emails in separate `style` tags:
146+
147+
```html
148+
<head>
149+
<!-- Styles below are not removed -->
150+
<style data-css-inline="keep">h1 { color:blue; }</style>
151+
</head>
152+
<body>
153+
<h1>Big Text</h1>
154+
</body>
155+
```
156+
157+
Such tags will be kept in the resulting HTML even if the `keep_style_tags` option is set to `false`.
158+
144159
## License
145160

146161
This project is licensed under the terms of the [MIT license](https://opensource.org/licenses/MIT).

bindings/javascript/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## [Unreleased]
44

5+
### Added
6+
7+
- Support for the `data-css-inline="keep"` attribute to enforce keeping the `style` tag.
8+
59
### Fixed
610

711
- Lookups for previous / next siblings, affecting selectors like `nth-child`. [#324](https://github.com/Stranger6667/css-inline/issues/324)

bindings/javascript/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,21 @@ The `data-css-inline="ignore"` attribute also allows you to skip `link` and `sty
110110
</body>
111111
```
112112

113+
Alternatively, you may keep `style` from being removed by using the `data-css-inline="keep"` attribute.
114+
This is useful if you want to keep `@media` queries for responsive emails in separate `style` tags:
115+
116+
```html
117+
<head>
118+
<!-- Styles below are not removed -->
119+
<style data-css-inline="keep">h1 { color:blue; }</style>
120+
</head>
121+
<body>
122+
<h1>Big Text</h1>
123+
</body>
124+
```
125+
126+
Such tags will be kept in the resulting HTML even if the `keep_style_tags` option is set to `false`.
127+
113128
## WebAssembly
114129

115130
`css-inline` also ships a WebAssembly module built with `wasm-bindgen` to run in browsers.

bindings/python/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## [Unreleased]
44

5+
### Added
6+
7+
- Support for the `data-css-inline="keep"` attribute to enforce keeping the `style` tag.
8+
59
### Fixed
610

711
- Lookups for previous / next siblings, affecting selectors like `nth-child`. [#324](https://github.com/Stranger6667/css-inline/issues/324)

bindings/python/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,21 @@ The `data-css-inline="ignore"` attribute also allows you to skip `link` and `sty
144144
</body>
145145
```
146146

147+
Alternatively, you may keep `style` from being removed by using the `data-css-inline="keep"` attribute.
148+
This is useful if you want to keep `@media` queries for responsive emails in separate `style` tags:
149+
150+
```html
151+
<head>
152+
<!-- Styles below are not removed -->
153+
<style data-css-inline="keep">h1 { color:blue; }</style>
154+
</head>
155+
<body>
156+
<h1>Big Text</h1>
157+
</body>
158+
```
159+
160+
Such tags will be kept in the resulting HTML even if the `keep_style_tags` option is set to `false`.
161+
147162
If you'd like to load stylesheets from your filesystem, use the `file://` scheme:
148163

149164
```python

bindings/ruby/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## [Unreleased]
44

5+
### Added
6+
7+
- Support for the `data-css-inline="keep"` attribute to enforce keeping the `style` tag.
8+
59
### Fixed
610

711
- Lookups for previous / next siblings, affecting selectors like `nth-child`. [#324](https://github.com/Stranger6667/css-inline/issues/324)

bindings/ruby/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,21 @@ The `data-css-inline="ignore"` attribute also allows you to skip `link` and `sty
125125
</body>
126126
```
127127

128+
Alternatively, you may keep `style` from being removed by using the `data-css-inline="keep"` attribute.
129+
This is useful if you want to keep `@media` queries for responsive emails in separate `style` tags:
130+
131+
```html
132+
<head>
133+
<!-- Styles below are not removed -->
134+
<style data-css-inline="keep">h1 { color:blue; }</style>
135+
</head>
136+
<body>
137+
<h1>Big Text</h1>
138+
</body>
139+
```
140+
141+
Such tags will be kept in the resulting HTML even if the `keep_style_tags` option is set to `false`.
142+
128143
If you'd like to load stylesheets from your filesystem, use the `file://` scheme:
129144

130145
```ruby

0 commit comments

Comments
 (0)