minify-html/src/lib.rs

38 lines
830 B
Rust
Raw Normal View History

2021-08-05 22:07:27 -04:00
use crate::cfg::Cfg;
use crate::parse::Code;
2019-12-25 04:44:51 -05:00
2021-08-05 22:07:27 -04:00
mod ast;
mod cfg;
2020-06-19 03:58:16 -04:00
mod gen;
2021-08-05 22:07:27 -04:00
mod parse;
mod pattern;
mod spec;
2020-07-10 06:40:33 -04:00
mod tests;
2020-08-24 10:36:27 -04:00
/// Copies a slice into a new Vec and minifies it, returning the Vec.
/// The resulting Vec will only contain minified code.
///
/// # Arguments
///
/// * `code` - A slice of bytes representing the source code to minify.
/// * `cfg` - Configuration object to adjust minification approach.
///
/// # Examples
///
/// ```
2021-08-05 22:07:27 -04:00
/// use minify_html::{Cfg, minify};
2020-08-24 10:36:27 -04:00
///
/// let mut code: &[u8] = b"<p> Hello, world! </p>";
2020-08-24 10:36:27 -04:00
/// let cfg = &Cfg {
/// minify_js: false,
2021-01-07 08:26:02 -05:00
/// minify_css: false,
2020-08-24 10:36:27 -04:00
/// };
2021-08-05 22:07:27 -04:00
/// let minified = minify(&code, cfg);
/// assert_eq!(minified, b"<p>Hello, world!".to_vec());
2020-08-24 10:36:27 -04:00
/// ```
2021-08-05 22:07:27 -04:00
pub fn minify(code: &[u8], cfg: &Cfg) -> Vec<u8> {
let code = Code::new(code);
// TODO
Vec::new()
}