### Start Test Server with Python Source: https://github.com/stranger6667/css-inline/blob/master/CONTRIBUTING.md Starts the test server required for running tests in the css-inline project. This command should be executed in the background. ```shell python ./css-inline/tests/server.py & ``` -------------------------------- ### CLI: Installation and Usage Source: https://context7.com/stranger6667/css-inline/llms.txt Instructions for installing and using the `css-inline` command-line interface tool to process HTML files. ```APIDOC ## Command Line Interface ### Description This section covers the installation and usage of the `css-inline` CLI tool, allowing you to inline CSS directly from your terminal. ### Installation Install the `css-inline` CLI tool using Cargo: ```bash cargo install css-inline ``` ### Usage #### Inline CSS in a single file Process an HTML file and save the output to a new file (e.g., `inlined.email.html`). ```bash css-inline email.html ``` #### Inline CSS in multiple files Process multiple HTML files concurrently. The tool will process them in parallel using Rust's threading capabilities. ```bash css-inline email1.html email2.html email3.html ``` ### Output By default, the output is written to a new file named `.inlined.html` in the same directory. If multiple files are processed, each will generate its own inlined file. ``` -------------------------------- ### Gradle Setup for css-inline Java Bindings Source: https://github.com/stranger6667/css-inline/blob/master/bindings/java/README.md Configures Gradle to use GitHub Packages as a repository and adds the css-inline dependency. Requires authentication credentials for GitHub Packages. ```gradle repositories { maven { url = uri("https://maven.pkg.github.com/Stranger6667/css-inline") credentials { username = project.findProperty("gpr.user") ?: System.getenv("USERNAME") password = project.findProperty("gpr.key") ?: System.getenv("TOKEN") } } } dependencies { implementation 'org.css-inline:css-inline:0.20.0' } ``` -------------------------------- ### Install css_inline PHP Extension Source: https://github.com/stranger6667/css-inline/blob/master/bindings/php/README.md Instructions for cloning the repository, building the PHP extension using Cargo, and copying the compiled extension to the PHP extensions directory. This process is for Linux and macOS. ```shell git clone https://github.com/Stranger6667/css-inline.git cd css-inline/bindings/php cargo build --release # Linux cp target/release/libcss_inline_php.so $(php-config --extension-dir)/css_inline.so # macOS cp target/release/libcss_inline_php.dylib $(php-config --extension-dir)/css_inline.so ``` -------------------------------- ### Maven Setup for css-inline Java Bindings Source: https://github.com/stranger6667/css-inline/blob/master/bindings/java/README.md Configures Maven to use GitHub Packages as a repository and adds the css-inline dependency. Requires authentication credentials for GitHub Packages. ```xml github https://maven.pkg.github.com/Stranger6667/css-inline org.css-inline css-inline 0.20.0 ``` -------------------------------- ### Install css-inline CLI using Cargo Source: https://github.com/stranger6667/css-inline/blob/master/README.md Provides the command to install the css-inline command-line interface tool using the Cargo package manager. This allows users to inline CSS directly from their terminal. ```text cargo install css-inline ``` -------------------------------- ### Initialize and Use WebAssembly CSS Inline Source: https://github.com/stranger6667/css-inline/blob/master/bindings/javascript/README.md Shows how to initialize and use the WebAssembly module for CSS inlining directly in the browser. This example includes initializing the WASM module and then calling the `inline` function. ```html ``` -------------------------------- ### WebAssembly Module - Browser Usage Source: https://context7.com/stranger6667/css-inline/llms.txt Provides an example of how to use the CSS Inline WebAssembly module directly in a web browser. ```APIDOC ## WebAssembly Module - Browser Usage ### Description Use css-inline directly in the browser via WebAssembly. This allows for client-side CSS inlining without needing a server-side process. ### Initialization First, initialize the WASM module by providing the path to the WASM file. ```javascript // Initialize the WASM module first cssInline.initWasm(fetch('https://unpkg.com/@css-inline/css-inline-wasm/index_bg.wasm')); ``` ### Method `cssInline.inline(html: string): string` ### Parameters #### Arguments - **html** (string) - The HTML content to process. ### Request Example ```html ``` ### Response #### Success Response (string) - **inlinedHtml** (string) - The HTML content with CSS styles inlined. #### Response Example ```html

Big Text

``` ### Limitations - The WebAssembly module does not support network fetching of external stylesheets. - Caching of stylesheets is not available in the WASM version. ``` -------------------------------- ### Install and Use CSS Inline CLI Source: https://context7.com/stranger6667/css-inline/llms.txt Install the CSS Inline command-line interface tool using Cargo and process HTML files directly from the terminal. This provides a convenient way to inline CSS without writing code. Supports single and multiple file processing, with parallel execution for multiple files. ```bash # Install css-inline CLI carp install css-inline # Inline CSS in a single file css-inline email.html # Output: inlined.email.html # Inline CSS in multiple files (processed in parallel) css-inline email1.html email2.html email3.html ``` -------------------------------- ### Configure CSS Inlining Process (Java) Source: https://github.com/stranger6667/css-inline/blob/master/bindings/java/README.md This example demonstrates how to customize the CSS inlining behavior using CssInlineConfig. Options include controlling the loading of remote stylesheets, keeping style tags, setting a base URL, and more. The configured instance is then used with the CssInline.inline method. ```java import org.cssinline.CssInline; import org.cssinline.CssInlineConfig; public class ConfigExample { public static void main(String[] args) { String html = "..."; CssInlineConfig config = new CssInlineConfig.Builder() .setLoadRemoteStylesheets(false) .setKeepStyleTags(true) .setBaseUrl("https://example.com/") .build(); String inlined = CssInline.inline(html, config); } } ``` -------------------------------- ### Setting Base URL for Relative Stylesheets (PHP) Source: https://github.com/stranger6667/css-inline/blob/master/bindings/php/README.md Demonstrates how to configure the CssInliner to resolve relative URLs for stylesheets by setting the 'baseUrl' option. The example uses the 'file://' scheme to load stylesheets from the local filesystem. ```php inline($html); ``` -------------------------------- ### Install css-inline using pip Source: https://github.com/stranger6667/css-inline/blob/master/bindings/python/README.md This command installs the css-inline Python package using pip. It ensures that the necessary files are downloaded and set up for use in your Python environment. Pre-compiled wheels are available for most platforms, but a Rust compiler might be needed for others. ```shell pip install css_inline ``` -------------------------------- ### Install css-inline via npm Source: https://github.com/stranger6667/css-inline/blob/master/bindings/javascript/README.md Installs the css-inline library using npm, a package manager for Node.js. This command is typically run in a Node.js project's root directory. ```shell npm i @css-inline/css-inline ``` -------------------------------- ### WebAssembly: Browser Usage Source: https://context7.com/stranger6667/css-inline/llms.txt Provides an example of using the `@css-inline/css-inline-wasm` WebAssembly module directly in a web browser. It shows how to initialize the WASM module and then use the `inline` function to process HTML. ```html ``` -------------------------------- ### Implement Custom Stylesheet Loading with StylesheetResolver (Rust) Source: https://context7.com/stranger6667/css-inline/llms.txt Shows how to implement the `StylesheetResolver` trait for custom stylesheet loading logic. This allows fetching stylesheets from various sources beyond standard URLs. The example demonstrates a custom resolver that only supports `custom://` URLs. ```rust use css_inline::{CSSInliner, StylesheetResolver}; use std::sync::Arc; #[derive(Debug, Default)] pub struct CustomResolver; impl StylesheetResolver for CustomResolver { fn retrieve(&self, location: &str) -> css_inline::Result { // Custom logic to fetch stylesheets if location.starts_with("custom://") { Ok("h1 { color: green; }".to_string()) } else { Err(self.unsupported("Only custom:// URLs are supported")) } } } fn main() -> css_inline::Result<()> { let inliner = CSSInliner::options() .resolver(Arc::new(CustomResolver)) .build(); // Use custom resolver for stylesheet loading Ok(()) } ``` -------------------------------- ### Inline CSS into HTML with Default Configuration (Java) Source: https://github.com/stranger6667/css-inline/blob/master/bindings/java/README.md This example shows the basic usage of the CssInline.inline method to apply CSS styles directly within HTML tags. It takes an HTML string with embedded styles and returns the HTML with those styles inlined. No external dependencies are required beyond the CssInline library itself. ```java import org.cssinline.CssInline; public class Example { public static void main(String[] args) { String html = """

Big Text

"""; String inlined = CssInline.inline(html); System.out.println(inlined); } } ``` -------------------------------- ### Inline CSS into HTML Fragment (Java) Source: https://github.com/stranger6667/css-inline/blob/master/bindings/java/README.md This example shows how to use the inlineFragment method to apply CSS rules to an HTML fragment that may not have a complete document structure. It takes separate strings for the HTML fragment and the CSS rules, returning the HTML fragment with the styles inlined. ```java import org.cssinline.CssInline; public class FragmentExample { public static void main(String[] args) { String fragment = """

Hello

who am i

"""; String css = """ p { color: red; } h1 { color: blue; } """; String inlined = CssInline.inlineFragment(fragment, css); System.out.println(inlined); } } ``` -------------------------------- ### Implement Custom Stylesheet Resolver - Rust Source: https://github.com/stranger6667/css-inline/blob/master/README.md Provides an example of implementing a custom `StylesheetResolver` trait in Rust. The `CustomStylesheetResolver` struct demonstrates how to handle stylesheet retrieval, in this case, by explicitly returning an error for unsupported external stylesheets. ```rust #[derive(Debug, Default)] pub struct CustomStylesheetResolver; impl css_inline::StylesheetResolver for CustomStylesheetResolver { fn retrieve(&self, location: &str) -> css_inline::Result { Err(self.unsupported("External stylesheets are not supported")) } } fn main() -> css_inline::Result<()> { let inliner = css_inline::CSSInliner::options() ``` -------------------------------- ### Inline CSS into an HTML fragment (Ruby) Source: https://github.com/stranger6667/css-inline/blob/master/bindings/ruby/README.md This example shows how to use `CSSInline.inline_fragment` to apply CSS to a specific HTML fragment. This method is useful when you have a piece of HTML and a separate block of CSS that you want to combine. It allows for more granular control over the inlining process without altering the overall HTML structure beyond applying styles. ```ruby require 'css_inline' fragment = """

Hello

who am i

" css = """ p { color: red; } h1 { color: blue; } " inlined = CSSInline.inline_fragment(fragment, css) puts inlined # HTML becomes this: #
#

Hello

#
#

who am i

#
#
``` -------------------------------- ### Run Tests with Cargo Source: https://github.com/stranger6667/css-inline/blob/master/CONTRIBUTING.md Executes the tests for the css-inline project using the cargo test command. This assumes the test server is already running. ```shell cargo test ``` -------------------------------- ### Basic CSS Inlining with Configuration (PHP) Source: https://github.com/stranger6667/css-inline/blob/master/bindings/php/README.md Demonstrates basic CSS inlining using the CssInliner class in PHP. It shows how to instantiate the class with the 'keepStyleTags' option set to true and then perform the inlining operation on an HTML string. ```php inline($html); ``` -------------------------------- ### Initialize CSSInliner with Options (Ruby) Source: https://github.com/stranger6667/css-inline/blob/master/bindings/ruby/README.md Demonstrates how to initialize the CSSInliner class in Ruby with various configuration options. These options control aspects like keeping style tags, minifying CSS, and handling remote stylesheets. ```ruby require 'css_inline' inliner = CSSInline::CSSInliner.new(keep_style_tags: true) inliner.inline("...") ``` ```ruby require 'css_inline' # styles/email is relative to the current directory inliner = CSSInline::CSSInliner.new(base_url: "file://styles/email/") inliner.inline("...") ``` ```ruby require 'css_inline' inliner = CSSInline::CSSInliner.new( cache: CSSInline::StylesheetCache.new(size: 5) ) inliner.inline("...") ``` -------------------------------- ### Python CSSInliner Configuration Source: https://context7.com/stranger6667/css-inline/llms.txt Demonstrates how to create a configured CSSInliner instance in Python with various options for controlling the inlining process. ```APIDOC ## Python CSSInliner Configuration ### Description This section shows how to instantiate and configure the `CSSInliner` class in Python. You can control aspects like style tag handling, CSS minification, remote stylesheet loading, and more. ### Method `css_inline.CSSInliner(**options)` ### Parameters #### Keyword Arguments - **inline_style_tags** (bool) - Optional - Whether to inline CSS from `

Hello

""" result = inliner.inline(html) print(result) ``` ### Response #### Success Response (str) - **result** (str) - The HTML content with CSS styles inlined. #### Response Example ```html

Hello

``` ``` -------------------------------- ### Minifying CSS with Configuration (HTML) Source: https://github.com/stranger6667/css-inline/blob/master/bindings/php/README.md Shows how to enable CSS minification by setting the 'minifyCss' option to true. This removes trailing semicolons and spaces between CSS properties and values, resulting in more compact inline styles. ```html

Big Text

``` -------------------------------- ### Cache External Stylesheets with TypeScript Source: https://github.com/stranger6667/css-inline/blob/master/bindings/javascript/README.md Provides a TypeScript example of inlining HTML with an external stylesheet, utilizing the `cache` option to manage external stylesheet requests. Caching is disabled by default. ```typescript import { inline } from "@css-inline/css-inline"; var inlined = inline( `

Test

`, { cache: { size: 5 } }, ); ``` -------------------------------- ### Display Help for css-inline CLI Source: https://github.com/stranger6667/css-inline/blob/master/README.md Shows the command to display the help message for the css-inline command-line interface. This provides information on all available options and usage instructions. ```text css-inline --help ``` -------------------------------- ### Caching External Stylesheets (PHP) Source: https://github.com/stranger6667/css-inline/blob/master/bindings/php/README.md Illustrates how to implement caching for external stylesheets using the 'StylesheetCache' class. This helps to avoid repeated network requests for the same stylesheets, improving performance. ```php inline($html); ``` -------------------------------- ### CSS Inline Common Options (Command Line) Source: https://context7.com/stranger6667/css-inline/llms.txt Illustrates common command-line options for css-inline, such as keeping style tags, link tags, setting a base URL, and adding extra CSS rules. ```bash css-inline --keep-style-tags email.html css-inline --keep-link-tags email.html css-inline --base-url "https://example.com/" email.html css-inline --extra-css "p { margin: 0; }" email.html ``` -------------------------------- ### Inline CSS into an HTML fragment Source: https://github.com/stranger6667/css-inline/blob/master/bindings/python/README.md This Python example shows how to use `css_inline.inline_fragment` to apply CSS rules to an HTML fragment without altering its structure. It takes both the HTML fragment and a CSS string as input, returning the fragment with styles inlined. ```python import css_inline FRAGMENT = """

Hello

who am i

""" CSS = "" p { color: red; } h1 { color: blue; } "" inlined = css_inline.inline_fragment(FRAGMENT, CSS) # HTML becomes this: #
#

Hello

#
#

who am i

#
#
``` -------------------------------- ### Configure Base URL for Filesystem Stylesheets - Rust Source: https://github.com/stranger6667/css-inline/blob/master/README.md Shows how to configure the `base_url` option in Rust to load stylesheets from the filesystem using the `file://` scheme. This involves parsing a URL and passing it to the `CSSInliner::options()` builder. ```rust const HTML: &str = "..."; fn main() -> css_inline::Result<()> { let base_url = css_inline::Url::parse("file://styles/email/").expect("Invalid URL"); let inliner = css_inline::CSSInliner::options() .base_url(Some(base_url)) .build(); let inlined = inliner.inline(HTML); // Do something with inlined HTML, e.g. send an email Ok(()) } ``` -------------------------------- ### Write Inlined CSS Output to a Writer (Rust) Source: https://context7.com/stranger6667/css-inline/llms.txt Illustrates using the `inline_to` function to write the inlined CSS output directly to any type implementing `std::io::Write`. This is useful for writing to files or streaming the output. The example shows writing to both a `File` and a `Vec` buffer. ```rust use css_inline::CSSInliner; use std::fs::File; fn main() -> css_inline::Result<()> { let html = r###"

Text

"###; // Write to file let mut file = File::create("output.html").expect("Failed to create file"); CSSInliner::default().inline_to(html, &mut file)?; // Write to Vec let mut buffer: Vec = Vec::new(); css_inline::inline_to(html, &mut buffer)?; let result = String::from_utf8_lossy(&buffer); println!("{}", result); Ok(()) } ``` -------------------------------- ### Python: Create Configured CSS Inliner Source: https://context7.com/stranger6667/css-inline/llms.txt Demonstrates creating a CSSInliner instance in Python with various configuration options to control the inlining process. This includes options for handling style tags, link tags, media queries, minification, base URLs, remote stylesheets, and attribute application. ```python import css_inline inliner = css_inline.CSSInliner( inline_style_tags=True, # Inline CSS from

Hello

""" result = inliner.inline(html) print(result) ``` -------------------------------- ### Configure CSS Inliner with Options - Rust Source: https://github.com/stranger6667/css-inline/blob/master/README.md Demonstrates how to configure the CSSInliner in Rust using the Builder pattern. It shows setting options like `load_remote_stylesheets` before building the inliner instance and then using it to inline CSS into HTML. ```rust const HTML: &str = "..."; fn main() -> css_inline::Result<()> { let inliner = css_inline::CSSInliner::options() .load_remote_stylesheets(false) .build(); let inlined = inliner.inline(HTML)?; // Do something with inlined HTML, e.g. send an email Ok(()) } ``` -------------------------------- ### Usage of css-inline CLI for Multiple Files Source: https://github.com/stranger6667/css-inline/blob/master/README.md Demonstrates how to use the css-inline command-line tool to inline CSS in multiple HTML files simultaneously. The command processes the specified files and saves the output with modified filenames. ```text css-inline email1.html email2.html ``` -------------------------------- ### JavaScript/Node.js `inline()` with Options Source: https://context7.com/stranger6667/css-inline/llms.txt Shows how to use the `inline()` function with a configuration object to customize the CSS inlining behavior in JavaScript. ```APIDOC ## `inline()` with Options - Configured Inlining ### Description Pass configuration options as the second argument to the `inline()` function to customize inlining behavior in JavaScript/Node.js. This allows for fine-grained control over how CSS is processed and applied. ### Method `inline(html: string, options?: InlineOptions): string` ### Parameters #### Arguments - **html** (string) - The HTML content to process. - **options** (object, optional) - Configuration options for inlining. - **inlineStyleTags** (boolean) - Optional - Inline CSS from `

Test

`; const inlined = inline(html, { inlineStyleTags: true, keepStyleTags: false, keepLinkTags: false, keepAtRules: true, minifyCss: true, baseUrl: "https://example.com/", loadRemoteStylesheets: true, extraCss: "p { margin: 0; }", preallocateNodeCapacity: 64, cache: { size: 5 }, removeInlinedSelectors: false, applyWidthAttributes: true, applyHeightAttributes: true, }); console.log(inlined); ``` ### Response #### Success Response (string) - **inlined** (string) - The HTML content with CSS styles inlined according to the provided options. #### Response Example ```html

Test

``` ``` -------------------------------- ### JavaScript/Node.js `inlineFragment()` Source: https://context7.com/stranger6667/css-inline/llms.txt Demonstrates how to use `inlineFragment()` to inline CSS into a specific HTML fragment, providing both the fragment and the CSS rules. ```APIDOC ## `inlineFragment()` - Inline CSS into Fragment ### Description Inline CSS into an HTML fragment in JavaScript. This function is useful when you need to apply styles to a piece of HTML that might not be a complete document. ### Method `inlineFragment(fragment: string, css: string): string` ### Parameters #### Arguments - **fragment** (string) - The HTML fragment to process. - **css** (string) - The CSS rules to inline into the fragment. ### Request Example ```typescript import { inlineFragment } from "@css-inline/css-inline"; const fragment = `

Hello

who am i

`; const css = ` p { color: red; } h1 { color: blue; } `; const inlined = inlineFragment(fragment, css); // Result: //
//

Hello

//
//

who am i

//
//
console.log(inlined); ``` ### Response #### Success Response (string) - **inlined** (string) - The HTML fragment with CSS styles inlined. #### Response Example ```html

Hello

who am i

``` ``` -------------------------------- ### Configure CSS Inliner with Python Source: https://github.com/stranger6667/css-inline/blob/master/bindings/python/README.md Demonstrates how to initialize and use the CSSInliner class in Python. It shows setting configuration options like `keep_style_tags` and performing the inlining operation. ```python import css_inline inliner = css_inline.CSSInliner(keep_style_tags=True) inliner.inline("...") ``` -------------------------------- ### Keeping At-Rules with Configuration (HTML) Source: https://github.com/stranger6667/css-inline/blob/master/bindings/php/README.md Explains how to keep at-rules, such as media queries, within style tags while still inlining other CSS properties. This is achieved by setting the 'keepAtRules' option to true in the CssInliner configuration. ```html

Big Text

``` -------------------------------- ### Set Base URL for Filesystem Stylesheets in Python Source: https://github.com/stranger6667/css-inline/blob/master/bindings/python/README.md Shows how to configure the `CSSInliner` to load stylesheets from the local filesystem by specifying a `base_url` with the `file://` scheme. This is useful for managing project assets. ```python import css_inline # styles/email is relative to the current directory inliner = css_inline.CSSInliner(base_url="file://styles/email/") inliner.inline("...") ``` -------------------------------- ### Inline CSS into Multiple HTML Documents (PHP) Source: https://github.com/stranger6667/css-inline/blob/master/bindings/php/README.md Illustrates the use of `CssInline\inlineMany` for processing multiple HTML documents concurrently. This function leverages multi-threading at the Rust layer for improved performance on multicore machines. ```php { const optionControls = { inlineStyleTags: document.getElementById("css-inline-opt-inline-style-tags"), keepStyleTags: document.getElementById("css-inline-opt-keep-style-tags"), keepLinkTags: document.getElementById("css-inline-opt-keep-link-tags"), keepAtRules: document.getElementById("css-inline-opt-keep-at-rules"), minifyCss: document.getElementById("css-inline-opt-minify-css"), applyWidthAttributes: document.getElementById("css-inline-opt-apply-width-attributes"), applyHeightAttributes: document.getElementById("css-inline-opt-apply-height-attributes"), extraCss: document.getElementById("css-inline-opt-extra-css") }; const collectOptions = () => { const options = { inlineStyleTags: optionControls.inlineStyleTags ? optionControls.inlineStyleTags.checked : true, keepStyleTags: optionControls.keepStyleTags ? optionControls.keepStyleTags.checked : false, keepLinkTags: optionControls.keepLinkTags ? optionControls.keepLinkTags.checked : false, keepAtRules: optionControls.keepAtRules ? optionControls.keepAtRules.checked : false, minifyCss: optionControls.minifyCss ? optionControls.minifyCss.checked : false, applyWidthAttributes: optionControls.applyWidthAttributes ? optionControls.applyWidthAttributes.checked : false, applyHeightAttributes: optionControls.applyHeightAttributes ? optionControls.applyHeightAttributes.checked : false }; const extraCss = optionControls.extraCss ? optionControls.extraCss.value : ""; if (extraCss && extraCss.trim().length > 0) { options.extraCss = extraCss; } return options; }; cssInline.initWasm(fetch("./index_bg.wasm")).then(() => { const versionElement = document.getElementById("css-inline-package-version"); if (versionElement) { versionElement.textContent = `css-inline-js ${cssInline.version()}`; } const submitButton = document.getElementById("css-inline-submit"); const html = document.getElementById("css-inline-html"); const inlinedCodeElement = document.getElementById("css-inline-result"); const inlinedCodeContainer = document.getElementById("css-inline-result-container"); const inlinedErrorContainer = document.getElementById("css-inline-error-container"); const inlinedErrorText = document.getElementById("css-inline-error-text"); const outputSizeSpan = document.getElementById("css-inline-output-size"); const callTimeSpan = document.getElementById("css-inline-call-time"); submitButton.addEventListener("click", function () { try { const startTime = performance.now(); const options = collectOptions(); const inlinedHtml = cssInline.inline(html.value, options); const durationMs = (performance.now() - startTime).toFixed(2); const blob = new Blob([inlinedHtml], { type: "text/html" }); const sizeInBytes = blob.size; let sizeText; if (sizeInBytes < 1024) { sizeText = `${sizeInBytes} bytes`; } else if (sizeInBytes < 1048576) { sizeText = `${(sizeInBytes / 1024).toFixed(2)} KB`; } else { sizeText = `${(sizeInBytes / 1048576).toFixed(2)} MB`; } outputSizeSpan.textContent = sizeText; callTimeSpan.textContent = `${durationMs} ms`; inlinedCodeElement.textContent = inlinedHtml; inlinedErrorContainer.classList.add("hidden"); inlinedCodeContainer.classList.remove("hidden"); } catch (error) { inlinedCodeContainer.classList.add("hidden"); inlinedErrorContainer.classList.remove("hidden"); inlinedErrorText.textContent = error; } }); }); }); ``` -------------------------------- ### Python API - css_inline.CSSInliner Source: https://context7.com/stranger6667/css-inline/llms.txt Create a reusable inliner with custom configuration options. ```APIDOC ## Python API - `css_inline.CSSInliner` ### Description Create a reusable inliner with custom configuration options. ### Method `CSSInliner` (class constructor) ### Endpoint N/A ### Parameters #### Request Body - **options** (dict, optional) - A dictionary of configuration options. Available options include: - `keep_declarations`: bool (default: `False`) - `inline_pseudo_elements`: bool (default: `False`) - `base_url`: str (default: `None`) - `exclude_selectors`: list of str (default: `[]`) - `cache_size`: int (default: `None`) - `resolver`: callable (default: `None`) ### Request Example ```python import css_inline # Create an inliner with custom options inliner = css_inline.CSSInliner(options={ "keep_declarations": True, "cache_size": 10 }) html = "

Title

" inlined_html = inliner.inline(html) print(inlined_html) ``` ### Response #### Success Response (200) N/A (This is a class for creating an inliner instance) #### Response Example N/A ``` -------------------------------- ### Configure Inlining Behavior with CSSInliner::options() (Rust) Source: https://context7.com/stranger6667/css-inline/llms.txt Creates a configurable inliner using a builder pattern, allowing fine-tuning of CSS inlining behavior. This method supports numerous options such as keeping/removing style and link tags, loading remote stylesheets, minification, and applying email-specific attributes. It returns a `CSSInliner` instance configured with the specified options. ```rust use css_inline::{CSSInliner, Url}; use std::num::NonZeroUsize; const HTML: &str = r#"

Big Text

"#; fn main() -> css_inline::Result<()> { // Configure inliner with multiple options let inliner = CSSInliner::options() .inline_style_tags(true) // Inline CSS from