Commit Graph

351 Commits

Author SHA1 Message Date
Wilson Lin e52d85bc28 Reformatting 2021-08-06 21:07:58 +10:00
Wilson Lin 9eb5045f6f Sort attributes for determinism; fix parsing of entities; combine split adjacent text nodes 2021-08-06 21:04:47 +10:00
Wilson Lin 29d1b72230 Test attr minification 2021-08-06 20:36:58 +10:00
Wilson Lin 74b4ab689e Various parsing fixes 2021-08-06 20:16:30 +10:00
Wilson Lin bf37e37e71 Clean up dead code and tests 2021-08-06 17:54:23 +10:00
Wilson Lin 383b2b3423 Implement whitespace minification 2021-08-06 17:33:56 +10:00
Wilson Lin 1a930a170d rustfmt 2021-08-06 16:19:36 +10:00
Wilson Lin 5a259a8ead Implement core minifier 2021-08-06 16:17:45 +10:00
Wilson Lin 0a85ebe34b Decode entities 2021-08-06 13:36:07 +10:00
Wilson Lin 88d288b0cb Implement parser; remove legacy code 2021-08-06 12:07:27 +10:00
Wilson Lin 85b1c6658c Treat <textarea> as whitespace-sensitive 2021-05-23 11:54:30 +10:00
Wilson Lin 080d4e0c96 Relax parsing of unquoted attr values to accept own minified output 2021-04-21 00:55:39 +10:00
Wilson Lin 034932988e Follow spec on decoding entities in attr values 2021-04-16 12:19:47 +10:00
Wilson Lin 98cb36c9c2 Improve closing tag escaping 2021-04-15 01:36:06 +10:00
Wilson Lin feced339ea Escape unintentional script closing tag in JS 2021-04-15 00:18:16 +10:00
Wilson Lin df6426cb25 All gt must be encoded in unquoted attr values 2021-04-13 15:35:39 +10:00
Wilson Lin d8f6bd457a Fix incorrect script end tag detection in JS 2021-04-07 22:08:44 +10:00
Wilson Lin 849a2d9dc1 Update doc 2021-02-07 01:57:09 +11:00
Wilson Lin 261f3f6461 Add test 2021-02-07 01:55:52 +11:00
Wilson Lin 485db71ca6 Use written tag name for comparison 2021-02-07 01:46:46 +11:00
Wilson Lin 0bfb8d86d7 Fix pre propagation 2021-02-06 00:03:14 +11:00
Wilson Lin 55eab19bbe Do not minify any whitespace in any descendants of <pre> 2021-02-05 23:54:29 +11:00
Wilson Lin 83efa7e8a8 Add JS comment test 2021-01-26 21:25:08 +11:00
Wilson Lin e4d8b14d0b CSS minification using esbuild 2021-01-08 00:26:02 +11:00
Wilson Lin 8ff5bc3768 Minor reformatting; minor README wording improvements 2020-09-20 20:50:22 +10:00
Wilson Lin 9968dd4649 Add comment and a few more tests 2020-09-02 17:13:09 +10:00
Wilson Lin 9baa4c1a9e Allow < followed by invalid char to be content 2020-09-02 17:07:02 +10:00
Wilson Lin cf02e8265c Minor refactoring of Rust API `copy` example 2020-08-26 14:42:42 +10:00
Wilson Lin 693c847563 Add documentation comments to Rust API 2020-08-25 00:36:27 +10:00
Wilson Lin a415045ae6 Fix hex numeric entity parsing 2020-08-24 21:48:58 +10:00
Wilson Lin d7ddda3f21 Do not allow unmatched closing tag at root 2020-07-30 20:17:55 +10:00
Wilson Lin d024d21274 Refactoring 2020-07-30 19:51:43 +10:00
Wilson Lin 0eddabcb89 Remove unused function 2020-07-30 14:41:33 +10:00
Wilson Lin ed72690463 Allow omitted tags in source 2020-07-30 14:38:40 +10:00
Wilson Lin d2bffe8005 Allow case insensitive closing tag names for script and style 2020-07-30 12:46:18 +10:00
Wilson Lin abfc4bceaa Make tag and attribute names case insensitive 2020-07-30 12:32:53 +10:00
Wilson Lin 08a2f39108 Fix debug repr line boundaries check; reduce debug repr output by stopping at read position; provide expected and actual tag names for closing tag mismatch error 2020-07-30 00:28:57 +10:00
Wilson Lin 8badd30b40 Minor fix: support numeric entities with more than 256 digits 2020-07-27 18:33:31 +10:00
Wilson Lin 2eb1bea077 Bang -> bang 2020-07-27 18:09:49 +10:00
Wilson Lin e5245acc31 Inline most functions; use aho-corasick for comments and instructions too 2020-07-27 18:08:53 +10:00
Wilson Lin e8726c2ed1 Fix boundary bugs 2020-07-27 17:56:19 +10:00
Wilson Lin 009e91d094 Use aho-corasick for faster and simpler end tag matching 2020-07-27 00:27:52 +10:00
Wilson Lin e76c12a9db Avoid cloning script data before passing to esbuild 2020-07-25 14:18:23 +10:00
Wilson Lin 9627921cb2 Do not minify non-JS script data 2020-07-25 13:22:39 +10:00
Wilson Lin 9f40000527 Omit closing tags for html, head, body 2020-07-24 19:05:29 +10:00
Wilson Lin e1e18bb1a7 Fix race condition from not releasing Mutex guard and Arc ref on async JS min jobs 2020-07-22 21:33:52 +10:00
Wilson Lin cc98a61bc2 Fix </script> end tag escaping in JS 2020-07-22 21:33:09 +10:00
Wilson Lin e9ea7bc378 Separate out and simplify debug repr; reimplement with_friendly_error; fix JS copying 2020-07-22 18:57:47 +10:00
Wilson Lin 1847eca6b6 Fix type errors 2020-07-22 17:45:47 +10:00
Wilson Lin 1826e980f7 Fix JS finishing; temporarily remove friendly function 2020-07-21 23:27:56 +10:00
Wilson Lin 6f3e1254de Conditionally compile JS feature code 2020-07-21 17:59:56 +10:00
Wilson Lin b967e338ca Use named error struct instead of tuple; use async JS minification; fix old JS package names 2020-07-21 17:57:39 +10:00
Wilson Lin c71a9169a7 Add str helper function 2020-07-12 16:05:49 +10:00
Wilson Lin dc376d7c7f Rename to minify-html 2020-07-12 01:29:34 +10:00
Wilson Lin a15c0e76f9 Remove dependence on regex 2020-07-11 22:52:27 +10:00
Wilson Lin 56edbac338 Make JS library optional 2020-07-11 22:20:17 +10:00
Wilson Lin ced0e82515 Add support for configuration and JS minification using esbuild 2020-07-11 01:15:56 +10:00
Wilson Lin 0787bb83f1 Clean up dead code 2020-07-10 21:07:30 +10:00
Wilson Lin 9ffb7b1d98 Add unit tests and fix various bugs 2020-07-10 20:40:33 +10:00
Wilson Lin 26b6c47d06 Use lookup tables for code points 2020-07-09 17:06:08 +10:00
Wilson Lin 2ffb626573 Fix entity normalisation 2020-07-07 21:09:04 +10:00
Wilson Lin 3ca6ae3d8e Improve performance of char specs 2020-07-07 21:08:39 +10:00
Wilson Lin bcbb048762 Fix not writing closing tag on encoded '<' in content 2020-07-07 21:08:15 +10:00
Wilson Lin a35641445d Use much simpler read-time entity decoding; fix longest prefix matching; fix transparent nodes not being interpreted as such 2020-07-04 20:33:02 +10:00
Wilson Lin 38084e2894 Fix missing space at end of self-closing SVG tags when last attribute is unquoted 2020-07-04 15:58:35 +10:00
Wilson Lin 1ee193de1b Fix tricky subtle bugs in trie matching 2020-07-03 22:32:16 +10:00
Wilson Lin a519394c3a Use regex crate for substring searches 2020-07-03 20:37:52 +10:00
Wilson Lin 2a010088fa Use lazy_static instead of phf due to phf incompatibility with latest Rust versions 2020-07-03 17:32:09 +10:00
Wilson Lin 9605c34e66 Compact tries even more 2020-06-19 18:12:55 +10:00
Wilson Lin cefdc8fdd9 Wire up new generated code 2020-06-19 17:58:16 +10:00
Wilson Lin 7a52bd7add Extract CLI to own package 2020-06-19 09:54:56 +10:00
Wilson Lin 360bfbba8d Fix typos 2020-05-12 17:26:13 +10:00
Wilson Lin 26157908a6 Add friendlier Rust functions; improve examples 2020-05-12 17:12:29 +10:00
Wilson Lin ab28f51b3c Fix incorrect encoding of `>` instead of `<` 2020-03-01 14:04:20 +11:00
Wilson Lin aaf57a9c22 Improve performance through inlining and direct arrays 2020-01-31 23:15:35 +11:00
Wilson Lin 2ebfb9d017 Remove comments 2020-01-26 23:26:47 +13:00
Wilson Lin 3aa752e46b Restructure enums and matching for performance 2020-01-26 22:32:06 +13:00
Wilson Lin 212e4257d1 Fix bugs relating to entities decoding and encoding 2020-01-26 18:38:23 +13:00
Wilson Lin ead4917fb7 Minor cleanup of Processor 2020-01-26 13:49:43 +13:00
Wilson Lin ee2d9e22cf Reformatting 2020-01-26 13:35:57 +13:00
Wilson Lin 90148f5f9b Support stdin/out for CLI; use friendlier CLI error messages; clarify replacement character usage 2020-01-26 13:30:41 +13:00
Wilson Lin 71a3e3927b Create through matching condition; show code context on error when using CLI 2020-01-26 03:25:07 +13:00
Wilson Lin 0a094dfed0 Implement more effective `>` encoding; restructure internal APIs 2020-01-26 01:05:07 +13:00
Wilson Lin 24c1639a82 Remove unused errors; order imports 2020-01-25 20:07:52 +13:00
Wilson Lin 8988ff1e3a Create simplified unified matching API 2020-01-25 20:04:02 +13:00
Wilson 6ec509945a Minify area[shape] attr; simplify NS code 2020-01-24 15:17:46 +13:00
Wilson 54b65bbd0c Minify SVG attributes; minor QoL improvements 2020-01-24 03:53:09 +13:00
Wilson Lin 6b2b8cf552 Handle comments correctly 2020-01-19 11:44:11 +11:00
Wilson Lin 9f93a5d6de Fix content whitespace trimming 2020-01-19 11:32:38 +11:00
Wilson Lin 3c4b71612e Fix text minification 2020-01-18 22:39:33 +11:00
Wilson Lin b88e96e97e Significantly clarify code; handle whitespace minification and tag omission at root 2020-01-18 22:19:06 +11:00
Wilson Lin b4f8a041b2 Mention attr with default value removal in README; add <style> default attr values 2020-01-18 11:47:38 +11:00
Wilson Lin 27af2368ff Remove attrs with default values; create minified comparison script; remove `=` from boolean attrs; fix closing tag writing before collapsed whitespace; rebuild hyperbuild only in bench build script instead of all dependencies; conservatively collapse whitespace for html-minifier to match hyperbuild behaviour; update bench results 2020-01-18 11:42:01 +11:00
Wilson Lin ba5fbc68f7 Simplify and improve performance of whitespace minification strategy config 2020-01-17 19:27:34 +11:00
Wilson Lin 3a9877534f Minor code reformatting 2020-01-17 00:07:04 +11:00
Wilson Lin 5b78526230 Handle edge case in attribute value minification 2020-01-17 00:05:48 +11:00
Wilson Lin 4eeb70639a Rename classname attr; update bench results; mention decoding to U+FFFD 2020-01-15 22:57:47 +11:00
Wilson Lin f8b0bbe3e0 Fix various parsing bugs 2020-01-15 22:09:16 +11:00
Wilson Lin 7dcd7442e8 Remove redundant attributes with empty values 2020-01-15 00:58:33 +11:00
Wilson Lin 37115fef7a Allow more whitespace w.r.t. attributes; do not format bench test pages 2020-01-14 21:10:49 +11:00