Skip to content

Commit 7620ae9

Browse files
committed
docs: Clarify inline vs inline_fragment behavior
Signed-off-by: Dmitry Dygalo <dmitry@dygalo.dev>
1 parent 5e9e60f commit 7620ae9

File tree

8 files changed

+19
-7
lines changed

8 files changed

+19
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ fn main() -> css_inline::Result<()> {
8282

8383
Note that `css-inline` automatically adds missing `html` and `body` tags, so the output is a valid HTML document.
8484

85-
Alternatively, you can inline CSS into an HTML fragment, preserving the original structure:
85+
Alternatively, you can inline CSS into an HTML fragment. Structural tags (`<html>`, `<head>`, `<body>`) are stripped from the output; only their contents are preserved. Use `inline` if you need to keep the full document structure:
8686

8787
```rust
8888
const FRAGMENT: &str = r#"<main>

bindings/c/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ The inline function, `css_inline_to()`, doesn't allocate, so you must provide an
8888
8989
Note that `css-inline` automatically adds missing `html` and `body` tags, so the output is a valid HTML document.
9090
91-
Alternatively, you can inline CSS into an HTML fragment, preserving the original structure:
91+
Alternatively, you can inline CSS into an HTML fragment. Structural tags (`<html>`, `<head>`, `<body>`) are stripped from the output; only their contents are preserved. Use `css_inline_to` if you need to keep the full document structure:
9292
9393
```c
9494
#include "css_inline.h"

bindings/java/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public class ConfigExample {
160160

161161
### HTML Fragments
162162

163-
Alternatively, you can inline CSS into an HTML fragment, preserving the original structure:
163+
Alternatively, you can inline CSS into an HTML fragment. Structural tags (`<html>`, `<head>`, `<body>`) are stripped from the output; only their contents are preserved. Use `CssInline.inline` if you need to keep the full document structure:
164164

165165
```java
166166
import org.cssinline.CssInline;

bindings/javascript/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ var inlined = inline(
7878

7979
Note that `css-inline` automatically adds missing `html` and `body` tags, so the output is a valid HTML document.
8080

81-
Alternatively, you can inline CSS into an HTML fragment, preserving the original structure:
81+
Alternatively, you can inline CSS into an HTML fragment. Structural tags (`<html>`, `<head>`, `<body>`) are stripped from the output; only their contents are preserved. Use `inline` if you need to keep the full document structure:
8282

8383
```javascript
8484
import { inlineFragment } from "@css-inline/css-inline";

bindings/php/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ $inlined = CssInline\inline($html);
105105

106106
Note that `css_inline` automatically adds missing `html` and `body` tags, so the output is a valid HTML document.
107107

108-
Alternatively, you can inline CSS into an HTML fragment, preserving the original structure:
108+
Alternatively, you can inline CSS into an HTML fragment. Structural tags (`<html>`, `<head>`, `<body>`) are stripped from the output; only their contents are preserved. Use `CssInline\inline` if you need to keep the full document structure:
109109

110110
```php
111111
<?php

bindings/python/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ inlined = css_inline.inline(HTML)
9090

9191
Note that `css-inline` automatically adds missing `html` and `body` tags, so the output is a valid HTML document.
9292

93-
Alternatively, you can inline CSS into an HTML fragment, preserving the original structure:
93+
Alternatively, you can inline CSS into an HTML fragment. Structural tags (`<html>`, `<head>`, `<body>`) are stripped from the output; only their contents are preserved. Use `inline` if you need to keep the full document structure:
9494

9595
```python
9696
FRAGMENT = """<main>

bindings/ruby/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ puts inlined
7171

7272
Note that `css-inline` automatically adds missing `html` and `body` tags, so the output is a valid HTML document.
7373

74-
Alternatively, you can inline CSS into an HTML fragment, preserving the original structure:
74+
Alternatively, you can inline CSS into an HTML fragment. Structural tags (`<html>`, `<head>`, `<body>`) are stripped from the output; only their contents are preserved. Use `CSSInline.inline` if you need to keep the full document structure:
7575

7676
```ruby
7777
require 'css_inline'

css-inline/src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,14 @@ impl<'a> CSSInliner<'a> {
589589

590590
/// Inline CSS into an HTML fragment.
591591
///
592+
/// Unlike [`inline`](CSSInliner::inline), this method does not wrap the output in `<html>` and
593+
/// `<body>` tags. Structural tags (`<html>`, `<head>`, `<body>`) are stripped from the output;
594+
/// only their contents are preserved. CSS from `<style>` tags within the input is also
595+
/// processed and inlined.
596+
///
597+
/// If you need to preserve the full HTML document structure, use [`inline`](CSSInliner::inline)
598+
/// instead.
599+
///
592600
/// # Errors
593601
///
594602
/// Inlining might fail for the following reasons:
@@ -609,6 +617,8 @@ impl<'a> CSSInliner<'a> {
609617

610618
/// Inline CSS into an HTML fragment and write the result to a generic writer.
611619
///
620+
/// See [`inline_fragment`](CSSInliner::inline_fragment) for details on fragment handling.
621+
///
612622
/// # Errors
613623
///
614624
/// Inlining might fail for the following reasons:
@@ -939,6 +949,8 @@ pub fn inline_to<W: Write>(html: &str, target: &mut W) -> Result<()> {
939949

940950
/// Shortcut for inlining CSS into an HTML fragment with default parameters.
941951
///
952+
/// See [`CSSInliner::inline_fragment`] for details on fragment handling.
953+
///
942954
/// # Errors
943955
///
944956
/// Inlining might fail for the following reasons:

0 commit comments

Comments
 (0)