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;
|
2020-07-10 11:15:56 -04:00
|
|
|
mod cfg;
|
2020-06-19 03:58:16 -04:00
|
|
|
mod gen;
|
2021-08-05 22:07:27 -04:00
|
|
|
mod parse;
|
2019-12-29 19:52:45 -05:00
|
|
|
mod pattern;
|
2019-12-23 06:48:41 -05:00
|
|
|
mod spec;
|
2020-07-10 06:40:33 -04:00
|
|
|
mod tests;
|
2020-05-12 03:12:29 -04:00
|
|
|
|
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
|
|
|
///
|
2020-08-26 00:42:42 -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()
|
2020-07-22 04:57:47 -04:00
|
|
|
}
|