css-inline
A crate for inlining CSS into HTML documents. When you send HTML emails you need to use "style" attributes instead of "style" tags.
For example, this HTML:
Test
Big Text
Will be turned into this:
Test
Big Text
To use it in your project add the following line to your dependencies
section in project's Cargo.toml
file:
= "0.3"
Usage
use css_inline;
const HTML: &str = r#"<html>
<head>
<title>Test</title>
<style>h1 { color:blue; }</style>
</head>
<body>
<h1>Big Text</h1>
</body>
</html>"#;
Features
css-inline
does minimum work by default:
- No CSS transformation;
- No "style" or "link" tags removal;
It also loads external stylesheets via network or filesystem, but this behavior is configurable.
Configuration
css-inline
can be configured by using InlineOptions
and CSSInliner
:
use css_inline;
remove_style_tags
. Remove "style" tags after inlining.base_url
. Base URL to resolve relative URLsload_remote_stylesheets
. Whether remote stylesheets should be loaded or not
Command Line Interface
css-inline
provides a command-line interface:
|
<PATH>...