diff --git a/Cargo.toml b/Cargo.toml index 557b827..b7be417 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,23 @@ [package] name = "hyperbuild" +description = "One-pass in-place HTML minifier written in Rust with advanced whitespace handling" +license = "MIT" +homepage = "https://github.com/wilsonzlin/hyperbuild" +readme = "README.md" +keywords = ["html", "compress", "minifier", "minify", "minification"] +categories = ["compression", "command-line-utilities", "development-tools::build-utils", "web-programming"] +repository = "https://github.com/wilsonzlin/hyperbuild.git" version = "0.0.1" authors = ["Wilson Lin "] edition = "2018" +[badges] +maintenance = { status = "actively-developed" } + [dependencies] phf = { version = "0.8.0", features = ["macros"] } cascade = "0.1.4" structopt = "0.3.5" + +[profile.release] +panic = 'abort' diff --git a/README.md b/README.md index 6471ae9..31b08cd 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,6 @@ A fast one-pass in-place HTML minifier written in Rust with advanced whitespace handling. -Currently in beta, working on documentation and tests. Issues and pull requests welcome! Guide below is currently WIP. - ## Features - Minification is done in one pass with no backtracking or DOM/AST building. @@ -26,6 +24,82 @@ hyperbuild has advanced whitespace minification that can allow strategies such a - Trim and collapse whitespace in content tags, as whitespace is collapsed anyway when rendered. - Remove whitespace in layout tags, which allows the use of inline layouts while keeping formatted code. +#### Collapsing whitespace + +Reduce a sequence of whitespace characters in text nodes to a single space (U+0020). + +
BeforeAfter
+ +```html +

↵ +··The·quick·brown·fox↵ +··jumps·over·the·lazy↵ +··dog.↵ +

+``` + +
+ +```html +

·The·quick·brown·fox·jumps·over·the·lazy·dog.·

+``` + +
+ +#### Destroying whole whitespace + +Remove any text nodes that only consist of whitespace characters. + +Especially useful when using `display: inline-block` so that whitespace between elements (e.g. indentation) does not alter layout and styling. + +
BeforeAfter
+ +```html +
    ↵ +··
  • A
  • ↵ +··
  • B
  • ↵ +··
  • C
  • ↵ +
+``` + +
+ +```html +
  • A
  • B
  • C
+``` + +
+ +#### Trimming whitespace + +Remove any whitespace from the start and end of a tag, if the first and/or last node is a text node. + +Useful when combined with whitespace collapsing. + +Other whitespace between text nodes and tags are not removed, as it is not recommended to mix non-formatting tags with raw text. + +Basically, a tag should only either contain text and [formatting tags](#formatting-tags), or only non-formatting tags. + +
BeforeAfter
+ +```html +

↵ +··Hey,·I·just·found↵ +··out·about·this·cool·website!↵ +··

↵ +

+``` + +
+ +```html +

Hey,·I·just·found↵ +··out·about·this·cool·website!↵ +··

+``` + +
+ ### Attributes Any entities in attribute values are decoded, and then the most optimal representation is calculated and used: diff --git a/archive/child/blacklist.c b/archive/child/blacklist.c deleted file mode 100644 index 12f570b..0000000 --- a/archive/child/blacklist.c +++ /dev/null @@ -1,92 +0,0 @@ -#include -#include -#include - -static hb_map_tag_relations* hb_rule_tag_child_blacklist_map; - -void hb_rule_tag_child_blacklist_map_add_entries(hb_map_tag_relations* map) -{ - //
- hb_set_tag_names* address = hb_set_tag_names_create(); - hb_rule_tag_heading_add_elems(address); - hb_rule_tag_sectioning_add_elems(address); - hb_set_tag_names_add_whole_literal(address, "address"); - hb_set_tag_names_add_whole_literal(address, "header"); - hb_set_tag_names_add_whole_literal(address, "footer"); - hb_map_tag_relations_set_whole_literal(map, "address", address); - - //