diff options
Diffstat (limited to 'vendor/github.com/tdewolff/minify')
| -rw-r--r-- | vendor/github.com/tdewolff/minify/v2/.gitattributes | 2 | ||||
| -rw-r--r-- | vendor/github.com/tdewolff/minify/v2/.gitignore | 32 | ||||
| -rw-r--r-- | vendor/github.com/tdewolff/minify/v2/.golangci.yml | 16 | ||||
| -rw-r--r-- | vendor/github.com/tdewolff/minify/v2/Dockerfile | 17 | ||||
| -rw-r--r-- | vendor/github.com/tdewolff/minify/v2/LICENSE | 22 | ||||
| -rw-r--r-- | vendor/github.com/tdewolff/minify/v2/Makefile | 58 | ||||
| -rw-r--r-- | vendor/github.com/tdewolff/minify/v2/README.md | 737 | ||||
| -rw-r--r-- | vendor/github.com/tdewolff/minify/v2/common.go | 524 | ||||
| -rw-r--r-- | vendor/github.com/tdewolff/minify/v2/html/buffer.go | 139 | ||||
| -rw-r--r-- | vendor/github.com/tdewolff/minify/v2/html/hash.go | 610 | ||||
| -rw-r--r-- | vendor/github.com/tdewolff/minify/v2/html/html.go | 534 | ||||
| -rw-r--r-- | vendor/github.com/tdewolff/minify/v2/html/table.go | 1389 | ||||
| -rw-r--r-- | vendor/github.com/tdewolff/minify/v2/minify.go | 375 | 
13 files changed, 0 insertions, 4455 deletions
diff --git a/vendor/github.com/tdewolff/minify/v2/.gitattributes b/vendor/github.com/tdewolff/minify/v2/.gitattributes deleted file mode 100644 index 16a3a8b06..000000000 --- a/vendor/github.com/tdewolff/minify/v2/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -benchmarks/sample_* linguist-generated -tests/*/corpus/* linguist-generated diff --git a/vendor/github.com/tdewolff/minify/v2/.gitignore b/vendor/github.com/tdewolff/minify/v2/.gitignore deleted file mode 100644 index 1771a0e2f..000000000 --- a/vendor/github.com/tdewolff/minify/v2/.gitignore +++ /dev/null @@ -1,32 +0,0 @@ -release.sh -dist -_benchmarks/* -!_benchmarks/*.go -!_benchmarks/sample_* -tests/*/fuzz-fuzz.zip -tests/*/crashers -tests/*/suppressions -tests/*/corpus/* -!tests/*/corpus/*.* -parse/tests/*/fuzz-fuzz.zip -parse/tests/*/crashers -parse/tests/*/suppressions -parse/tests/*/corpus/* -!parse/tests/*/corpus/*.* -bindings/js/build -bindings/js/prebuilds -bindings/js/minify.h -bindings/js/minify.a -bindings/js/node_modules -bindings/js/example/package-lock.json -bindings/js/example/node_modules -bindings/js/example/test.min.html -bindings/py/go.mod -bindings/py/go.sum -bindings/py/**/*.h -bindings/py/**/*.so -bindings/py/**/*.egg-info -bindings/py/example/example.min.html -bindings/py/dist -bindings/py/build -bindings/py/**/*.pyc diff --git a/vendor/github.com/tdewolff/minify/v2/.golangci.yml b/vendor/github.com/tdewolff/minify/v2/.golangci.yml deleted file mode 100644 index 7009f9201..000000000 --- a/vendor/github.com/tdewolff/minify/v2/.golangci.yml +++ /dev/null @@ -1,16 +0,0 @@ -linters: -  enable: -  - depguard -  - dogsled -  - gofmt -  - goimports -  - golint -  - gosec -  - govet -  - megacheck -  - misspell -  - nakedret -  - prealloc -  - unconvert -  - unparam -  - wastedassign diff --git a/vendor/github.com/tdewolff/minify/v2/Dockerfile b/vendor/github.com/tdewolff/minify/v2/Dockerfile deleted file mode 100644 index 0f7fde443..000000000 --- a/vendor/github.com/tdewolff/minify/v2/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -# Use this image to build the executable -FROM golang:1.18-alpine AS build - -WORKDIR /go/src/github.com/tdewolff/minify -COPY . /go/src/github.com/tdewolff/minify/ - -RUN apk add --no-cache git ca-certificates make bash -RUN /usr/bin/env bash -c make install - - -# Final image containing the executable from the previous step -FROM alpine:3 - -COPY --from=build /go/bin/minify /usr/bin/minify -COPY "containerfiles/container-entrypoint.sh" "/init.sh" - -ENTRYPOINT ["/init.sh"] diff --git a/vendor/github.com/tdewolff/minify/v2/LICENSE b/vendor/github.com/tdewolff/minify/v2/LICENSE deleted file mode 100644 index ffd6ad3e7..000000000 --- a/vendor/github.com/tdewolff/minify/v2/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2025 Taco de Wolff - - Permission is hereby granted, free of charge, to any person - obtaining a copy of this software and associated documentation - files (the "Software"), to deal in the Software without - restriction, including without limitation the rights to use, - copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the - Software is furnished to do so, subject to the following - conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file diff --git a/vendor/github.com/tdewolff/minify/v2/Makefile b/vendor/github.com/tdewolff/minify/v2/Makefile deleted file mode 100644 index 9eede2839..000000000 --- a/vendor/github.com/tdewolff/minify/v2/Makefile +++ /dev/null @@ -1,58 +0,0 @@ -SHELL=/usr/bin/env bash -NAME=minify -CMD=./cmd/minify -TARGETS=linux_amd64 linux_arm64 darwin_amd64 darwin_arm64 freebsd_amd64 netbsd_amd64 openbsd_amd64 windows_amd64 -VERSION=`git describe --tags` -FLAGS=-ldflags "-s -w -X 'main.Version=${VERSION}'" -trimpath -ENVS=GO111MODULES=on CGO_ENABLED=0 - -all: install - -install: -	echo "Installing ${VERSION}" -	${ENVS} go install ${FLAGS} ./cmd/minify -	. cmd/minify/bash_completion - -release: -	TAG=$(shell git describe --tags --exact-match 2> /dev/null); -	if [ "${.SHELLSTATUS}" -eq 0 ]; then \ -		echo "Releasing ${VERSION}"; \ -	else \ -		echo "ERROR: commit is not tagged with a version"; \ -		echo ""; \ -		exit 1; \ -	fi -	rm -rf dist -	mkdir -p dist -	for t in ${TARGETS}; do \ -		echo Building $$t...; \ -		mkdir dist/$$t; \ -		os=$$(echo $$t | cut -f1 -d_); \ -		arch=$$(echo $$t | cut -f2 -d_); \ -		${ENVS} GOOS=$$os GOARCH=$$arch go build ${FLAGS} -o dist/$$t/${NAME} ${CMD}; \ -		\ -		cp LICENSE dist/$$t/.; \ -		cp cmd/minify/README.md dist/$$t/.; \ -		if [ "$$os" == "windows" ]; then \ -			mv dist/$$t/${NAME} dist/$$t/${NAME}.exe; \ -			zip -jq dist/${NAME}_$$t.zip dist/$$t/*; \ -			cd dist; \ -			sha256sum ${NAME}_$$t.zip >> checksums.txt; \ -			cd ..; \ -		else \ -			cp cmd/minify/bash_completion dist/$$t/.; \ -			cd dist/$$t; \ -			tar -cf - * | gzip -9 > ../${NAME}_$$t.tar.gz; \ -			cd ..; \ -			sha256sum ${NAME}_$$t.tar.gz >> checksums.txt; \ -			cd ..; \ -		fi; \ -		rm -rf dist/$$t; \ -	done - -clean: -	echo "Cleaning dist/" -	rm -rf dist - -.PHONY: install release clean -.SILENT: install release clean diff --git a/vendor/github.com/tdewolff/minify/v2/README.md b/vendor/github.com/tdewolff/minify/v2/README.md deleted file mode 100644 index 34ae642ea..000000000 --- a/vendor/github.com/tdewolff/minify/v2/README.md +++ /dev/null @@ -1,737 +0,0 @@ -# Minify <a name="minify"></a> [](https://pkg.go.dev/github.com/tdewolff/minify/v2?tab=doc) [](https://goreportcard.com/report/github.com/tdewolff/minify) [](https://codecov.io/gh/tdewolff/minify) - -**[Online demo](https://go.tacodewolff.nl/minify)** if you need to minify files *now*. - -**[Binaries](https://github.com/tdewolff/minify/releases) of CLI for various platforms.** See [CLI](https://github.com/tdewolff/minify/tree/master/cmd/minify) for more installation instructions. - -**[Windows binary from scoop](https://scoop.sh/#/apps?q=minify)** install with `scoop install main/minify` - -**[Python bindings](https://pypi.org/project/tdewolff-minify/)** install with `pip install tdewolff-minify` - -**[JavaScript bindings](https://www.npmjs.com/package/@tdewolff/minify)** install with `npm i @tdewolff/minify` - -**[.NET bindings](https://github.com/JKamsker/NMinify)** install with `Install-Package NMinify` or `dotnet add package NMinify`, thanks to Jonas Kamsker for the port - ---- - -*Did you know that the shortest valid piece of HTML5 is `<!doctype html><title>x</title>`? See for yourself at the [W3C Validator](http://validator.w3.org/)!* - -Minify is a minifier package written in [Go][1]. It provides HTML5, CSS3, JS, JSON, SVG and XML minifiers and an interface to implement any other minifier. Minification is the process of removing bytes from a file (such as whitespace) without changing its output and therefore shrinking its size and speeding up transmission over the internet and possibly parsing. The implemented minifiers are designed for high performance (see https://github.com/privatenumber/minification-benchmarks where this library is (one of) the fastest JS minifiers). - -The core functionality associates mimetypes with minification functions, allowing embedded resources (like CSS or JS within HTML files) to be minified as well. Users can add new implementations that are triggered based on a mimetype (or pattern), or redirect to an external command (like ClosureCompiler, UglifyCSS, ...). - -### Sponsors -I'm actively looking for support in the form of donations or sponsorships to keep developing this library and highly appreciate any gesture. Please see the Sponsors button in GitHub for ways to contribute, or contact me directly. - -[](https://www.siteground.com/) - -#### Table of Contents - -- [Minify](#minify) -	- [Prologue](#prologue) -	- [Installation](#installation) -	- [API stability](#api-stability) -	- [Testing](#testing) -	- [Performance](#performance) -	- [HTML](#html) -		- [Whitespace removal](#whitespace-removal) -	- [CSS](#css) -	- [JS](#js) -		- [Comparison with other tools](#comparison-with-other-tools) -            - [Compression ratio (lower is better)](#compression-ratio-lower-is-better) -            - [Time (lower is better)](#time-lower-is-better) -	- [JSON](#json) -	- [SVG](#svg) -	- [XML](#xml) -	- [Usage](#usage) -		- [New](#new) -		- [From reader](#from-reader) -		- [From bytes](#from-bytes) -		- [From string](#from-string) -		- [To reader](#to-reader) -		- [To writer](#to-writer) -		- [Middleware](#middleware) -		- [Custom minifier](#custom-minifier) -		- [Mediatypes](#mediatypes) -	- [Examples](#examples) -		- [Common minifiers](#common-minifiers) -		- [External minifiers](#external-minifiers) -            - [Closure Compiler](#closure-compiler) -            - [UglifyJS](#uglifyjs) -            - [esbuild](#esbuild) -		- [Custom minifier](#custom-minifier-example) -		- [ResponseWriter](#responsewriter) -		- [Templates](#templates) -    - [FAQ](#faq) -	- [License](#license) - -### Roadmap - -- [ ] Use ASM/SSE to further speed-up core parts of the parsers/minifiers -- [x] Improve JS minifiers by shortening variables and proper semicolon omission -- [ ] Speed-up SVG minifier, it is very slow -- [x] Proper parser error reporting and line number + column information -- [ ] Generation of source maps (uncertain, might slow down parsers too much if it cannot run separately nicely) -- [ ] Create a cmd to pack webfiles (much like webpack), ie. merging CSS and JS files, inlining small external files, minification and gzipping. This would work on HTML files. - -## Prologue -Minifiers or bindings to minifiers exist in almost all programming languages. Some implementations are merely using several regular expressions to trim whitespace and comments (even though regex for parsing HTML/XML is ill-advised, for a good read see [Regular Expressions: Now You Have Two Problems](http://blog.codinghorror.com/regular-expressions-now-you-have-two-problems/)). Some implementations are much more profound, such as the [YUI Compressor](http://yui.github.io/yuicompressor/) and [Google Closure Compiler](https://github.com/google/closure-compiler) for JS. As most existing implementations either use JavaScript, use regexes, and don't focus on performance, they are pretty slow. - -This minifier proves to be that fast and extensive minifier that can handle HTML and any other filetype it may contain (CSS, JS, ...). It is usually orders of magnitude faster than existing minifiers. - -## Installation -Make sure you have [Git](https://git-scm.com/) and [Go](https://golang.org/dl/) (1.18 or higher) installed, run -``` -mkdir Project -cd Project -go mod init -go get -u github.com/tdewolff/minify/v2 -``` - -Then add the following imports to be able to use the various minifiers -``` go -import ( -	"github.com/tdewolff/minify/v2" -	"github.com/tdewolff/minify/v2/css" -	"github.com/tdewolff/minify/v2/html" -	"github.com/tdewolff/minify/v2/js" -	"github.com/tdewolff/minify/v2/json" -	"github.com/tdewolff/minify/v2/svg" -	"github.com/tdewolff/minify/v2/xml" -) -``` - -You can optionally run `go mod tidy` to clean up the `go.mod` and `go.sum` files. - -See [CLI tool](https://github.com/tdewolff/minify/tree/master/cmd/minify) for installation instructions of the binary. - -### Docker - -If you want to use Docker, please see https://hub.docker.com/r/tdewolff/minify. - -```bash -$ docker run -it tdewolff/minify --help -``` - -## API stability -There is no guarantee for absolute stability, but I take issues and bugs seriously and don't take API changes lightly. The library will be maintained in a compatible way unless vital bugs prevent me from doing so. There has been one API change after v1 which added options support and I took the opportunity to push through some more API clean up as well. There are no plans whatsoever for future API changes. - -## Testing -For all subpackages and the imported `parse` package, test coverage of 100% is pursued. Besides full coverage, the minifiers are [fuzz tested](https://github.com/tdewolff/fuzz) using [github.com/dvyukov/go-fuzz](http://www.github.com/dvyukov/go-fuzz), see [the wiki](https://github.com/tdewolff/minify/wiki) for the most important bugs found by fuzz testing. These tests ensure that everything works as intended and that the code does not crash (whatever the input). If you still encounter a bug, please file a [bug report](https://github.com/tdewolff/minify/issues)! - -## Performance -The benchmarks directory contains a number of standardized samples used to compare performance between changes. To give an indication of the speed of this library, I've ran the tests on my Thinkpad T460 (i5-6300U quad-core 2.4GHz running Arch Linux) using Go 1.15. - -``` -name                              time/op -CSS/sample_bootstrap.css-4          2.70ms ± 0% -CSS/sample_gumby.css-4              3.57ms ± 0% -CSS/sample_fontawesome.css-4         767µs ± 0% -CSS/sample_normalize.css-4          85.5µs ± 0% -HTML/sample_amazon.html-4           15.2ms ± 0% -HTML/sample_bbc.html-4              3.90ms ± 0% -HTML/sample_blogpost.html-4          420µs ± 0% -HTML/sample_es6.html-4              15.6ms ± 0% -HTML/sample_stackoverflow.html-4    3.73ms ± 0% -HTML/sample_wikipedia.html-4        6.60ms ± 0% -JS/sample_ace.js-4                  28.7ms ± 0% -JS/sample_dot.js-4                   357µs ± 0% -JS/sample_jquery.js-4               10.0ms ± 0% -JS/sample_jqueryui.js-4             20.4ms ± 0% -JS/sample_moment.js-4               3.47ms ± 0% -JSON/sample_large.json-4            3.25ms ± 0% -JSON/sample_testsuite.json-4        1.74ms ± 0% -JSON/sample_twitter.json-4          24.2µs ± 0% -SVG/sample_arctic.svg-4             34.7ms ± 0% -SVG/sample_gopher.svg-4              307µs ± 0% -SVG/sample_usa.svg-4                57.4ms ± 0% -SVG/sample_car.svg-4                18.0ms ± 0% -SVG/sample_tiger.svg-4              5.61ms ± 0% -XML/sample_books.xml-4              54.7µs ± 0% -XML/sample_catalog.xml-4            33.0µs ± 0% -XML/sample_omg.xml-4                7.17ms ± 0% - -name                              speed -CSS/sample_bootstrap.css-4        50.7MB/s ± 0% -CSS/sample_gumby.css-4            52.1MB/s ± 0% -CSS/sample_fontawesome.css-4      61.2MB/s ± 0% -CSS/sample_normalize.css-4        70.8MB/s ± 0% -HTML/sample_amazon.html-4         31.1MB/s ± 0% -HTML/sample_bbc.html-4            29.5MB/s ± 0% -HTML/sample_blogpost.html-4       49.8MB/s ± 0% -HTML/sample_es6.html-4            65.6MB/s ± 0% -HTML/sample_stackoverflow.html-4  55.0MB/s ± 0% -HTML/sample_wikipedia.html-4      67.5MB/s ± 0% -JS/sample_ace.js-4                22.4MB/s ± 0% -JS/sample_dot.js-4                14.5MB/s ± 0% -JS/sample_jquery.js-4             24.8MB/s ± 0% -JS/sample_jqueryui.js-4           23.0MB/s ± 0% -JS/sample_moment.js-4             28.6MB/s ± 0% -JSON/sample_large.json-4           234MB/s ± 0% -JSON/sample_testsuite.json-4       394MB/s ± 0% -JSON/sample_twitter.json-4        63.0MB/s ± 0% -SVG/sample_arctic.svg-4           42.4MB/s ± 0% -SVG/sample_gopher.svg-4           19.0MB/s ± 0% -SVG/sample_usa.svg-4              17.8MB/s ± 0% -SVG/sample_car.svg-4              29.3MB/s ± 0% -SVG/sample_tiger.svg-4            12.2MB/s ± 0% -XML/sample_books.xml-4            81.0MB/s ± 0% -XML/sample_catalog.xml-4          58.6MB/s ± 0% -XML/sample_omg.xml-4               159MB/s ± 0% -``` - -## HTML - -HTML (with JS and CSS) minification typically shaves off about 10%. - -The HTML5 minifier uses these minifications: - -- strip unnecessary whitespace and otherwise collapse it to one space (or newline if it originally contained a newline) -- strip superfluous quotes, or uses single/double quotes whichever requires fewer escapes -- strip default attribute values and attribute boolean values -- strip some empty attributes -- strip unrequired tags (`html`, `head`, `body`, ...) -- strip unrequired end tags (`tr`, `td`, `li`, ... and often `p`) -- strip default protocols (`http:`, `https:` and `javascript:`) -- strip all comments (including conditional comments, old IE versions are not supported anymore by Microsoft) -- shorten `doctype` and `meta` charset -- lowercase tags, attributes and some values to enhance gzip compression - -Options: - -- `KeepSpecialComments` preserve all special comments, including Server Side Includes such as `<!--#include file="header.html" -->` and IE conditional comments such as `<!--[if IE 6]><![endif]-->` and `<![if IE 6]><![endif]>`, see https://msdn.microsoft.com/en-us/library/ms537512(v=vs.85).aspx#syntax -- `KeepDefaultAttrVals` preserve default attribute values such as `<script type="application/javascript">` -- `KeepDocumentTags` preserve `html`, `head` and `body` tags -- `KeepEndTags` preserve all end tags -- `KeepQuotes` preserve quotes around attribute values -- `KeepWhitespace` preserve whitespace between inline tags but still collapse multiple whitespace characters into one -- `TemplateDelims` preserve context within and surrounding the given opening and closing delimiters - -After recent benchmarking and profiling it became really fast and minifies pages in the 10ms range, making it viable for on-the-fly minification. - -However, be careful when doing on-the-fly minification. Minification typically trims off 10% and does this at worst around about 20MB/s. This means users have to download slower than 2MB/s to make on-the-fly minification worthwhile. This may or may not apply in your situation. Rather use caching! - -### Whitespace removal -The whitespace removal mechanism collapses all sequences of whitespace (spaces, newlines, tabs) to a single space. If the sequence contained a newline or carriage return it will collapse into a newline character instead. It trims all text parts (in between tags) depending on whether it was preceded by a space from a previous piece of text and whether it is followed up by a block element or an inline element. In the former case we can omit spaces while for inline elements whitespace has significance. - -Make sure your HTML doesn't depend on whitespace between `block` elements that have been changed to `inline` or `inline-block` elements using CSS. Your layout *should not* depend on those whitespaces as the minifier will remove them. An example is a menu consisting of multiple `<li>` that have `display:inline-block` applied and have whitespace in between them. It is bad practise to rely on whitespace for element positioning anyways! - -## CSS - -Minification typically shaves off about 10%-15%. This CSS minifier will _not_ do structural changes to your stylesheets. Although this could result in smaller files, the complexity is quite high and the risk of breaking website is high too. - -The CSS minifier will only use safe minifications: - -- remove comments and unnecessary whitespace (but keep `/*! ... */` which usually contains the license) -- remove trailing semicolons -- optimize `margin`, `padding` and `border-width` number of sides -- shorten numbers by removing unnecessary `+` and zeros and rewriting with/without exponent -- remove dimension and percentage for zero values -- remove quotes for URLs -- remove quotes for font families and make lowercase -- rewrite hex colors to/from color names, or to three digit hex -- rewrite `rgb(`, `rgba(`, `hsl(` and `hsla(` colors to hex or name -- use four digit hex for alpha values (`transparent` → `#0000`) -- replace `normal` and `bold` by numbers for `font-weight` and `font` -- replace `none` → `0` for `border`, `background` and `outline` -- lowercase all identifiers except classes, IDs and URLs to enhance gzip compression -- shorten MS alpha function -- rewrite data URIs with base64 or ASCII whichever is shorter -- calls minifier for data URI mediatypes, thus you can compress embedded SVG files if you have that minifier attached -- shorten aggregate declarations such as `background` and `font` - -It does purposely not use the following techniques: - -- (partially) merge rulesets -- (partially) split rulesets -- collapse multiple declarations when main declaration is defined within a ruleset (don't put `font-weight` within an already existing `font`, too complex) -- remove overwritten properties in ruleset (this not always overwrites it, for example with `!important`) -- rewrite properties into one ruleset if possible (like `margin-top`, `margin-right`, `margin-bottom` and `margin-left` → `margin`) -- put nested ID selector at the front (`body > div#elem p` → `#elem p`) -- rewrite attribute selectors for IDs and classes (`div[id=a]` → `div#a`) -- put space after pseudo-selectors (IE6 is old, move on!) - -There are a couple of comparison tables online, such as [CSS Minifier Comparison](http://www.codenothing.com/benchmarks/css-compressor-3.0/full.html), [CSS minifiers comparison](http://www.phpied.com/css-minifiers-comparison/) and [CleanCSS tests](http://goalsmashers.github.io/css-minification-benchmark/). Comparing speed between each, this minifier will usually be between 10x-300x faster than existing implementations, and even rank among the top for minification ratios. It falls short with the purposely not implemented and often unsafe techniques. - -Options: - -- `KeepCSS2` prohibits using CSS3 syntax (such as exponents in numbers, or `rgba(` → `rgb(`), might be incomplete -- `Precision` number of significant digits to preserve for numbers, `0` means no trimming - -## JS - -The JS minifier typically shaves off about 35% -- 65% of filesize depending on the file, which is a compression close to many other minifiers. Common speeds of PHP and JS implementations are about 100-300kB/s (see [Uglify2](http://lisperator.net/uglifyjs/), [Adventures in PHP web asset minimization](https://www.happyassassin.net/2014/12/29/adventures-in-php-web-asset-minimization/)). This implementation is orders of magnitude faster at around ~25MB/s. - -The following features are implemented: - -- remove superfluous whitespace -- remove superfluous semicolons -- shorten `true`, `false`, and `undefined` to `!0`, `!1` and `void 0` -- rename variables and functions to shorter names (not in global scope) -- move `var` declarations to the top of the global/function scope (if more than one) -- collapse if/else statements to expressions -- minify conditional expressions to simpler ones -- merge sequential expression statements to one, including into `return` and `throw` -- remove superfluous grouping in expressions -- shorten or remove string escapes -- convert object key or index expression from string to identifier or decimal -- merge concatenated strings -- rewrite numbers (binary, octal, decimal, hexadecimal) to shorter representations - -Options: - -- `KeepVarNames` keeps variable names as they are and omits shortening variable names -- `Precision` number of significant digits to preserve for numbers, `0` means no trimming -- `Version` ECMAScript version to use for output, `0` is the latest - -### Comparison with other tools - -Performance is measured with `time [command]` ran 10 times and selecting the fastest one, on a Thinkpad T460 (i5-6300U quad-core 2.4GHz running Arch Linux) using Go 1.15. - -- [minify](https://github.com/tdewolff/minify): `minify -o script.min.js script.js` -- [esbuild](https://github.com/evanw/esbuild): `esbuild --minify --outfile=script.min.js script.js` -- [terser](https://github.com/terser/terser): `terser script.js --compress --mangle -o script.min.js` -- [UglifyJS](https://github.com/Skalman/UglifyJS-online): `uglifyjs --compress --mangle -o script.min.js script.js` -- [Closure Compiler](https://github.com/google/closure-compiler): `closure-compiler -O SIMPLE --js script.js --js_output_file script.min.js --language_in ECMASCRIPT_NEXT -W QUIET --jscomp_off=checkVars` optimization level `SIMPLE` instead of `ADVANCED` to make similar assumptions as do the other tools (do not rename/assume anything of global level variables) - -#### Compression ratio (lower is better) -All tools give very similar results, although UglifyJS compresses slightly better. - -| Tool | ace.js | dot.js | jquery.js | jqueryui.js | moment.js | -| --- | --- | --- | --- | --- | --- | -| **minify** | 53.7% | 64.8% | 34.2% | 51.3% | 34.8% | -| esbuild | 53.8% | 66.3% | 34.4% | 53.1% | 34.8% | -| terser | 53.2% | 65.2% | 34.2% | 51.8% | 34.7% | -| UglifyJS | 53.1% | 64.7% | 33.8% | 50.7% | 34.2% | -| Closure Compiler | 53.4% | 64.0% | 35.7% | 53.6% | 34.3% | - -#### Time (lower is better) -Most tools are extremely slow, with `minify` and `esbuild` being orders of magnitudes faster. - -| Tool | ace.js | dot.js | jquery.js | jqueryui.js | moment.js | -| --- | --- | --- | --- | --- | --- | -| **minify** | 49ms | 5ms | 22ms | 35ms | 13ms | -| esbuild | 64ms | 9ms | 31ms | 51ms | 17ms | -| terser | 2900s | 180ms | 1400ms | 2200ms | 730ms | -| UglifyJS | 3900ms | 210ms | 2000ms | 3100ms | 910ms | -| Closure Compiler | 6100ms | 2500ms | 4400ms | 5300ms | 3500ms | - -## JSON - -Minification typically shaves off about 15% of filesize for common indented JSON such as generated by [JSON Generator](http://www.json-generator.com/). - -The JSON minifier only removes whitespace, which is the only thing that can be left out, and minifies numbers (`1000` => `1e3`). - -Options: - -- `Precision` number of significant digits to preserve for numbers, `0` means no trimming -- `KeepNumbers` do not minify numbers if set to `true`, by default numbers will be minified - -## SVG - -The SVG minifier uses these minifications: - -- trim and collapse whitespace between all tags -- strip comments, empty `doctype`, XML prelude, `metadata` -- strip SVG version -- strip CDATA sections wherever possible -- collapse tags with no content to a void tag -- minify style tag and attributes with the CSS minifier -- minify colors -- shorten lengths and numbers and remove default `px` unit -- shorten `path` data -- use relative or absolute positions in path data whichever is shorter - -TODO: -- convert attributes to style attribute whenever shorter -- merge path data? (same style and no intersection -- the latter is difficult) - -Options: - -- `Precision` number of significant digits to preserve for numbers, `0` means no trimming - -## XML - -The XML minifier uses these minifications: - -- strip unnecessary whitespace and otherwise collapse it to one space (or newline if it originally contained a newline) -- strip comments -- collapse tags with no content to a void tag -- strip CDATA sections wherever possible - -Options: - -- `KeepWhitespace` preserve whitespace between inline tags but still collapse multiple whitespace characters into one - -## Usage -Any input stream is being buffered by the minification functions. This is how the underlying buffer package inherently works to ensure high performance. The output stream however is not buffered. It is wise to preallocate a buffer as big as the input to which the output is written, or otherwise use `bufio` to buffer to a streaming writer. - -### New -Retrieve a minifier struct which holds a map of mediatype → minifier functions. -``` go -m := minify.New() -``` - -The following loads all provided minifiers. -``` go -m := minify.New() -m.AddFunc("text/css", css.Minify) -m.AddFunc("text/html", html.Minify) -m.AddFunc("image/svg+xml", svg.Minify) -m.AddFuncRegexp(regexp.MustCompile("^(application|text)/(x-)?(java|ecma)script$"), js.Minify) -m.AddFuncRegexp(regexp.MustCompile("[/+]json$"), json.Minify) -m.AddFuncRegexp(regexp.MustCompile("[/+]xml$"), xml.Minify) -``` - -You can set options to several minifiers. -``` go -m.Add("text/html", &html.Minifier{ -	KeepDefaultAttrVals: true, -	KeepWhitespace: true, -}) -``` - -### From reader -Minify from an `io.Reader` to an `io.Writer` for a specific mediatype. -``` go -if err := m.Minify(mediatype, w, r); err != nil { -	panic(err) -} -``` - -### From bytes -Minify from and to a `[]byte` for a specific mediatype. -``` go -b, err = m.Bytes(mediatype, b) -if err != nil { -	panic(err) -} -``` - -### From string -Minify from and to a `string` for a specific mediatype. -``` go -s, err = m.String(mediatype, s) -if err != nil { -	panic(err) -} -``` - -### To reader -Get a minifying reader for a specific mediatype. -``` go -mr := m.Reader(mediatype, r) -if _, err := mr.Read(b); err != nil { -	panic(err) -} -``` - -### To writer -Get a minifying writer for a specific mediatype. Must be explicitly closed because it uses an `io.Pipe` underneath. -``` go -mw := m.Writer(mediatype, w) -if mw.Write([]byte("input")); err != nil { -	panic(err) -} -if err := mw.Close(); err != nil { -	panic(err) -} -``` - -### Middleware -Minify resources on the fly using middleware. It passes a wrapped response writer to the handler that removes the Content-Length header. The minifier is chosen based on the Content-Type header or, if the header is empty, by the request URI file extension. This is on-the-fly processing, you should preferably cache the results though! -``` go -fs := http.FileServer(http.Dir("www/")) -http.Handle("/", m.Middleware(fs)) -``` - -### Custom minifier -Add a minifier for a specific mimetype. -``` go -type CustomMinifier struct { -	KeepLineBreaks bool -} - -func (c *CustomMinifier) Minify(m *minify.M, w io.Writer, r io.Reader, params map[string]string) error { -	// ... -	return nil -} - -m.Add(mimetype, &CustomMinifier{KeepLineBreaks: true}) -// or -m.AddRegexp(regexp.MustCompile("/x-custom$"), &CustomMinifier{KeepLineBreaks: true}) -``` - -Add a minify function for a specific mimetype. -``` go -m.AddFunc(mimetype, func(m *minify.M, w io.Writer, r io.Reader, params map[string]string) error { -	// ... -	return nil -}) -m.AddFuncRegexp(regexp.MustCompile("/x-custom$"), func(m *minify.M, w io.Writer, r io.Reader, params map[string]string) error { -	// ... -	return nil -}) -``` - -Add a command `cmd` with arguments `args` for a specific mimetype. -``` go -m.AddCmd(mimetype, exec.Command(cmd, args...)) -m.AddCmdRegexp(regexp.MustCompile("/x-custom$"), exec.Command(cmd, args...)) -``` - -### Mediatypes -Using the `params map[string]string` argument one can pass parameters to the minifier such as seen in mediatypes (`type/subtype; key1=val2; key2=val2`). Examples are the encoding or charset of the data. Calling `Minify` will split the mimetype and parameters for the minifiers for you, but `MinifyMimetype` can be used if you already have them split up. - -Minifiers can also be added using a regular expression. For example a minifier with `image/.*` will match any image mime. - -## Examples -### Common minifiers -Basic example that minifies from stdin to stdout and loads the default HTML, CSS and JS minifiers. Optionally, one can enable `java -jar build/compiler.jar` to run for JS (for example the [ClosureCompiler](https://code.google.com/p/closure-compiler/)). Note that reading the file into a buffer first and writing to a pre-allocated buffer would be faster (but would disable streaming). -``` go -package main - -import ( -	"log" -	"os" -	"os/exec" - -	"github.com/tdewolff/minify/v2" -	"github.com/tdewolff/minify/v2/css" -	"github.com/tdewolff/minify/v2/html" -	"github.com/tdewolff/minify/v2/js" -	"github.com/tdewolff/minify/v2/json" -	"github.com/tdewolff/minify/v2/svg" -	"github.com/tdewolff/minify/v2/xml" -) - -func main() { -	m := minify.New() -	m.AddFunc("text/css", css.Minify) -	m.AddFunc("text/html", html.Minify) -	m.AddFunc("image/svg+xml", svg.Minify) -	m.AddFuncRegexp(regexp.MustCompile("^(application|text)/(x-)?(java|ecma)script$"), js.Minify) -	m.AddFuncRegexp(regexp.MustCompile("[/+]json$"), json.Minify) -	m.AddFuncRegexp(regexp.MustCompile("[/+]xml$"), xml.Minify) - -	if err := m.Minify("text/html", os.Stdout, os.Stdin); err != nil { -		panic(err) -	} -} -``` - -### External minifiers -Below are some examples of using common external minifiers. - -#### Closure Compiler -See [Closure Compiler Application](https://developers.google.com/closure/compiler/docs/gettingstarted_app). Not tested. - -``` go -m.AddCmdRegexp(regexp.MustCompile("^(application|text)/(x-)?(java|ecma)script$"), -    exec.Command("java", "-jar", "build/compiler.jar")) -``` - -### UglifyJS -See [UglifyJS](https://github.com/mishoo/UglifyJS2). - -``` go -m.AddCmdRegexp(regexp.MustCompile("^(application|text)/(x-)?(java|ecma)script$"), -    exec.Command("uglifyjs")) -``` - -### esbuild -See [esbuild](https://github.com/evanw/esbuild). - -``` go -m.AddCmdRegexp(regexp.MustCompile("^(application|text)/(x-)?(java|ecma)script$"), -    exec.Command("esbuild", "$in.js", "--minify", "--outfile=$out.js")) -``` - -### <a name="custom-minifier-example"></a> Custom minifier -Custom minifier showing an example that implements the minifier function interface. Within a custom minifier, it is possible to call any minifier function (through `m minify.Minifier`) recursively when dealing with embedded resources. -``` go -package main - -import ( -	"bufio" -	"fmt" -	"io" -	"log" -	"strings" - -	"github.com/tdewolff/minify/v2" -) - -func main() { -	m := minify.New() -	m.AddFunc("text/plain", func(m *minify.M, w io.Writer, r io.Reader, _ map[string]string) error { -		// remove newlines and spaces -		rb := bufio.NewReader(r) -		for { -			line, err := rb.ReadString('\n') -			if err != nil && err != io.EOF { -				return err -			} -			if _, errws := io.WriteString(w, strings.Replace(line, " ", "", -1)); errws != nil { -				return errws -			} -			if err == io.EOF { -				break -			} -		} -		return nil -	}) - -	in := "Because my coffee was too cold, I heated it in the microwave." -	out, err := m.String("text/plain", in) -	if err != nil { -		panic(err) -	} -	fmt.Println(out) -	// Output: Becausemycoffeewastoocold,Iheateditinthemicrowave. -} -``` - -### ResponseWriter -#### Middleware -``` go -func main() { -	m := minify.New() -	m.AddFunc("text/css", css.Minify) -	m.AddFunc("text/html", html.Minify) -	m.AddFunc("image/svg+xml", svg.Minify) -	m.AddFuncRegexp(regexp.MustCompile("^(application|text)/(x-)?(java|ecma)script$"), js.Minify) -	m.AddFuncRegexp(regexp.MustCompile("[/+]json$"), json.Minify) -	m.AddFuncRegexp(regexp.MustCompile("[/+]xml$"), xml.Minify) - -	fs := http.FileServer(http.Dir("www/")) -	http.Handle("/", m.MiddlewareWithError(fs)) -} - -func handleError(w http.ResponseWriter, r *http.Request, err error) { -    http.Error(w, err.Error(), http.StatusInternalServerError) -} -``` - -In order to properly handle minify errors, it is necessary to close the response writer since all writes are concurrently handled. There is no need to check errors on writes since they will be returned on closing. - -```go -func main() { -	m := minify.New() -	m.AddFunc("text/html", html.Minify) -	m.AddFuncRegexp(regexp.MustCompile("^(application|text)/(x-)?(java|ecma)script$"), js.Minify) - -	input := `<script>const i = 1_000_</script>` // Faulty JS -	req := httptest.NewRequest(http.MethodGet, "/", nil) -	rec := httptest.NewRecorder() -	m.Middleware(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { -		w.Header().Set("Content-Type", "text/html") -		_, _ = w.Write([]byte(input)) - -		if err = w.(io.Closer).Close(); err != nil { -			panic(err) -		} -	})).ServeHTTP(rec, req) -} -``` - -#### ResponseWriter -``` go -func Serve(w http.ResponseWriter, r *http.Request) { -	mw := m.ResponseWriter(w, r) -	defer mw.Close() -	w = mw - -	http.ServeFile(w, r, path.Join("www", r.URL.Path)) -} -``` - -#### Custom response writer -ResponseWriter example which returns a ResponseWriter that minifies the content and then writes to the original ResponseWriter. Any write after applying this filter will be minified. -``` go -type MinifyResponseWriter struct { -	http.ResponseWriter -	io.WriteCloser -} - -func (m MinifyResponseWriter) Write(b []byte) (int, error) { -	return m.WriteCloser.Write(b) -} - -// MinifyResponseWriter must be closed explicitly by calling site. -func MinifyFilter(mediatype string, res http.ResponseWriter) MinifyResponseWriter { -	m := minify.New() -	// add minfiers - -	mw := m.Writer(mediatype, res) -	return MinifyResponseWriter{res, mw} -} -``` - -``` go -// Usage -func(w http.ResponseWriter, req *http.Request) { -	w = MinifyFilter("text/html", w) -	if _, err := io.WriteString(w, "<p class="message"> This HTTP response will be minified. </p>"); err != nil { -		panic(err) -	} -	if err := w.Close(); err != nil { -		panic(err) -	} -	// Output: <p class=message>This HTTP response will be minified. -} -``` - -### Templates - -Here's an example of a replacement for `template.ParseFiles` from `template/html`, which automatically minifies each template before parsing it. - -Be aware that minifying templates will work in most cases but not all. Because the HTML minifier only works for valid HTML5, your template must be valid HTML5 of itself. Template tags are parsed as regular text by the minifier. - -``` go -func compileTemplates(filenames ...string) (*template.Template, error) { -	m := minify.New() -	m.AddFunc("text/html", html.Minify) - -	var tmpl *template.Template -	for _, filename := range filenames { -		name := filepath.Base(filename) -		if tmpl == nil { -			tmpl = template.New(name) -		} else { -			tmpl = tmpl.New(name) -		} - -		b, err := os.ReadFile(filename) -		if err != nil { -			return nil, err -		} - -		mb, err := m.Bytes("text/html", b) -		if err != nil { -			return nil, err -		} -		tmpl.Parse(string(mb)) -	} -	return tmpl, nil -} -``` - -Example usage: - -``` go -templates := template.Must(compileTemplates("view.html", "home.html")) -``` - -## FAQ -### Newlines remain in minified output -While you might expect the minified output to be on a single line for it to be fully minified, this is not true. In many cases, using a literal newline doesn't affect the file size, and in some cases it may even reduce the file size. - -A typical example is HTML. Whitespace is significant in HTML, meaning that spaces and newlines between or around tags may affect how they are displayed. There is no distinction between a space or a newline and they may be interchanged without affecting the displayed HTML. Remember that a space (0x20) and a newline (0x0A) are both one byte long, so that there is no difference in file size when interchanging them. This minifier removes unnecessary whitespace by replacing stretches of spaces and newlines by a single whitespace character. Specifically, if the stretch of white space characters contains a newline, it will replace it by a newline and otherwise by a space. This doesn't affect the file size, but may help somewhat for debugging or file transmission objectives. - -Another example is JavaScript. Single or double quoted string literals may not contain newline characters but instead need to escape them as `\n`. These are two bytes instead of a single newline byte. Using template literals it is allowed to have literal newline characters and we can use that fact to shave-off one byte! The result is that the minified output contains newlines instead of escaped newline characters, which makes the final file size smaller. Of course, changing from single or double quotes to template literals depends on other factors as well, and this minifier makes a calculation whether the template literal results in a shorter file size or not before converting a string literal. - -## License -Released under the [MIT license](LICENSE). - -[1]: http://golang.org/ "Go Language" diff --git a/vendor/github.com/tdewolff/minify/v2/common.go b/vendor/github.com/tdewolff/minify/v2/common.go deleted file mode 100644 index 3773a9b47..000000000 --- a/vendor/github.com/tdewolff/minify/v2/common.go +++ /dev/null @@ -1,524 +0,0 @@ -package minify - -import ( -	"bytes" -	"encoding/base64" - -	"github.com/tdewolff/parse/v2" -	"github.com/tdewolff/parse/v2/strconv" -) - -var ( -	textMimeBytes     = []byte("text/plain") -	charsetASCIIBytes = []byte("charset=us-ascii") -	dataBytes         = []byte("data:") -	base64Bytes       = []byte(";base64") -) - -// Epsilon is the closest number to zero that is not considered to be zero. -var Epsilon = 0.00001 - -// Mediatype minifies a given mediatype by removing all whitespace and lowercasing all parts except strings (which may be case sensitive). -func Mediatype(b []byte) []byte { -	j := 0 -	inString := false -	start, lastString := 0, 0 -	for i, c := range b { -		if !inString && parse.IsWhitespace(c) { -			if start != 0 { -				j += copy(b[j:], b[start:i]) -			} else { -				j += i -			} -			start = i + 1 -		} else if c == '"' { -			inString = !inString -			if inString { -				if i-lastString < 1024 { // ToLower may otherwise slow down minification greatly -					parse.ToLower(b[lastString:i]) -				} -			} else { -				lastString = j + (i + 1 - start) -			} -		} -	} -	if start != 0 { -		j += copy(b[j:], b[start:]) -		parse.ToLower(b[lastString:j]) -		return b[:j] -	} -	parse.ToLower(b[lastString:]) -	return b -} - -// DataURI minifies a data URI and calls a minifier by the specified mediatype. Specifications: https://www.ietf.org/rfc/rfc2397.txt. -func DataURI(m *M, dataURI []byte) []byte { -	origData := parse.Copy(dataURI) -	mediatype, data, err := parse.DataURI(dataURI) -	if err != nil { -		return dataURI -	} - -	data, _ = m.Bytes(string(mediatype), data) -	base64Len := len(";base64") + base64.StdEncoding.EncodedLen(len(data)) -	asciiLen := len(data) -	for _, c := range data { -		if parse.DataURIEncodingTable[c] { -			asciiLen += 2 -		} -		if asciiLen > base64Len { -			break -		} -	} -	if len(origData) < base64Len && len(origData) < asciiLen { -		return origData -	} -	if base64Len < asciiLen { -		encoded := make([]byte, base64Len-len(";base64")) -		base64.StdEncoding.Encode(encoded, data) -		data = encoded -		mediatype = append(mediatype, base64Bytes...) -	} else { -		data = parse.EncodeURL(data, parse.DataURIEncodingTable) -	} -	if len("text/plain") <= len(mediatype) && parse.EqualFold(mediatype[:len("text/plain")], textMimeBytes) { -		mediatype = mediatype[len("text/plain"):] -	} -	for i := 0; i+len(";charset=us-ascii") <= len(mediatype); i++ { -		// must start with semicolon and be followed by end of mediatype or semicolon -		if mediatype[i] == ';' && parse.EqualFold(mediatype[i+1:i+len(";charset=us-ascii")], charsetASCIIBytes) && (i+len(";charset=us-ascii") >= len(mediatype) || mediatype[i+len(";charset=us-ascii")] == ';') { -			mediatype = append(mediatype[:i], mediatype[i+len(";charset=us-ascii"):]...) -			break -		} -	} -	return append(append(append(dataBytes, mediatype...), ','), data...) -} - -// MaxInt is the maximum value of int. -const MaxInt = int(^uint(0) >> 1) - -// MinInt is the minimum value of int. -const MinInt = -MaxInt - 1 - -// Decimal minifies a given byte slice containing a decimal and removes superfluous characters. It differs from Number in that it does not parse exponents. -// It does not parse or output exponents. prec is the number of significant digits. When prec is zero it will keep all digits. Only digits after the dot can be removed to reach the number of significant digits. Very large number may thus have more significant digits. -func Decimal(num []byte, prec int) []byte { -	if len(num) <= 1 { -		return num -	} - -	// omit first + and register mantissa start and end, whether it's negative and the exponent -	neg := false -	start := 0 -	dot := -1 -	end := len(num) -	if 0 < end && (num[0] == '+' || num[0] == '-') { -		if num[0] == '-' { -			neg = true -		} -		start++ -	} -	for i, c := range num[start:] { -		if c == '.' { -			dot = start + i -			break -		} -	} -	if dot == -1 { -		dot = end -	} - -	// trim leading zeros but leave at least one digit -	for start < end-1 && num[start] == '0' { -		start++ -	} -	// trim trailing zeros -	i := end - 1 -	for ; dot < i; i-- { -		if num[i] != '0' { -			end = i + 1 -			break -		} -	} -	if i == dot { -		end = dot -		if start == end { -			num[start] = '0' -			return num[start : start+1] -		} -	} else if start == end-1 && num[start] == '0' { -		return num[start:end] -	} - -	// apply precision -	if 0 < prec && dot <= start+prec { -		precEnd := start + prec + 1 // include dot -		if dot == start {           // for numbers like .012 -			digit := start + 1 -			for digit < end && num[digit] == '0' { -				digit++ -			} -			precEnd = digit + prec -		} -		if precEnd < end { -			end = precEnd - -			// process either an increase from a lesser significant decimal (>= 5) -			// or remove trailing zeros after the dot, or both -			i := end - 1 -			inc := '5' <= num[end] -			for ; start < i; i-- { -				if i == dot { -					// no-op -				} else if inc && num[i] != '9' { -					num[i]++ -					inc = false -					break -				} else if inc && i < dot { // end inc for integer -					num[i] = '0' -				} else if !inc && (i < dot || num[i] != '0') { -					break -				} -			} -			if i < dot { -				end = dot -			} else { -				end = i + 1 -			} - -			if inc { -				if dot == start && end == start+1 { -					num[start] = '1' -				} else if num[start] == '9' { -					num[start] = '1' -					num[start+1] = '0' -					end++ -				} else { -					num[start]++ -				} -			} -		} -	} - -	if neg { -		start-- -		num[start] = '-' -	} -	return num[start:end] -} - -// Number minifies a given byte slice containing a number and removes superfluous characters. -func Number(num []byte, prec int) []byte { -	if len(num) <= 1 { -		return num -	} - -	// omit first + and register mantissa start and end, whether it's negative and the exponent -	neg := false -	start := 0 -	dot := -1 -	end := len(num) -	origExp := 0 -	if num[0] == '+' || num[0] == '-' { -		if num[0] == '-' { -			neg = true -		} -		start++ -	} -	for i, c := range num[start:] { -		if c == '.' { -			dot = start + i -		} else if c == 'e' || c == 'E' { -			end = start + i -			i += start + 1 -			if i < len(num) && num[i] == '+' { -				i++ -			} -			if tmpOrigExp, n := strconv.ParseInt(num[i:]); 0 < n && int64(MinInt) <= tmpOrigExp && tmpOrigExp <= int64(MaxInt) { -				// range checks for when int is 32 bit -				origExp = int(tmpOrigExp) -			} else { -				return num -			} -			break -		} -	} -	if dot == -1 { -		dot = end -	} - -	// trim leading zeros but leave at least one digit -	for start < end-1 && num[start] == '0' { -		start++ -	} -	// trim trailing zeros -	i := end - 1 -	for ; dot < i; i-- { -		if num[i] != '0' { -			end = i + 1 -			break -		} -	} -	if i == dot { -		end = dot -		if start == end { -			num[start] = '0' -			return num[start : start+1] -		} -	} else if start == end-1 && num[start] == '0' { -		return num[start:end] -	} - -	// apply precision -	if 0 < prec { //&& (dot <= start+prec || start+prec+1 < dot || 0 < origExp) { // don't minify 9 to 10, but do 999 to 1e3 and 99e1 to 1e3 -		precEnd := start + prec -		if dot == start { // for numbers like .012 -			digit := start + 1 -			for digit < end && num[digit] == '0' { -				digit++ -			} -			precEnd = digit + prec -		} else if dot < precEnd { // for numbers where precision will include the dot -			precEnd++ -		} -		if precEnd < end && (dot < end || 1 < dot-precEnd+origExp) { // do not minify 9=>10 or 99=>100 or 9e1=>1e2 (but 90), but 999=>1e3 and 99e1=>1e3 -			end = precEnd -			inc := '5' <= num[end] -			if dot == end { -				inc = end+1 < len(num) && '5' <= num[end+1] -			} -			if precEnd < dot { -				origExp += dot - precEnd -				dot = precEnd -			} -			// process either an increase from a lesser significant decimal (>= 5) -			// and remove trailing zeros -			i := end - 1 -			for ; start < i; i-- { -				if i == dot { -					// no-op -				} else if inc && num[i] != '9' { -					num[i]++ -					inc = false -					break -				} else if !inc && num[i] != '0' { -					break -				} -			} -			end = i + 1 -			if end < dot { -				origExp += dot - end -				dot = end -			} -			if inc { // single digit left -				if dot == start { -					num[start] = '1' -					dot = start + 1 -				} else if num[start] == '9' { -					num[start] = '1' -					origExp++ -				} else { -					num[start]++ -				} -			} -		} -	} - -	// n is the number of significant digits -	// normExp would be the exponent if it were normalised (0.1 <= f < 1) -	n := 0 -	normExp := 0 -	if dot == start { -		for i = dot + 1; i < end; i++ { -			if num[i] != '0' { -				n = end - i -				normExp = dot - i + 1 -				break -			} -		} -	} else if dot == end { -		normExp = end - start -		for i = end - 1; start <= i; i-- { -			if num[i] != '0' { -				n = i + 1 - start -				end = i + 1 -				break -			} -		} -	} else { -		n = end - start - 1 -		normExp = dot - start -	} - -	if origExp < 0 && (normExp < MinInt-origExp || normExp-n < MinInt-origExp) || 0 < origExp && (MaxInt-origExp < normExp || MaxInt-origExp < normExp-n) { -		return num // exponent overflow -	} -	normExp += origExp - -	// intExp would be the exponent if it were an integer -	intExp := normExp - n -	lenIntExp := strconv.LenInt(int64(intExp)) -	lenNormExp := strconv.LenInt(int64(normExp)) - -	// there are three cases to consider when printing the number -	// case 1: without decimals and with a positive exponent (large numbers: 5e4) -	// case 2: with decimals and with a negative exponent (small numbers with many digits: .123456e-4) -	// case 3: with decimals and without an exponent (around zero: 5.6) -	// case 4: without decimals and with a negative exponent (small numbers: 123456e-9) -	if n <= normExp { -		// case 1: print number with positive exponent -		if dot < end { -			// remove dot, either from the front or copy the smallest part -			if dot == start { -				start = end - n -			} else if dot-start < end-dot-1 { -				copy(num[start+1:], num[start:dot]) -				start++ -			} else { -				copy(num[dot:], num[dot+1:end]) -				end-- -			} -		} -		if n+3 <= normExp { -			num[end] = 'e' -			end++ -			for i := end + lenIntExp - 1; end <= i; i-- { -				num[i] = byte(intExp%10) + '0' -				intExp /= 10 -			} -			end += lenIntExp -		} else if n+2 == normExp { -			num[end] = '0' -			num[end+1] = '0' -			end += 2 -		} else if n+1 == normExp { -			num[end] = '0' -			end++ -		} -	} else if normExp < -3 && lenNormExp < lenIntExp && dot < end { -		// case 2: print normalized number (0.1 <= f < 1) -		zeroes := -normExp + origExp -		if 0 < zeroes { -			copy(num[start+1:], num[start+1+zeroes:end]) -			end -= zeroes -		} else if zeroes < 0 { -			copy(num[start+1:], num[start:dot]) -			num[start] = '.' -		} -		num[end] = 'e' -		num[end+1] = '-' -		end += 2 -		for i := end + lenNormExp - 1; end <= i; i-- { -			num[i] = -byte(normExp%10) + '0' -			normExp /= 10 -		} -		end += lenNormExp -	} else if -lenIntExp-1 <= normExp { -		// case 3: print number without exponent -		zeroes := -normExp -		if 0 < zeroes { -			// dot placed at the front and negative exponent, adding zeroes -			newDot := end - n - zeroes - 1 -			if newDot != dot { -				d := start - newDot -				if 0 < d { -					if dot < end { -						// copy original digits after the dot towards the end -						copy(num[dot+1+d:], num[dot+1:end]) -						if start < dot { -							// copy original digits before the dot towards the end -							copy(num[start+d+1:], num[start:dot]) -						} -					} else if start < dot { -						// copy original digits before the dot towards the end -						copy(num[start+d:], num[start:dot]) -					} -					newDot = start -					end += d -				} else { -					start += -d -				} -				num[newDot] = '.' -				for i := 0; i < zeroes; i++ { -					num[newDot+1+i] = '0' -				} -			} -		} else { -			// dot placed in the middle of the number -			if dot == start { -				// when there are zeroes after the dot -				dot = end - n - 1 -				start = dot -			} else if end <= dot { -				// when input has no dot in it -				dot = end -				end++ -			} -			newDot := start + normExp -			// move digits between dot and newDot towards the end -			if dot < newDot { -				copy(num[dot:], num[dot+1:newDot+1]) -			} else if newDot < dot { -				copy(num[newDot+1:], num[newDot:dot]) -			} -			num[newDot] = '.' -		} -	} else { -		// case 4: print number with negative exponent -		// find new end, considering moving numbers to the front, removing the dot and increasing the length of the exponent -		newEnd := end -		if dot == start { -			newEnd = start + n -		} else { -			newEnd-- -		} -		newEnd += 2 + lenIntExp - -		exp := intExp -		lenExp := lenIntExp -		if newEnd < len(num) { -			// it saves space to convert the decimal to an integer and decrease the exponent -			if dot < end { -				if dot == start { -					copy(num[start:], num[end-n:end]) -					end = start + n -				} else { -					copy(num[dot:], num[dot+1:end]) -					end-- -				} -			} -		} else { -			// it does not save space and will panic, so we revert to the original representation -			exp = origExp -			lenExp = 1 -			if origExp <= -10 || 10 <= origExp { -				lenExp = strconv.LenInt(int64(origExp)) -			} -		} -		num[end] = 'e' -		num[end+1] = '-' -		end += 2 -		for i := end + lenExp - 1; end <= i; i-- { -			num[i] = -byte(exp%10) + '0' -			exp /= 10 -		} -		end += lenExp -	} - -	if neg { -		start-- -		num[start] = '-' -	} -	return num[start:end] -} - -func UpdateErrorPosition(err error, input *parse.Input, offset int) error { -	if perr, ok := err.(*parse.Error); ok { -		r := bytes.NewBuffer(input.Bytes()) -		line, column, _ := parse.Position(r, offset) -		perr.Line += line - 1 -		perr.Column += column - 1 -		return perr -	} -	return err -} diff --git a/vendor/github.com/tdewolff/minify/v2/html/buffer.go b/vendor/github.com/tdewolff/minify/v2/html/buffer.go deleted file mode 100644 index f2a6f8c52..000000000 --- a/vendor/github.com/tdewolff/minify/v2/html/buffer.go +++ /dev/null @@ -1,139 +0,0 @@ -package html - -import ( -	"github.com/tdewolff/parse/v2" -	"github.com/tdewolff/parse/v2/html" -) - -// Token is a single token unit with an attribute value (if given) and hash of the data. -type Token struct { -	html.TokenType -	Hash        Hash -	Data        []byte -	Text        []byte -	AttrVal     []byte -	Traits      traits -	Offset      int -	HasTemplate bool -} - -// TokenBuffer is a buffer that allows for token look-ahead. -type TokenBuffer struct { -	r *parse.Input -	l *html.Lexer - -	buf []Token -	pos int - -	attrBuffer []*Token -} - -// NewTokenBuffer returns a new TokenBuffer. -func NewTokenBuffer(r *parse.Input, l *html.Lexer) *TokenBuffer { -	return &TokenBuffer{ -		r:   r, -		l:   l, -		buf: make([]Token, 0, 8), -	} -} - -func (z *TokenBuffer) read(t *Token) { -	t.Offset = z.r.Offset() -	t.TokenType, t.Data = z.l.Next() -	t.Text = z.l.Text() -	t.HasTemplate = z.l.HasTemplate() -	if t.TokenType == html.AttributeToken { -		t.Offset += 1 + len(t.Text) + 1 -		t.AttrVal = z.l.AttrVal() -		if 1 < len(t.AttrVal) && (t.AttrVal[0] == '"' || t.AttrVal[0] == '\'') { -			t.Offset++ -			t.AttrVal = t.AttrVal[1 : len(t.AttrVal)-1] // quotes will be readded in attribute loop if necessary -		} -		t.Hash = ToHash(t.Text) -		t.Traits = attrMap[t.Hash] -	} else if t.TokenType == html.StartTagToken || t.TokenType == html.EndTagToken { -		t.AttrVal = nil -		t.Hash = ToHash(t.Text) -		t.Traits = tagMap[t.Hash] // zero if not exist -	} else { -		t.AttrVal = nil -		t.Hash = 0 -		t.Traits = 0 -	} -} - -// Peek returns the ith element and possibly does an allocation. -// Peeking past an error will panic. -func (z *TokenBuffer) Peek(pos int) *Token { -	pos += z.pos -	if pos >= len(z.buf) { -		if len(z.buf) > 0 && z.buf[len(z.buf)-1].TokenType == html.ErrorToken { -			return &z.buf[len(z.buf)-1] -		} - -		c := cap(z.buf) -		d := len(z.buf) - z.pos -		p := pos - z.pos + 1 // required peek length -		var buf []Token -		if 2*p > c { -			buf = make([]Token, 0, 2*c+p) -		} else { -			buf = z.buf -		} -		copy(buf[:d], z.buf[z.pos:]) - -		buf = buf[:p] -		pos -= z.pos -		for i := d; i < p; i++ { -			z.read(&buf[i]) -			if buf[i].TokenType == html.ErrorToken { -				buf = buf[:i+1] -				pos = i -				break -			} -		} -		z.pos, z.buf = 0, buf -	} -	return &z.buf[pos] -} - -// Shift returns the first element and advances position. -func (z *TokenBuffer) Shift() *Token { -	if z.pos >= len(z.buf) { -		t := &z.buf[:1][0] -		z.read(t) -		return t -	} -	t := &z.buf[z.pos] -	z.pos++ -	return t -} - -// Attributes extracts the gives attribute hashes from a tag. -// It returns in the same order pointers to the requested token data or nil. -func (z *TokenBuffer) Attributes(hashes ...Hash) []*Token { -	n := 0 -	for { -		if t := z.Peek(n); t.TokenType != html.AttributeToken { -			break -		} -		n++ -	} -	if len(hashes) > cap(z.attrBuffer) { -		z.attrBuffer = make([]*Token, len(hashes)) -	} else { -		z.attrBuffer = z.attrBuffer[:len(hashes)] -		for i := range z.attrBuffer { -			z.attrBuffer[i] = nil -		} -	} -	for i := z.pos; i < z.pos+n; i++ { -		attr := &z.buf[i] -		for j, hash := range hashes { -			if hash == attr.Hash { -				z.attrBuffer[j] = attr -			} -		} -	} -	return z.attrBuffer -} diff --git a/vendor/github.com/tdewolff/minify/v2/html/hash.go b/vendor/github.com/tdewolff/minify/v2/html/hash.go deleted file mode 100644 index 5eefcebb0..000000000 --- a/vendor/github.com/tdewolff/minify/v2/html/hash.go +++ /dev/null @@ -1,610 +0,0 @@ -package html - -// generated by hasher -type=Hash -file=hash.go; DO NOT EDIT, except for adding more constants to the list and rerun go generate - -// uses github.com/tdewolff/hasher -//go:generate hasher -type=Hash -file=hash.go - -// Hash defines perfect hashes for a predefined list of strings -type Hash uint32 - -// Unique hash definitions to be used instead of strings -const ( -	A                        Hash = 0x1     // a -	Abbr                     Hash = 0x40004 // abbr -	About                    Hash = 0x5     // about -	Accept                   Hash = 0xc06   // accept -	Accept_Charset           Hash = 0xc0e   // accept-charset -	Accesskey                Hash = 0x2c09  // accesskey -	Acronym                  Hash = 0x3507  // acronym -	Action                   Hash = 0x26006 // action -	Address                  Hash = 0x6d07  // address -	Allow                    Hash = 0x31f05 // allow -	Allowfullscreen          Hash = 0x31f0f // allowfullscreen -	Amp_Boilerplate          Hash = 0x5e0f  // amp-boilerplate -	Applet                   Hash = 0xee06  // applet -	Area                     Hash = 0x2c304 // area -	Article                  Hash = 0x22507 // article -	As                       Hash = 0x2102  // as -	Aside                    Hash = 0x9205  // aside -	Async                    Hash = 0x8a05  // async -	Audio                    Hash = 0x9d05  // audio -	Autocapitalize           Hash = 0xc30e  // autocapitalize -	Autocomplete             Hash = 0xd10c  // autocomplete -	Autofocus                Hash = 0xe309  // autofocus -	Autoplay                 Hash = 0xfc08  // autoplay -	B                        Hash = 0x101   // b -	Base                     Hash = 0x2004  // base -	Basefont                 Hash = 0x2008  // basefont -	Bb                       Hash = 0x40102 // bb -	Bdi                      Hash = 0x8303  // bdi -	Bdo                      Hash = 0x3dc03 // bdo -	Big                      Hash = 0x12f03 // big -	Blocking                 Hash = 0x13208 // blocking -	Blockquote               Hash = 0x13a0a // blockquote -	Body                     Hash = 0x804   // body -	Br                       Hash = 0x14b02 // br -	Button                   Hash = 0x14406 // button -	Canvas                   Hash = 0x8e06  // canvas -	Caption                  Hash = 0x23707 // caption -	Capture                  Hash = 0x10d07 // capture -	Center                   Hash = 0x24f06 // center -	Charset                  Hash = 0x1307  // charset -	Checked                  Hash = 0x37707 // checked -	Cite                     Hash = 0x14d04 // cite -	Class                    Hash = 0x15a05 // class -	Code                     Hash = 0x17604 // code -	Col                      Hash = 0x17f03 // col -	Colgroup                 Hash = 0x17f08 // colgroup -	Color                    Hash = 0x19e05 // color -	Cols                     Hash = 0x1a304 // cols -	Colspan                  Hash = 0x1a307 // colspan -	Content                  Hash = 0x1b107 // content -	Contenteditable          Hash = 0x1b10f // contenteditable -	Controls                 Hash = 0x1cc08 // controls -	Coords                   Hash = 0x1e306 // coords -	Crossorigin              Hash = 0x2160b // crossorigin -	Data                     Hash = 0xad04  // data -	Datalist                 Hash = 0xad08  // datalist -	Datatype                 Hash = 0x11908 // datatype -	Datetime                 Hash = 0x28508 // datetime -	Dd                       Hash = 0x6e02  // dd -	Decoding                 Hash = 0x9508  // decoding -	Default                  Hash = 0x17807 // default -	Defer                    Hash = 0x4405  // defer -	Del                      Hash = 0x1f203 // del -	Details                  Hash = 0x20b07 // details -	Dfn                      Hash = 0x16a03 // dfn -	Dialog                   Hash = 0x28d06 // dialog -	Dir                      Hash = 0x8403  // dir -	Disabled                 Hash = 0x19208 // disabled -	Div                      Hash = 0x19903 // div -	Dl                       Hash = 0x1c302 // dl -	Draggable                Hash = 0x1da09 // draggable -	Dt                       Hash = 0x40902 // dt -	Em                       Hash = 0xdc02  // em -	Embed                    Hash = 0x16605 // embed -	Enctype                  Hash = 0x26a07 // enctype -	Enterkeyhint             Hash = 0x2500c // enterkeyhint -	Fetchpriority            Hash = 0x1220d // fetchpriority -	Fieldset                 Hash = 0x22c08 // fieldset -	Figcaption               Hash = 0x2340a // figcaption -	Figure                   Hash = 0x24506 // figure -	Font                     Hash = 0x2404  // font -	Footer                   Hash = 0x1a06  // footer -	For                      Hash = 0x25c03 // for -	Form                     Hash = 0x25c04 // form -	Formaction               Hash = 0x25c0a // formaction -	Formenctype              Hash = 0x2660b // formenctype -	Formmethod               Hash = 0x2710a // formmethod -	Formnovalidate           Hash = 0x27b0e // formnovalidate -	Formtarget               Hash = 0x2930a // formtarget -	Frame                    Hash = 0x16e05 // frame -	Frameset                 Hash = 0x16e08 // frameset -	H1                       Hash = 0x2d502 // h1 -	H2                       Hash = 0x38602 // h2 -	H3                       Hash = 0x39502 // h3 -	H4                       Hash = 0x40b02 // h4 -	H5                       Hash = 0x29d02 // h5 -	H6                       Hash = 0x29f02 // h6 -	Head                     Hash = 0x36c04 // head -	Header                   Hash = 0x36c06 // header -	Headers                  Hash = 0x36c07 // headers -	Height                   Hash = 0x2a106 // height -	Hgroup                   Hash = 0x2b506 // hgroup -	Hidden                   Hash = 0x2cc06 // hidden -	High                     Hash = 0x2d204 // high -	Hr                       Hash = 0x2d702 // hr -	Href                     Hash = 0x2d704 // href -	Hreflang                 Hash = 0x2d708 // hreflang -	Html                     Hash = 0x2a504 // html -	Http_Equiv               Hash = 0x2df0a // http-equiv -	I                        Hash = 0x2801  // i -	Id                       Hash = 0x9402  // id -	Iframe                   Hash = 0x2f206 // iframe -	Image                    Hash = 0x30005 // image -	Imagesizes               Hash = 0x3000a // imagesizes -	Imagesrcset              Hash = 0x30d0b // imagesrcset -	Img                      Hash = 0x31803 // img -	Inert                    Hash = 0x10805 // inert -	Inlist                   Hash = 0x21f06 // inlist -	Input                    Hash = 0x3d05  // input -	Inputmode                Hash = 0x3d09  // inputmode -	Ins                      Hash = 0x31b03 // ins -	Is                       Hash = 0xb202  // is -	Ismap                    Hash = 0x32e05 // ismap -	Itemid                   Hash = 0x2fa06 // itemid -	Itemprop                 Hash = 0x14e08 // itemprop -	Itemref                  Hash = 0x34507 // itemref -	Itemscope                Hash = 0x35709 // itemscope -	Itemtype                 Hash = 0x36108 // itemtype -	Kbd                      Hash = 0x8203  // kbd -	Kind                     Hash = 0xaa04  // kind -	Label                    Hash = 0x1c405 // label -	Lang                     Hash = 0x2db04 // lang -	Legend                   Hash = 0x1be06 // legend -	Li                       Hash = 0xb102  // li -	Link                     Hash = 0x1c804 // link -	List                     Hash = 0xb104  // list -	Loading                  Hash = 0x3ad07 // loading -	Loop                     Hash = 0x2a804 // loop -	Low                      Hash = 0x32103 // low -	Main                     Hash = 0x3b04  // main -	Map                      Hash = 0xed03  // map -	Mark                     Hash = 0x7f04  // mark -	Marquee                  Hash = 0x3e407 // marquee -	Math                     Hash = 0x36904 // math -	Max                      Hash = 0x37e03 // max -	Maxlength                Hash = 0x37e09 // maxlength -	Media                    Hash = 0x28b05 // media -	Menu                     Hash = 0x2f604 // menu -	Menuitem                 Hash = 0x2f608 // menuitem -	Meta                     Hash = 0x5004  // meta -	Meter                    Hash = 0x38805 // meter -	Method                   Hash = 0x27506 // method -	Min                      Hash = 0x38d03 // min -	Minlength                Hash = 0x38d09 // minlength -	Multiple                 Hash = 0x39708 // multiple -	Muted                    Hash = 0x39f05 // muted -	Name                     Hash = 0x4e04  // name -	Nav                      Hash = 0xbc03  // nav -	Nobr                     Hash = 0x14904 // nobr -	Noembed                  Hash = 0x16407 // noembed -	Noframes                 Hash = 0x16c08 // noframes -	Nomodule                 Hash = 0x1a908 // nomodule -	Noscript                 Hash = 0x23d08 // noscript -	Novalidate               Hash = 0x27f0a // novalidate -	Object                   Hash = 0xa106  // object -	Ol                       Hash = 0x18002 // ol -	Open                     Hash = 0x35d04 // open -	Optgroup                 Hash = 0x2aa08 // optgroup -	Optimum                  Hash = 0x3de07 // optimum -	Option                   Hash = 0x2ec06 // option -	Output                   Hash = 0x206   // output -	P                        Hash = 0x501   // p -	Param                    Hash = 0x7b05  // param -	Pattern                  Hash = 0xb607  // pattern -	Picture                  Hash = 0x18607 // picture -	Ping                     Hash = 0x2b104 // ping -	Plaintext                Hash = 0x2ba09 // plaintext -	Playsinline              Hash = 0x1000b // playsinline -	Popover                  Hash = 0x33207 // popover -	Popovertarget            Hash = 0x3320d // popovertarget -	Popovertargetaction      Hash = 0x33213 // popovertargetaction -	Portal                   Hash = 0x3f406 // portal -	Poster                   Hash = 0x41006 // poster -	Pre                      Hash = 0x3a403 // pre -	Prefix                   Hash = 0x3a406 // prefix -	Preload                  Hash = 0x3aa07 // preload -	Profile                  Hash = 0x3b407 // profile -	Progress                 Hash = 0x3bb08 // progress -	Property                 Hash = 0x15208 // property -	Q                        Hash = 0x11401 // q -	Rb                       Hash = 0x1f02  // rb -	Readonly                 Hash = 0x2c408 // readonly -	Referrerpolicy           Hash = 0x3490e // referrerpolicy -	Rel                      Hash = 0x3ab03 // rel -	Required                 Hash = 0x11208 // required -	Resource                 Hash = 0x24908 // resource -	Rev                      Hash = 0x18b03 // rev -	Reversed                 Hash = 0x18b08 // reversed -	Rows                     Hash = 0x4804  // rows -	Rowspan                  Hash = 0x4807  // rowspan -	Rp                       Hash = 0x6702  // rp -	Rt                       Hash = 0x10b02 // rt -	Rtc                      Hash = 0x10b03 // rtc -	Ruby                     Hash = 0x8604  // ruby -	S                        Hash = 0x1701  // s -	Samp                     Hash = 0x5d04  // samp -	Sandbox                  Hash = 0x7307  // sandbox -	Scope                    Hash = 0x35b05 // scope -	Script                   Hash = 0x23f06 // script -	Section                  Hash = 0x15e07 // section -	Select                   Hash = 0x1d306 // select -	Selected                 Hash = 0x1d308 // selected -	Shadowrootdelegatesfocus Hash = 0x1e818 // shadowrootdelegatesfocus -	Shadowrootmode           Hash = 0x1ff0e // shadowrootmode -	Shape                    Hash = 0x21105 // shape -	Size                     Hash = 0x30504 // size -	Sizes                    Hash = 0x30505 // sizes -	Slot                     Hash = 0x30904 // slot -	Small                    Hash = 0x31d05 // small -	Source                   Hash = 0x24b06 // source -	Span                     Hash = 0x4b04  // span -	Spellcheck               Hash = 0x3720a // spellcheck -	Src                      Hash = 0x31203 // src -	Srclang                  Hash = 0x3c207 // srclang -	Srcset                   Hash = 0x31206 // srcset -	Start                    Hash = 0x22305 // start -	Step                     Hash = 0xb304  // step -	Strike                   Hash = 0x3c906 // strike -	Strong                   Hash = 0x3cf06 // strong -	Style                    Hash = 0x3d505 // style -	Sub                      Hash = 0x3da03 // sub -	Summary                  Hash = 0x3eb07 // summary -	Sup                      Hash = 0x3f203 // sup -	Svg                      Hash = 0x3fa03 // svg -	Tabindex                 Hash = 0x5208  // tabindex -	Table                    Hash = 0x1bb05 // table -	Target                   Hash = 0x29706 // target -	Tbody                    Hash = 0x705   // tbody -	Td                       Hash = 0x1f102 // td -	Template                 Hash = 0xdb08  // template -	Text                     Hash = 0x2bf04 // text -	Textarea                 Hash = 0x2bf08 // textarea -	Tfoot                    Hash = 0x1905  // tfoot -	Th                       Hash = 0x27702 // th -	Thead                    Hash = 0x36b05 // thead -	Time                     Hash = 0x28904 // time -	Title                    Hash = 0x2705  // title -	Tr                       Hash = 0xa602  // tr -	Track                    Hash = 0xa605  // track -	Translate                Hash = 0xf309  // translate -	Tt                       Hash = 0xb802  // tt -	Type                     Hash = 0x11d04 // type -	Typeof                   Hash = 0x11d06 // typeof -	U                        Hash = 0x301   // u -	Ul                       Hash = 0x17c02 // ul -	Usemap                   Hash = 0xea06  // usemap -	Value                    Hash = 0xbe05  // value -	Var                      Hash = 0x19b03 // var -	Video                    Hash = 0x2e805 // video -	Vocab                    Hash = 0x3fd05 // vocab -	Wbr                      Hash = 0x40403 // wbr -	Width                    Hash = 0x40705 // width -	Wrap                     Hash = 0x40d04 // wrap -	Xmlns                    Hash = 0x5905  // xmlns -	Xmp                      Hash = 0x7903  // xmp -) - -// String returns the hash' name. -func (i Hash) String() string { -	start := uint32(i >> 8) -	n := uint32(i & 0xff) -	if start+n > uint32(len(_Hash_text)) { -		return "" -	} -	return _Hash_text[start : start+n] -} - -// ToHash returns the hash whose name is s. It returns zero if there is no -// such hash. It is case sensitive. -func ToHash(s []byte) Hash { -	if len(s) == 0 || len(s) > _Hash_maxLen { -		return 0 -	} -	h := uint32(_Hash_hash0) -	for i := 0; i < len(s); i++ { -		h ^= uint32(s[i]) -		h *= 16777619 -	} -	if i := _Hash_table[h&uint32(len(_Hash_table)-1)]; int(i&0xff) == len(s) { -		t := _Hash_text[i>>8 : i>>8+i&0xff] -		for i := 0; i < len(s); i++ { -			if t[i] != s[i] { -				goto NEXT -			} -		} -		return i -	} -NEXT: -	if i := _Hash_table[(h>>16)&uint32(len(_Hash_table)-1)]; int(i&0xff) == len(s) { -		t := _Hash_text[i>>8 : i>>8+i&0xff] -		for i := 0; i < len(s); i++ { -			if t[i] != s[i] { -				return 0 -			} -		} -		return i -	} -	return 0 -} - -const _Hash_hash0 = 0x51243bbc -const _Hash_maxLen = 24 -const _Hash_text = "aboutputbodyaccept-charsetfooterbasefontitleaccesskeyacronym" + -	"ainputmodeferowspanametabindexmlnsamp-boilerplateaddressandb" + -	"oxmparamarkbdirubyasyncanvasidecodingaudiobjectrackindatalis" + -	"tepatternavalueautocapitalizeautocompletemplateautofocusemap" + -	"pletranslateautoplaysinlinertcapturequiredatatypeofetchprior" + -	"itybigblockingblockquotebuttonobrcitempropertyclassectionoem" + -	"bedfnoframesetcodefaultcolgroupictureversedisabledivarcolorc" + -	"olspanomodulecontenteditablegendlabelinkcontrolselectedragga" + -	"blecoordshadowrootdelegatesfocushadowrootmodetailshapecrosso" + -	"riginlistarticlefieldsetfigcaptionoscriptfiguresourcenterkey" + -	"hintformactionformenctypeformmethodformnovalidatetimedialogf" + -	"ormtargeth5h6heightmlooptgroupinghgrouplaintextareadonlyhidd" + -	"enhigh1hreflanghttp-equivideoptioniframenuitemidimagesizeslo" + -	"timagesrcsetimginsmallowfullscreenismapopovertargetactionite" + -	"mreferrerpolicyitemscopenitemtypematheaderspellcheckedmaxlen" + -	"gth2meterminlength3multiplemutedprefixpreloadingprofileprogr" + -	"essrclangstrikestrongstylesubdoptimumarqueesummarysuportalsv" + -	"gvocabbrwbrwidth4wraposter" - -var _Hash_table = [1 << 9]Hash{ -	0x0:   0x4405,  // defer -	0x5:   0x18002, // ol -	0x6:   0x3720a, // spellcheck -	0x7:   0x40b02, // h4 -	0x8:   0x40705, // width -	0x9:   0x9402,  // id -	0xb:   0x14904, // nobr -	0xc:   0x31d05, // small -	0xf:   0x2b506, // hgroup -	0x10:  0x27702, // th -	0x15:  0x24f06, // center -	0x18:  0xd10c,  // autocomplete -	0x1b:  0x2c304, // area -	0x1e:  0x17f03, // col -	0x1f:  0x2a106, // height -	0x21:  0x4b04,  // span -	0x22:  0x37e03, // max -	0x23:  0x3cf06, // strong -	0x24:  0x501,   // p -	0x29:  0x24b06, // source -	0x2c:  0x8e06,  // canvas -	0x2d:  0x2c09,  // accesskey -	0x2e:  0x18607, // picture -	0x30:  0x3a403, // pre -	0x31:  0x5d04,  // samp -	0x34:  0x40902, // dt -	0x36:  0x30505, // sizes -	0x37:  0x1a908, // nomodule -	0x39:  0x2a504, // html -	0x3a:  0x31203, // src -	0x3c:  0x28d06, // dialog -	0x3e:  0x3ab03, // rel -	0x40:  0x1a06,  // footer -	0x43:  0x30d0b, // imagesrcset -	0x46:  0x3c906, // strike -	0x47:  0x2e805, // video -	0x4a:  0x2d702, // hr -	0x4b:  0x36108, // itemtype -	0x4c:  0x1c804, // link -	0x4e:  0x6702,  // rp -	0x4f:  0x2801,  // i -	0x50:  0xee06,  // applet -	0x51:  0x17f08, // colgroup -	0x53:  0x1905,  // tfoot -	0x54:  0xc06,   // accept -	0x57:  0x14d04, // cite -	0x58:  0x1307,  // charset -	0x59:  0x17604, // code -	0x5a:  0x4e04,  // name -	0x5b:  0x2bf04, // text -	0x5d:  0x31f05, // allow -	0x5e:  0x36c04, // head -	0x61:  0x16605, // embed -	0x62:  0x3fa03, // svg -	0x63:  0x3fd05, // vocab -	0x64:  0x5e0f,  // amp-boilerplate -	0x65:  0x38805, // meter -	0x67:  0x3320d, // popovertarget -	0x69:  0x3b04,  // main -	0x6a:  0x41006, // poster -	0x6c:  0x1c302, // dl -	0x6e:  0x26006, // action -	0x71:  0x17807, // default -	0x72:  0x3d05,  // input -	0x74:  0xb202,  // is -	0x75:  0x27506, // method -	0x79:  0x7903,  // xmp -	0x7a:  0x101,   // b -	0x7b:  0x21f06, // inlist -	0x7c:  0x25c0a, // formaction -	0x7e:  0x39708, // multiple -	0x80:  0x1f203, // del -	0x81:  0x26a07, // enctype -	0x83:  0x27b0e, // formnovalidate -	0x84:  0x2404,  // font -	0x85:  0x11d06, // typeof -	0x86:  0x2d704, // href -	0x87:  0x13a0a, // blockquote -	0x88:  0x4807,  // rowspan -	0x89:  0x3aa07, // preload -	0x8a:  0x12f03, // big -	0x8c:  0x38d09, // minlength -	0x90:  0x1bb05, // table -	0x91:  0x39f05, // muted -	0x92:  0x3e407, // marquee -	0x94:  0x3507,  // acronym -	0x96:  0x40d04, // wrap -	0x98:  0x14b02, // br -	0x9a:  0x10b02, // rt -	0x9e:  0xa602,  // tr -	0x9f:  0x35709, // itemscope -	0xa4:  0xad04,  // data -	0xa5:  0x29706, // target -	0xac:  0x11908, // datatype -	0xae:  0xb304,  // step -	0xb3:  0x1cc08, // controls -	0xb5:  0xbe05,  // value -	0xb6:  0x2ba09, // plaintext -	0xb7:  0x1da09, // draggable -	0xc0:  0x8a05,  // async -	0xc2:  0x2a804, // loop -	0xc3:  0x28904, // time -	0xc6:  0x2004,  // base -	0xc7:  0x23f06, // script -	0xce:  0x32103, // low -	0xcf:  0x3dc03, // bdo -	0xd1:  0x18b03, // rev -	0xd2:  0x1e306, // coords -	0xd3:  0x8403,  // dir -	0xd4:  0x2f608, // menuitem -	0xd6:  0x22507, // article -	0xd8:  0x11d04, // type -	0xda:  0x18b08, // reversed -	0xdb:  0x23707, // caption -	0xdc:  0x35d04, // open -	0xdd:  0x1701,  // s -	0xe0:  0x2705,  // title -	0xe1:  0x9508,  // decoding -	0xe3:  0xc0e,   // accept-charset -	0xe4:  0x15a05, // class -	0xe5:  0x3f203, // sup -	0xe6:  0xdb08,  // template -	0xe7:  0x16c08, // noframes -	0xe8:  0x3ad07, // loading -	0xeb:  0xa106,  // object -	0xee:  0x3da03, // sub -	0xef:  0x2fa06, // itemid -	0xf0:  0x30904, // slot -	0xf1:  0x8604,  // ruby -	0xf4:  0x1f102, // td -	0xf5:  0x11208, // required -	0xf9:  0x16e05, // frame -	0xfc:  0x2102,  // as -	0xfd:  0x37e09, // maxlength -	0xff:  0x31f0f, // allowfullscreen -	0x101: 0x2160b, // crossorigin -	0x102: 0xed03,  // map -	0x104: 0x6e02,  // dd -	0x105: 0x705,   // tbody -	0x107: 0x2d502, // h1 -	0x109: 0x5004,  // meta -	0x10a: 0x1,     // a -	0x10c: 0x16a03, // dfn -	0x10e: 0x34507, // itemref -	0x110: 0x38d03, // min -	0x111: 0x28508, // datetime -	0x114: 0xdc02,  // em -	0x115: 0x7f04,  // mark -	0x119: 0x2d708, // hreflang -	0x11a: 0x3de07, // optimum -	0x11c: 0x1220d, // fetchpriority -	0x11d: 0x39502, // h3 -	0x11e: 0x5905,  // xmlns -	0x11f: 0x19903, // div -	0x121: 0x40403, // wbr -	0x128: 0x2bf08, // textarea -	0x129: 0x3d505, // style -	0x12a: 0x3f406, // portal -	0x12b: 0x1b107, // content -	0x12d: 0x19b03, // var -	0x12f: 0x40004, // abbr -	0x133: 0x31803, // img -	0x138: 0x35b05, // scope -	0x13b: 0x30504, // size -	0x13e: 0x29f02, // h6 -	0x141: 0xfc08,  // autoplay -	0x142: 0x2c408, // readonly -	0x143: 0x3d09,  // inputmode -	0x144: 0x19208, // disabled -	0x145: 0x4804,  // rows -	0x149: 0x3490e, // referrerpolicy -	0x14a: 0x1c405, // label -	0x14b: 0x36c06, // header -	0x14c: 0xad08,  // datalist -	0x14d: 0xe309,  // autofocus -	0x14e: 0xb607,  // pattern -	0x150: 0x2cc06, // hidden -	0x151: 0x5,     // about -	0x152: 0x14406, // button -	0x154: 0x2f206, // iframe -	0x155: 0x1d308, // selected -	0x156: 0x3c207, // srclang -	0x15b: 0xb102,  // li -	0x15c: 0x22305, // start -	0x15d: 0x7307,  // sandbox -	0x15e: 0x31b03, // ins -	0x162: 0x1a307, // colspan -	0x163: 0x1ff0e, // shadowrootmode -	0x164: 0xb104,  // list -	0x166: 0x5208,  // tabindex -	0x169: 0x3b407, // profile -	0x16b: 0x301,   // u -	0x16c: 0x23d08, // noscript -	0x16e: 0x2660b, // formenctype -	0x16f: 0x16e08, // frameset -	0x170: 0x28b05, // media -	0x174: 0x2008,  // basefont -	0x176: 0x2b104, // ping -	0x177: 0x3bb08, // progress -	0x178: 0x206,   // output -	0x17a: 0x36904, // math -	0x17b: 0x2930a, // formtarget -	0x17d: 0x7b05,  // param -	0x180: 0x13208, // blocking -	0x185: 0x37707, // checked -	0x188: 0x32e05, // ismap -	0x18a: 0x38602, // h2 -	0x18c: 0x2df0a, // http-equiv -	0x18e: 0x10d07, // capture -	0x190: 0x2db04, // lang -	0x195: 0x27f0a, // novalidate -	0x197: 0x1a304, // cols -	0x198: 0x804,   // body -	0x199: 0xbc03,  // nav -	0x19a: 0x1b10f, // contenteditable -	0x19b: 0x15e07, // section -	0x19e: 0x14e08, // itemprop -	0x19f: 0x15208, // property -	0x1a1: 0xc30e,  // autocapitalize -	0x1a4: 0x3eb07, // summary -	0x1a6: 0x1000b, // playsinline -	0x1a9: 0x8303,  // bdi -	0x1ab: 0x29d02, // h5 -	0x1ac: 0x6d07,  // address -	0x1b0: 0x2d204, // high -	0x1b1: 0x33207, // popover -	0x1b3: 0xa605,  // track -	0x1b6: 0x8203,  // kbd -	0x1b7: 0x11401, // q -	0x1b8: 0x2340a, // figcaption -	0x1b9: 0x30005, // image -	0x1ba: 0x25c04, // form -	0x1c1: 0x3000a, // imagesizes -	0x1c4: 0x1e818, // shadowrootdelegatesfocus -	0x1c5: 0x2ec06, // option -	0x1c6: 0x9d05,  // audio -	0x1c8: 0x40102, // bb -	0x1c9: 0x16407, // noembed -	0x1cc: 0x10805, // inert -	0x1cf: 0x1d306, // select -	0x1d1: 0x22c08, // fieldset -	0x1d2: 0x31206, // srcset -	0x1d3: 0x2f604, // menu -	0x1d5: 0x36c07, // headers -	0x1dd: 0x1be06, // legend -	0x1de: 0xaa04,  // kind -	0x1e0: 0x24908, // resource -	0x1e2: 0xf309,  // translate -	0x1e4: 0x2aa08, // optgroup -	0x1e6: 0x33213, // popovertargetaction -	0x1e7: 0x2710a, // formmethod -	0x1e9: 0xb802,  // tt -	0x1ea: 0x36b05, // thead -	0x1eb: 0x17c02, // ul -	0x1ee: 0x3a406, // prefix -	0x1ef: 0x19e05, // color -	0x1f1: 0x21105, // shape -	0x1f3: 0x25c03, // for -	0x1f4: 0x2500c, // enterkeyhint -	0x1f7: 0xea06,  // usemap -	0x1f8: 0x1f02,  // rb -	0x1fa: 0x20b07, // details -	0x1fb: 0x10b03, // rtc -	0x1fc: 0x9205,  // aside -	0x1fe: 0x24506, // figure -} diff --git a/vendor/github.com/tdewolff/minify/v2/html/html.go b/vendor/github.com/tdewolff/minify/v2/html/html.go deleted file mode 100644 index ce5e96dc3..000000000 --- a/vendor/github.com/tdewolff/minify/v2/html/html.go +++ /dev/null @@ -1,534 +0,0 @@ -// Package html minifies HTML5 following the specifications at http://www.w3.org/TR/html5/syntax.html. -package html - -import ( -	"bytes" -	"fmt" -	"io" - -	"github.com/tdewolff/minify/v2" -	"github.com/tdewolff/parse/v2" -	"github.com/tdewolff/parse/v2/buffer" -	"github.com/tdewolff/parse/v2/html" -) - -var ( -	gtBytes         = []byte(">") -	isBytes         = []byte("=") -	spaceBytes      = []byte(" ") -	doctypeBytes    = []byte("<!doctype html>") -	jsMimeBytes     = []byte("application/javascript") -	cssMimeBytes    = []byte("text/css") -	htmlMimeBytes   = []byte("text/html") -	svgMimeBytes    = []byte("image/svg+xml") -	formMimeBytes   = []byte("application/x-www-form-urlencoded") -	mathMimeBytes   = []byte("application/mathml+xml") -	dataSchemeBytes = []byte("data:") -	jsSchemeBytes   = []byte("javascript:") -	httpBytes       = []byte("http") -	radioBytes      = []byte("radio") -	onBytes         = []byte("on") -	textBytes       = []byte("text") -	noneBytes       = []byte("none") -	submitBytes     = []byte("submit") -	allBytes        = []byte("all") -	rectBytes       = []byte("rect") -	dataBytes       = []byte("data") -	getBytes        = []byte("get") -	autoBytes       = []byte("auto") -	oneBytes        = []byte("one") -	inlineParams    = map[string]string{"inline": "1"} -) - -//////////////////////////////////////////////////////////////// - -var GoTemplateDelims = [2]string{"{{", "}}"} -var HandlebarsTemplateDelims = [2]string{"{{", "}}"} -var MustacheTemplateDelims = [2]string{"{{", "}}"} -var EJSTemplateDelims = [2]string{"<%", "%>"} -var ASPTemplateDelims = [2]string{"<%", "%>"} -var PHPTemplateDelims = [2]string{"<?", "?>"} - -// Minifier is an HTML minifier. -type Minifier struct { -	KeepComments            bool -	KeepConditionalComments bool -	KeepSpecialComments     bool -	KeepDefaultAttrVals     bool -	KeepDocumentTags        bool -	KeepEndTags             bool -	KeepQuotes              bool -	KeepWhitespace          bool -	TemplateDelims          [2]string -} - -// Minify minifies HTML data, it reads from r and writes to w. -func Minify(m *minify.M, w io.Writer, r io.Reader, params map[string]string) error { -	return (&Minifier{}).Minify(m, w, r, params) -} - -// Minify minifies HTML data, it reads from r and writes to w. -func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]string) error { -	var rawTagHash Hash -	var rawTagMediatype []byte - -	if o.KeepConditionalComments { -		fmt.Println("DEPRECATED: KeepConditionalComments is replaced by KeepSpecialComments") -		o.KeepSpecialComments = true -		o.KeepConditionalComments = false // omit next warning -	} - -	omitSpace := true // if true the next leading space is omitted -	inPre := false - -	attrMinifyBuffer := buffer.NewWriter(make([]byte, 0, 64)) -	attrByteBuffer := make([]byte, 0, 64) - -	z := parse.NewInput(r) -	defer z.Restore() - -	l := html.NewTemplateLexer(z, o.TemplateDelims) -	tb := NewTokenBuffer(z, l) -	for { -		t := *tb.Shift() -		switch t.TokenType { -		case html.ErrorToken: -			if _, err := w.Write(nil); err != nil { -				return err -			} -			if l.Err() == io.EOF { -				return nil -			} -			return l.Err() -		case html.DoctypeToken: -			w.Write(doctypeBytes) -		case html.CommentToken: -			if o.KeepComments { -				w.Write(t.Data) -			} else if o.KeepSpecialComments { -				if 6 < len(t.Text) && (bytes.HasPrefix(t.Text, []byte("[if ")) || bytes.HasSuffix(t.Text, []byte("[endif]")) || bytes.HasSuffix(t.Text, []byte("[endif]--"))) { -					// [if ...] is always 7 or more characters, [endif] is only encountered for downlevel-revealed -					// see https://msdn.microsoft.com/en-us/library/ms537512(v=vs.85).aspx#syntax -					if bytes.HasPrefix(t.Data, []byte("<!--[if ")) && bytes.HasSuffix(t.Data, []byte("<![endif]-->")) { // downlevel-hidden -						begin := bytes.IndexByte(t.Data, '>') + 1 -						end := len(t.Data) - len("<![endif]-->") -						if begin < end { -							w.Write(t.Data[:begin]) -							if err := o.Minify(m, w, buffer.NewReader(t.Data[begin:end]), nil); err != nil { -								return minify.UpdateErrorPosition(err, z, t.Offset) -							} -							w.Write(t.Data[end:]) -						} else { -							w.Write(t.Data) // malformed -						} -					} else { -						w.Write(t.Data) // downlevel-revealed or short downlevel-hidden -					} -				} else if 1 < len(t.Text) && t.Text[0] == '#' { -					// SSI tags -					w.Write(t.Data) -				} -			} -		case html.SvgToken: -			if err := m.MinifyMimetype(svgMimeBytes, w, buffer.NewReader(t.Data), inlineParams); err != nil { -				if err != minify.ErrNotExist { -					return minify.UpdateErrorPosition(err, z, t.Offset) -				} -				w.Write(t.Data) -			} -			omitSpace = false -		case html.MathToken: -			if err := m.MinifyMimetype(mathMimeBytes, w, buffer.NewReader(t.Data), nil); err != nil { -				if err != minify.ErrNotExist { -					return minify.UpdateErrorPosition(err, z, t.Offset) -				} -				w.Write(t.Data) -			} -			omitSpace = false -		case html.TextToken: -			if t.HasTemplate { -				w.Write(t.Data) -				omitSpace = parse.IsWhitespace(t.Data[len(t.Data)-1]) -			} else if rawTagHash != 0 { -				if rawTagHash == Style || rawTagHash == Script || rawTagHash == Iframe { -					var mimetype []byte -					var params map[string]string -					if rawTagHash == Iframe { -						mimetype = htmlMimeBytes -					} else if 0 < len(rawTagMediatype) { -						mimetype, params = parse.Mediatype(rawTagMediatype) -					} else if rawTagHash == Script { -						mimetype = jsMimeBytes -					} else if rawTagHash == Style { -						mimetype = cssMimeBytes -					} -					if err := m.MinifyMimetype(mimetype, w, buffer.NewReader(t.Data), params); err != nil { -						if err != minify.ErrNotExist { -							return minify.UpdateErrorPosition(err, z, t.Offset) -						} -						w.Write(t.Data) -					} -				} else { -					w.Write(t.Data) -				} -			} else if inPre { -				w.Write(t.Data) -				// omitSpace = true after block element -			} else { -				t.Data = parse.ReplaceMultipleWhitespaceAndEntities(t.Data, EntitiesMap, TextRevEntitiesMap) - -				// whitespace removal; trim left -				if omitSpace && parse.IsWhitespace(t.Data[0]) { -					t.Data = t.Data[1:] -				} - -				// whitespace removal; trim right -				omitSpace = false -				if len(t.Data) == 0 { -					omitSpace = true -				} else if parse.IsWhitespace(t.Data[len(t.Data)-1]) { -					omitSpace = true -					i := 0 -					for { -						next := tb.Peek(i) -						// trim if EOF, text token with leading whitespace or block token -						if next.TokenType == html.ErrorToken { -							t.Data = t.Data[:len(t.Data)-1] -							omitSpace = false -							break -						} else if next.TokenType == html.TextToken && !parse.IsAllWhitespace(next.Data) { -							// stop looking when text encountered -							break -						} else if next.TokenType == html.StartTagToken || next.TokenType == html.EndTagToken || next.TokenType == html.SvgToken || next.TokenType == html.MathToken { -							if o.KeepWhitespace { -								break -							} -							// remove when followed by a block tag -							if next.Traits&blockTag != 0 { -								t.Data = t.Data[:len(t.Data)-1] -								omitSpace = false -								break -							} else if next.TokenType == html.StartTagToken || next.TokenType == html.SvgToken || next.TokenType == html.MathToken { -								break -							} -						} -						i++ -					} -				} - -				w.Write(t.Data) -			} -		case html.StartTagToken, html.EndTagToken: -			rawTagHash = 0 -			hasAttributes := false -			if t.TokenType == html.StartTagToken { -				if next := tb.Peek(0); next.TokenType == html.AttributeToken { -					hasAttributes = true -				} -				if t.Traits&rawTag != 0 { -					// ignore empty script and style tags -					if !hasAttributes && (t.Hash == Script || t.Hash == Style) { -						if next := tb.Peek(1); next.TokenType == html.EndTagToken { -							tb.Shift() -							tb.Shift() -							break -						} -					} -					rawTagHash = t.Hash -					rawTagMediatype = nil - -					// do not minify content of <style amp-boilerplate> -					if hasAttributes && t.Hash == Style { -						if attrs := tb.Attributes(Amp_Boilerplate); attrs[0] != nil { -							rawTagHash = 0 -						} -					} -				} -			} else if t.Hash == Template { -				omitSpace = true // EndTagToken -			} - -			if t.Hash == Pre { -				inPre = t.TokenType == html.StartTagToken -			} - -			// remove superfluous tags, except for html, head and body tags when KeepDocumentTags is set -			if !hasAttributes && (!o.KeepDocumentTags && (t.Hash == Html || t.Hash == Head || t.Hash == Body) || t.Hash == Colgroup) { -				break -			} else if t.TokenType == html.EndTagToken { -				omitEndTag := false -				if !o.KeepEndTags { -					if t.Hash == Thead || t.Hash == Tbody || t.Hash == Tfoot || t.Hash == Tr || t.Hash == Th || -						t.Hash == Td || t.Hash == Option || t.Hash == Dd || t.Hash == Dt || t.Hash == Li || -						t.Hash == Rb || t.Hash == Rt || t.Hash == Rtc || t.Hash == Rp { -						omitEndTag = true // omit end tags -					} else if t.Hash == P { -						i := 0 -						for { -							next := tb.Peek(i) -							i++ -							// continue if text token is empty or whitespace -							if next.TokenType == html.TextToken && parse.IsAllWhitespace(next.Data) { -								continue -							} -							if next.TokenType == html.ErrorToken || next.TokenType == html.EndTagToken && next.Traits&keepPTag == 0 || next.TokenType == html.StartTagToken && next.Traits&omitPTag != 0 { -								omitEndTag = true // omit p end tag -							} -							break -						} -					} else if t.Hash == Optgroup { -						i := 0 -						for { -							next := tb.Peek(i) -							i++ -							// continue if text token -							if next.TokenType == html.TextToken { -								continue -							} -							if next.TokenType == html.ErrorToken || next.Hash != Option { -								omitEndTag = true // omit optgroup end tag -							} -							break -						} -					} -				} - -				if !omitEndTag { -					if o.KeepWhitespace || t.Traits&objectTag != 0 { -						omitSpace = false -					} else if t.Traits&blockTag != 0 { -						omitSpace = true // omit spaces after block elements -					} - -					if 3+len(t.Text) < len(t.Data) { -						t.Data[2+len(t.Text)] = '>' -						t.Data = t.Data[:3+len(t.Text)] -					} -					w.Write(t.Data) -				} - -				// skip text in select and optgroup tags -				if t.Hash == Option || t.Hash == Optgroup { -					if next := tb.Peek(0); next.TokenType == html.TextToken && !next.HasTemplate { -						tb.Shift() -					} -				} -				break -			} - -			if o.KeepWhitespace || t.Traits&objectTag != 0 { -				omitSpace = false -			} else if t.Traits&blockTag != 0 { -				omitSpace = true // omit spaces after block elements -			} - -			w.Write(t.Data) - -			if hasAttributes { -				if t.Hash == Meta { -					attrs := tb.Attributes(Content, Http_Equiv, Charset, Name) -					if content := attrs[0]; content != nil { -						if httpEquiv := attrs[1]; httpEquiv != nil { -							httpEquiv.AttrVal = parse.TrimWhitespace(httpEquiv.AttrVal) -							if charset := attrs[2]; charset == nil && parse.EqualFold(httpEquiv.AttrVal, []byte("content-type")) { -								content.AttrVal = minify.Mediatype(content.AttrVal) -								if bytes.Equal(content.AttrVal, []byte("text/html;charset=utf-8")) { -									httpEquiv.Text = nil -									content.Text = []byte("charset") -									content.Hash = Charset -									content.AttrVal = []byte("utf-8") -								} -							} -						} -						if name := attrs[3]; name != nil { -							name.AttrVal = parse.TrimWhitespace(name.AttrVal) -							if parse.EqualFold(name.AttrVal, []byte("keywords")) { -								content.AttrVal = bytes.ReplaceAll(content.AttrVal, []byte(", "), []byte(",")) -							} else if parse.EqualFold(name.AttrVal, []byte("viewport")) { -								content.AttrVal = bytes.ReplaceAll(content.AttrVal, []byte(" "), []byte("")) -								for i := 0; i < len(content.AttrVal); i++ { -									if content.AttrVal[i] == '=' && i+2 < len(content.AttrVal) { -										i++ -										if n := parse.Number(content.AttrVal[i:]); 0 < n { -											minNum := minify.Number(content.AttrVal[i:i+n], -1) -											if len(minNum) < n { -												copy(content.AttrVal[i:i+len(minNum)], minNum) -												copy(content.AttrVal[i+len(minNum):], content.AttrVal[i+n:]) -												content.AttrVal = content.AttrVal[:len(content.AttrVal)+len(minNum)-n] -											} -											i += len(minNum) -										} -										i-- // mitigate for-loop increase -									} -								} -							} -						} -					} -				} else if t.Hash == Script { -					attrs := tb.Attributes(Src, Charset) -					if attrs[0] != nil && attrs[1] != nil { -						attrs[1].Text = nil -					} -				} else if t.Hash == Input { -					attrs := tb.Attributes(Type, Value) -					if t, value := attrs[0], attrs[1]; t != nil && value != nil { -						isRadio := parse.EqualFold(t.AttrVal, radioBytes) -						if !isRadio && len(value.AttrVal) == 0 { -							value.Text = nil -						} else if isRadio && parse.EqualFold(value.AttrVal, onBytes) { -							value.Text = nil -						} -					} -				} else if t.Hash == A { -					attrs := tb.Attributes(Id, Name) -					if id, name := attrs[0], attrs[1]; id != nil && name != nil { -						if bytes.Equal(id.AttrVal, name.AttrVal) { -							name.Text = nil -						} -					} -				} - -				// write attributes -				for { -					attr := *tb.Shift() -					if attr.TokenType != html.AttributeToken { -						break -					} else if attr.Text == nil { -						continue // removed attribute -					} else if attr.HasTemplate { -						w.Write(attr.Data) -						continue // don't minify attributes that contain templates -					} - -					val := attr.AttrVal -					if attr.Traits&trimAttr != 0 { -						val = parse.ReplaceMultipleWhitespaceAndEntities(val, EntitiesMap, nil) -						val = parse.TrimWhitespace(val) -					} else { -						val = parse.ReplaceEntities(val, EntitiesMap, nil) -					} -					if t.Traits != 0 { -						if len(val) == 0 && (attr.Hash == Class || -							attr.Hash == Dir || -							attr.Hash == Id || -							attr.Hash == Name || -							attr.Hash == Action && t.Hash == Form) { -							continue // omit empty attribute values -						} -						if rawTagHash != 0 && attr.Hash == Type { -							rawTagMediatype = parse.Copy(val) -						} - -						if attr.Hash == Enctype || -							attr.Hash == Formenctype || -							attr.Hash == Accept || -							attr.Hash == Type && (t.Hash == A || t.Hash == Link || t.Hash == Embed || t.Hash == Object || t.Hash == Source || t.Hash == Script) { -							val = minify.Mediatype(val) -						} - -						// default attribute values can be omitted -						if !o.KeepDefaultAttrVals && (attr.Hash == Type && (t.Hash == Script && jsMimetypes[string(parse.ToLower(parse.Copy(val)))] || -							t.Hash == Style && parse.EqualFold(val, cssMimeBytes) || -							t.Hash == Link && parse.EqualFold(val, cssMimeBytes) || -							t.Hash == Input && parse.EqualFold(val, textBytes) || -							t.Hash == Button && parse.EqualFold(val, submitBytes)) || -							attr.Hash == Method && parse.EqualFold(val, getBytes) || -							attr.Hash == Enctype && parse.EqualFold(val, formMimeBytes) || -							attr.Hash == Colspan && bytes.Equal(val, oneBytes) || -							attr.Hash == Rowspan && bytes.Equal(val, oneBytes) || -							attr.Hash == Shape && parse.EqualFold(val, rectBytes) || -							attr.Hash == Span && bytes.Equal(val, oneBytes) || -							attr.Hash == Media && t.Hash == Style && parse.EqualFold(val, allBytes)) { -							continue -						} - -						if attr.Hash == Style { -							// CSS minifier for attribute inline code -							val = parse.TrimWhitespace(val) -							attrMinifyBuffer.Reset() -							if err := m.MinifyMimetype(cssMimeBytes, attrMinifyBuffer, buffer.NewReader(val), inlineParams); err == nil { -								val = attrMinifyBuffer.Bytes() -							} else if err != minify.ErrNotExist { -								return minify.UpdateErrorPosition(err, z, attr.Offset) -							} -							if len(val) == 0 { -								continue -							} -						} else if 2 < len(attr.Text) && attr.Text[0] == 'o' && attr.Text[1] == 'n' { -							// JS minifier for attribute inline code -							val = parse.TrimWhitespace(val) -							if 11 <= len(val) && parse.EqualFold(val[:11], jsSchemeBytes) { -								val = val[11:] -							} -							attrMinifyBuffer.Reset() -							if err := m.MinifyMimetype(jsMimeBytes, attrMinifyBuffer, buffer.NewReader(val), inlineParams); err == nil { -								val = attrMinifyBuffer.Bytes() -							} else if err != minify.ErrNotExist { -								return minify.UpdateErrorPosition(err, z, attr.Offset) -							} -							if len(val) == 0 { -								continue -							} -						} else if attr.Traits&urlAttr != 0 { // anchors are already handled -							val = parse.TrimWhitespace(val) -							if 5 < len(val) { -								if parse.EqualFold(val[:4], httpBytes) { -									if val[4] == ':' { -										if m.URL != nil && m.URL.Scheme == "http" { -											val = val[5:] -										} else { -											parse.ToLower(val[:4]) -										} -									} else if (val[4] == 's' || val[4] == 'S') && val[5] == ':' { -										if m.URL != nil && m.URL.Scheme == "https" { -											val = val[6:] -										} else { -											parse.ToLower(val[:5]) -										} -									} -								} else if parse.EqualFold(val[:5], dataSchemeBytes) { -									val = minify.DataURI(m, val) -								} -							} -						} -					} - -					w.Write(spaceBytes) -					w.Write(attr.Text) -					if 0 < len(val) && attr.Traits&booleanAttr == 0 { -						w.Write(isBytes) - -						// use double quotes for RDFa attributes -						isXML := attr.Hash == Vocab || attr.Hash == Typeof || attr.Hash == Property || attr.Hash == Resource || attr.Hash == Prefix || attr.Hash == Content || attr.Hash == About || attr.Hash == Rev || attr.Hash == Datatype || attr.Hash == Inlist - -						// no quotes if possible, else prefer single or double depending on which occurs more often in value -						var quote byte - -						if 0 < len(attr.Data) && (attr.Data[len(attr.Data)-1] == '\'' || attr.Data[len(attr.Data)-1] == '"') { -							quote = attr.Data[len(attr.Data)-1] -						} -						val = html.EscapeAttrVal(&attrByteBuffer, val, quote, o.KeepQuotes || isXML) -						w.Write(val) -					} -				} -			} else { -				_ = tb.Shift() // StartTagClose -			} -			w.Write(gtBytes) - -			// skip text in select and optgroup tags -			if t.Hash == Select || t.Hash == Optgroup { -				if next := tb.Peek(0); next.TokenType == html.TextToken && !next.HasTemplate { -					tb.Shift() -				} -			} - -			// keep space after phrasing tags (<i>, <span>, ...) FontAwesome etc. -			if t.TokenType == html.StartTagToken && t.Traits == normalTag { -				if next := tb.Peek(0); next.Hash == t.Hash && next.TokenType == html.EndTagToken { -					omitSpace = false -				} -			} -		} -	} -} diff --git a/vendor/github.com/tdewolff/minify/v2/html/table.go b/vendor/github.com/tdewolff/minify/v2/html/table.go deleted file mode 100644 index 72380a98e..000000000 --- a/vendor/github.com/tdewolff/minify/v2/html/table.go +++ /dev/null @@ -1,1389 +0,0 @@ -package html - -type traits uint16 - -const ( -	normalTag traits = 1 << iota -	rawTag           // raw tags need special processing for their content -	blockTag         // remove spaces around these tags -	objectTag        // keep spaces after these open/close tags -	omitPTag         // omit p end tag if it is followed by this start tag -	keepPTag         // keep p end tag if it is followed by this end tag -) - -const ( -	booleanAttr traits = 1 << iota -	urlAttr -	trimAttr -) - -var tagMap = map[Hash]traits{ -	A:          keepPTag, -	Abbr:       normalTag, -	Address:    blockTag | omitPTag, -	Area:       normalTag, -	Article:    blockTag | omitPTag, -	Aside:      blockTag | omitPTag, -	Audio:      keepPTag, -	B:          normalTag, -	Base:       normalTag, -	Bb:         normalTag, -	Bdi:        normalTag, -	Bdo:        normalTag, -	Blockquote: blockTag | omitPTag, -	Body:       normalTag, -	Br:         blockTag, -	Button:     objectTag, -	Canvas:     objectTag | keepPTag, -	Caption:    blockTag, -	Cite:       normalTag, -	Code:       normalTag, -	Col:        blockTag, -	Colgroup:   blockTag, -	Data:       normalTag, -	Datalist:   normalTag, // no text content -	Dd:         blockTag, -	Del:        keepPTag, -	Details:    blockTag | omitPTag, -	Dfn:        normalTag, -	Dialog:     normalTag, -	Div:        blockTag | omitPTag, -	Dl:         blockTag | omitPTag, -	Dt:         blockTag, -	Em:         normalTag, -	Embed:      normalTag, -	Fieldset:   blockTag | omitPTag, -	Figcaption: blockTag | omitPTag, -	Figure:     blockTag | omitPTag, -	Footer:     blockTag | omitPTag, -	Form:       blockTag | omitPTag, -	H1:         blockTag | omitPTag, -	H2:         blockTag | omitPTag, -	H3:         blockTag | omitPTag, -	H4:         blockTag | omitPTag, -	H5:         blockTag | omitPTag, -	H6:         blockTag | omitPTag, -	Head:       blockTag, -	Header:     blockTag | omitPTag, -	Hgroup:     blockTag, -	Hr:         blockTag | omitPTag, -	Html:       blockTag, -	I:          normalTag, -	Iframe:     rawTag | objectTag, -	Img:        objectTag, -	Input:      objectTag, -	Ins:        keepPTag, -	Kbd:        normalTag, -	Label:      normalTag | keepPTag, // experimentally, keepPTag is needed -	Legend:     blockTag, -	Li:         blockTag, -	Link:       normalTag, -	Main:       blockTag | omitPTag, -	Map:        keepPTag, -	Mark:       normalTag, -	Math:       rawTag, -	Menu:       blockTag | omitPTag, -	Meta:       normalTag, -	Meter:      objectTag, -	Nav:        blockTag | omitPTag, -	Noscript:   blockTag | keepPTag, -	Object:     objectTag, -	Ol:         blockTag | omitPTag, -	Optgroup:   normalTag, // no text content -	Option:     blockTag, -	Output:     normalTag, -	P:          blockTag | omitPTag, -	Param:      normalTag, -	Picture:    normalTag, -	Pre:        blockTag | omitPTag, -	Progress:   objectTag, -	Q:          objectTag, -	Rp:         normalTag, -	Rt:         objectTag, -	Ruby:       normalTag, -	S:          normalTag, -	Samp:       normalTag, -	Script:     rawTag, -	Section:    blockTag | omitPTag, -	Select:     objectTag, -	Slot:       normalTag, -	Small:      normalTag, -	Source:     normalTag, -	Span:       normalTag, -	Strong:     normalTag, -	Style:      rawTag | blockTag, -	Sub:        normalTag, -	Summary:    blockTag, -	Sup:        normalTag, -	Svg:        rawTag | objectTag, -	Table:      blockTag | omitPTag, -	Tbody:      blockTag, -	Td:         blockTag, -	Template:   normalTag, -	Textarea:   rawTag | objectTag, -	Tfoot:      blockTag, -	Th:         blockTag, -	Thead:      blockTag, -	Time:       normalTag, -	Title:      blockTag, -	Tr:         blockTag, -	Track:      normalTag, -	U:          normalTag, -	Ul:         blockTag | omitPTag, -	Var:        normalTag, -	Video:      objectTag | keepPTag, -	Wbr:        objectTag, - -	// removed tags -	Acronym:   normalTag, -	Applet:    normalTag, -	Basefont:  normalTag, -	Big:       normalTag, -	Center:    blockTag, -	Dir:       blockTag, -	Font:      normalTag, -	Frame:     normalTag, -	Frameset:  normalTag, -	Image:     objectTag, -	Marquee:   blockTag, -	Menuitem:  normalTag, -	Nobr:      normalTag, -	Noembed:   blockTag, -	Noframes:  blockTag, -	Plaintext: normalTag, -	Rtc:       objectTag, -	Rb:        normalTag, -	Strike:    normalTag, -	Tt:        normalTag, -	Xmp:       blockTag, - -	// experimental tags -	Portal: normalTag, -} - -var attrMap = map[Hash]traits{ -	Accept:                   trimAttr, // list of mimetypes -	Accept_Charset:           trimAttr, -	Accesskey:                trimAttr, -	Action:                   urlAttr, -	Allow:                    trimAttr, -	Allowfullscreen:          booleanAttr, -	As:                       trimAttr, -	Async:                    booleanAttr, -	Autocapitalize:           trimAttr, -	Autocomplete:             trimAttr, -	Autofocus:                booleanAttr, -	Autoplay:                 booleanAttr, -	Blocking:                 trimAttr, -	Capture:                  trimAttr, -	Charset:                  trimAttr, -	Checked:                  booleanAttr, -	Cite:                     urlAttr, -	Class:                    trimAttr, -	Color:                    trimAttr, -	Cols:                     trimAttr, // uint bigger than 0 -	Colspan:                  trimAttr, // uint bigger than 0 -	Contenteditable:          trimAttr, -	Controls:                 booleanAttr, -	Coords:                   trimAttr, // list of floats -	Crossorigin:              trimAttr, -	Data:                     urlAttr, -	Datetime:                 trimAttr, -	Decoding:                 trimAttr, -	Default:                  booleanAttr, -	Defer:                    booleanAttr, -	Dir:                      trimAttr, -	Disabled:                 booleanAttr, -	Draggable:                trimAttr, -	Enctype:                  trimAttr, // mimetype -	Enterkeyhint:             trimAttr, -	Fetchpriority:            trimAttr, -	For:                      trimAttr, -	Form:                     trimAttr, -	Formaction:               urlAttr, -	Formenctype:              trimAttr, // mimetype -	Formmethod:               trimAttr, -	Formnovalidate:           booleanAttr, -	Formtarget:               trimAttr, -	Headers:                  trimAttr, -	Height:                   trimAttr, // uint -	Hidden:                   trimAttr, // TODO: boolean -	High:                     trimAttr, // float -	Href:                     urlAttr, -	Hreflang:                 trimAttr, // BCP 47 -	Http_Equiv:               trimAttr, -	Imagesizes:               trimAttr, -	Imagesrcset:              trimAttr, -	Inert:                    booleanAttr, -	Inputmode:                trimAttr, -	Is:                       trimAttr, -	Ismap:                    booleanAttr, -	Itemid:                   urlAttr, -	Itemprop:                 trimAttr, -	Itemref:                  trimAttr, -	Itemscope:                booleanAttr, -	Itemtype:                 trimAttr, // list of urls -	Kind:                     trimAttr, -	Lang:                     trimAttr, // BCP 47 -	List:                     trimAttr, -	Loading:                  trimAttr, -	Loop:                     booleanAttr, -	Low:                      trimAttr, // float -	Max:                      trimAttr, // float or varies -	Maxlength:                trimAttr, // uint -	Media:                    trimAttr, -	Method:                   trimAttr, -	Min:                      trimAttr, // float or varies -	Minlength:                trimAttr, // uint -	Multiple:                 booleanAttr, -	Muted:                    booleanAttr, -	Nomodule:                 booleanAttr, -	Novalidate:               booleanAttr, -	Open:                     booleanAttr, -	Optimum:                  trimAttr, // float -	Pattern:                  trimAttr, // regex -	Ping:                     trimAttr, // list of urls -	Playsinline:              booleanAttr, -	Popover:                  trimAttr, -	Popovertarget:            trimAttr, -	Popovertargetaction:      trimAttr, -	Poster:                   urlAttr, -	Preload:                  trimAttr, -	Profile:                  urlAttr, -	Readonly:                 booleanAttr, -	Referrerpolicy:           trimAttr, -	Rel:                      trimAttr, -	Required:                 booleanAttr, -	Reversed:                 booleanAttr, -	Rows:                     trimAttr, // uint bigger than 0 -	Rowspan:                  trimAttr, // uint -	Sandbox:                  trimAttr, -	Scope:                    trimAttr, -	Selected:                 booleanAttr, -	Shadowrootmode:           trimAttr, -	Shadowrootdelegatesfocus: booleanAttr, -	Shape:                    trimAttr, -	Size:                     trimAttr, // uint bigger than 0 -	Sizes:                    trimAttr, -	Span:                     trimAttr, // uint bigger than 0 -	Spellcheck:               trimAttr, -	Src:                      urlAttr, -	Srclang:                  trimAttr, // BCP 47 -	Srcset:                   trimAttr, -	Start:                    trimAttr, // int -	Step:                     trimAttr, // float or "any" -	Tabindex:                 trimAttr, // int -	Target:                   trimAttr, -	Translate:                trimAttr, -	Type:                     trimAttr, -	Usemap:                   trimAttr, -	Width:                    trimAttr, // uint -	Wrap:                     trimAttr, -	Xmlns:                    urlAttr, -} - -var jsMimetypes = map[string]bool{ -	"text/javascript":        true, -	"application/javascript": true, -} - -// EntitiesMap are all named character entities. -var EntitiesMap = map[string][]byte{ -	"AElig":                           []byte("Æ"), -	"AMP":                             []byte("&"), -	"Aacute":                          []byte("Á"), -	"Abreve":                          []byte("Ă"), -	"Acirc":                           []byte("Â"), -	"Agrave":                          []byte("À"), -	"Alpha":                           []byte("Α"), -	"Amacr":                           []byte("Ā"), -	"Aogon":                           []byte("Ą"), -	"ApplyFunction":                   []byte("⁡"), -	"Aring":                           []byte("Å"), -	"Assign":                          []byte("≔"), -	"Atilde":                          []byte("Ã"), -	"Backslash":                       []byte("∖"), -	"Barwed":                          []byte("⌆"), -	"Because":                         []byte("∵"), -	"Bernoullis":                      []byte("ℬ"), -	"Breve":                           []byte("˘"), -	"Bumpeq":                          []byte("≎"), -	"Cacute":                          []byte("Ć"), -	"CapitalDifferentialD":            []byte("ⅅ"), -	"Cayleys":                         []byte("ℭ"), -	"Ccaron":                          []byte("Č"), -	"Ccedil":                          []byte("Ç"), -	"Ccirc":                           []byte("Ĉ"), -	"Cconint":                         []byte("∰"), -	"Cedilla":                         []byte("¸"), -	"CenterDot":                       []byte("·"), -	"CircleDot":                       []byte("⊙"), -	"CircleMinus":                     []byte("⊖"), -	"CirclePlus":                      []byte("⊕"), -	"CircleTimes":                     []byte("⊗"), -	"ClockwiseContourIntegral":        []byte("∲"), -	"CloseCurlyDoubleQuote":           []byte("”"), -	"CloseCurlyQuote":                 []byte("’"), -	"Congruent":                       []byte("≡"), -	"Conint":                          []byte("∯"), -	"ContourIntegral":                 []byte("∮"), -	"Coproduct":                       []byte("∐"), -	"CounterClockwiseContourIntegral": []byte("∳"), -	"CupCap":                          []byte("≍"), -	"DDotrahd":                        []byte("⤑"), -	"Dagger":                          []byte("‡"), -	"Dcaron":                          []byte("Ď"), -	"Delta":                           []byte("Δ"), -	"DiacriticalAcute":                []byte("´"), -	"DiacriticalDot":                  []byte("˙"), -	"DiacriticalDoubleAcute":          []byte("˝"), -	"DiacriticalGrave":                []byte("`"), -	"DiacriticalTilde":                []byte("˜"), -	"Diamond":                         []byte("⋄"), -	"DifferentialD":                   []byte("ⅆ"), -	"DotDot":                          []byte("⃜"), -	"DotEqual":                        []byte("≐"), -	"DoubleContourIntegral":           []byte("∯"), -	"DoubleDot":                       []byte("¨"), -	"DoubleDownArrow":                 []byte("⇓"), -	"DoubleLeftArrow":                 []byte("⇐"), -	"DoubleLeftRightArrow":            []byte("⇔"), -	"DoubleLeftTee":                   []byte("⫤"), -	"DoubleLongLeftArrow":             []byte("⟸"), -	"DoubleLongLeftRightArrow":        []byte("⟺"), -	"DoubleLongRightArrow":            []byte("⟹"), -	"DoubleRightArrow":                []byte("⇒"), -	"DoubleRightTee":                  []byte("⊨"), -	"DoubleUpArrow":                   []byte("⇑"), -	"DoubleUpDownArrow":               []byte("⇕"), -	"DoubleVerticalBar":               []byte("∥"), -	"DownArrow":                       []byte("↓"), -	"DownArrowBar":                    []byte("⤓"), -	"DownArrowUpArrow":                []byte("⇵"), -	"DownBreve":                       []byte("̑"), -	"DownLeftRightVector":             []byte("⥐"), -	"DownLeftTeeVector":               []byte("⥞"), -	"DownLeftVector":                  []byte("↽"), -	"DownLeftVectorBar":               []byte("⥖"), -	"DownRightTeeVector":              []byte("⥟"), -	"DownRightVector":                 []byte("⇁"), -	"DownRightVectorBar":              []byte("⥗"), -	"DownTee":                         []byte("⊤"), -	"DownTeeArrow":                    []byte("↧"), -	"Downarrow":                       []byte("⇓"), -	"Dstrok":                          []byte("Đ"), -	"Eacute":                          []byte("É"), -	"Ecaron":                          []byte("Ě"), -	"Ecirc":                           []byte("Ê"), -	"Egrave":                          []byte("È"), -	"Element":                         []byte("∈"), -	"Emacr":                           []byte("Ē"), -	"EmptySmallSquare":                []byte("◻"), -	"EmptyVerySmallSquare":            []byte("▫"), -	"Eogon":                           []byte("Ę"), -	"Epsilon":                         []byte("Ε"), -	"EqualTilde":                      []byte("≂"), -	"Equilibrium":                     []byte("⇌"), -	"Exists":                          []byte("∃"), -	"ExponentialE":                    []byte("ⅇ"), -	"FilledSmallSquare":               []byte("◼"), -	"FilledVerySmallSquare":           []byte("▪"), -	"ForAll":                          []byte("∀"), -	"Fouriertrf":                      []byte("ℱ"), -	"GT":                              []byte(">"), -	"Gamma":                           []byte("Γ"), -	"Gammad":                          []byte("Ϝ"), -	"Gbreve":                          []byte("Ğ"), -	"Gcedil":                          []byte("Ģ"), -	"Gcirc":                           []byte("Ĝ"), -	"GreaterEqual":                    []byte("≥"), -	"GreaterEqualLess":                []byte("⋛"), -	"GreaterFullEqual":                []byte("≧"), -	"GreaterGreater":                  []byte("⪢"), -	"GreaterLess":                     []byte("≷"), -	"GreaterSlantEqual":               []byte("⩾"), -	"GreaterTilde":                    []byte("≳"), -	"HARDcy":                          []byte("Ъ"), -	"Hacek":                           []byte("ˇ"), -	"Hat":                             []byte("^"), -	"Hcirc":                           []byte("Ĥ"), -	"HilbertSpace":                    []byte("ℋ"), -	"HorizontalLine":                  []byte("─"), -	"Hstrok":                          []byte("Ħ"), -	"HumpDownHump":                    []byte("≎"), -	"HumpEqual":                       []byte("≏"), -	"IJlig":                           []byte("IJ"), -	"Iacute":                          []byte("Í"), -	"Icirc":                           []byte("Î"), -	"Ifr":                             []byte("ℑ"), -	"Igrave":                          []byte("Ì"), -	"Imacr":                           []byte("Ī"), -	"ImaginaryI":                      []byte("ⅈ"), -	"Implies":                         []byte("⇒"), -	"Integral":                        []byte("∫"), -	"Intersection":                    []byte("⋂"), -	"InvisibleComma":                  []byte("⁣"), -	"InvisibleTimes":                  []byte("⁢"), -	"Iogon":                           []byte("Į"), -	"Itilde":                          []byte("Ĩ"), -	"Jcirc":                           []byte("Ĵ"), -	"Jsercy":                          []byte("Ј"), -	"Kappa":                           []byte("Κ"), -	"Kcedil":                          []byte("Ķ"), -	"LT":                              []byte("<"), -	"Lacute":                          []byte("Ĺ"), -	"Lambda":                          []byte("Λ"), -	"Laplacetrf":                      []byte("ℒ"), -	"Lcaron":                          []byte("Ľ"), -	"Lcedil":                          []byte("Ļ"), -	"LeftAngleBracket":                []byte("⟨"), -	"LeftArrow":                       []byte("←"), -	"LeftArrowBar":                    []byte("⇤"), -	"LeftArrowRightArrow":             []byte("⇆"), -	"LeftCeiling":                     []byte("⌈"), -	"LeftDoubleBracket":               []byte("⟦"), -	"LeftDownTeeVector":               []byte("⥡"), -	"LeftDownVector":                  []byte("⇃"), -	"LeftDownVectorBar":               []byte("⥙"), -	"LeftFloor":                       []byte("⌊"), -	"LeftRightArrow":                  []byte("↔"), -	"LeftRightVector":                 []byte("⥎"), -	"LeftTee":                         []byte("⊣"), -	"LeftTeeArrow":                    []byte("↤"), -	"LeftTeeVector":                   []byte("⥚"), -	"LeftTriangle":                    []byte("⊲"), -	"LeftTriangleBar":                 []byte("⧏"), -	"LeftTriangleEqual":               []byte("⊴"), -	"LeftUpDownVector":                []byte("⥑"), -	"LeftUpTeeVector":                 []byte("⥠"), -	"LeftUpVector":                    []byte("↿"), -	"LeftUpVectorBar":                 []byte("⥘"), -	"LeftVector":                      []byte("↼"), -	"LeftVectorBar":                   []byte("⥒"), -	"Leftarrow":                       []byte("⇐"), -	"Leftrightarrow":                  []byte("⇔"), -	"LessEqualGreater":                []byte("⋚"), -	"LessFullEqual":                   []byte("≦"), -	"LessGreater":                     []byte("≶"), -	"LessLess":                        []byte("⪡"), -	"LessSlantEqual":                  []byte("⩽"), -	"LessTilde":                       []byte("≲"), -	"Lleftarrow":                      []byte("⇚"), -	"Lmidot":                          []byte("Ŀ"), -	"LongLeftArrow":                   []byte("⟵"), -	"LongLeftRightArrow":              []byte("⟷"), -	"LongRightArrow":                  []byte("⟶"), -	"Longleftarrow":                   []byte("⟸"), -	"Longleftrightarrow":              []byte("⟺"), -	"Longrightarrow":                  []byte("⟹"), -	"LowerLeftArrow":                  []byte("↙"), -	"LowerRightArrow":                 []byte("↘"), -	"Lstrok":                          []byte("Ł"), -	"MediumSpace":                     []byte(" "), -	"Mellintrf":                       []byte("ℳ"), -	"MinusPlus":                       []byte("∓"), -	"Nacute":                          []byte("Ń"), -	"Ncaron":                          []byte("Ň"), -	"Ncedil":                          []byte("Ņ"), -	"NegativeMediumSpace":             []byte("​"), -	"NegativeThickSpace":              []byte("​"), -	"NegativeThinSpace":               []byte("​"), -	"NegativeVeryThinSpace":           []byte("​"), -	"NestedGreaterGreater":            []byte("≫"), -	"NestedLessLess":                  []byte("≪"), -	"NewLine":                         []byte("\n"), -	"NoBreak":                         []byte("⁠"), -	"NonBreakingSpace":                []byte(" "), -	"NotCongruent":                    []byte("≢"), -	"NotCupCap":                       []byte("≭"), -	"NotDoubleVerticalBar":            []byte("∦"), -	"NotElement":                      []byte("∉"), -	"NotEqual":                        []byte("≠"), -	"NotExists":                       []byte("∄"), -	"NotGreater":                      []byte("≯"), -	"NotGreaterEqual":                 []byte("≱"), -	"NotGreaterLess":                  []byte("≹"), -	"NotGreaterTilde":                 []byte("≵"), -	"NotLeftTriangle":                 []byte("⋪"), -	"NotLeftTriangleEqual":            []byte("⋬"), -	"NotLess":                         []byte("≮"), -	"NotLessEqual":                    []byte("≰"), -	"NotLessGreater":                  []byte("≸"), -	"NotLessTilde":                    []byte("≴"), -	"NotPrecedes":                     []byte("⊀"), -	"NotPrecedesSlantEqual":           []byte("⋠"), -	"NotReverseElement":               []byte("∌"), -	"NotRightTriangle":                []byte("⋫"), -	"NotRightTriangleEqual":           []byte("⋭"), -	"NotSquareSubsetEqual":            []byte("⋢"), -	"NotSquareSupersetEqual":          []byte("⋣"), -	"NotSubsetEqual":                  []byte("⊈"), -	"NotSucceeds":                     []byte("⊁"), -	"NotSucceedsSlantEqual":           []byte("⋡"), -	"NotSupersetEqual":                []byte("⊉"), -	"NotTilde":                        []byte("≁"), -	"NotTildeEqual":                   []byte("≄"), -	"NotTildeFullEqual":               []byte("≇"), -	"NotTildeTilde":                   []byte("≉"), -	"NotVerticalBar":                  []byte("∤"), -	"Ntilde":                          []byte("Ñ"), -	"OElig":                           []byte("Œ"), -	"Oacute":                          []byte("Ó"), -	"Ocirc":                           []byte("Ô"), -	"Odblac":                          []byte("Ő"), -	"Ograve":                          []byte("Ò"), -	"Omacr":                           []byte("Ō"), -	"Omega":                           []byte("Ω"), -	"Omicron":                         []byte("Ο"), -	"OpenCurlyDoubleQuote":            []byte("“"), -	"OpenCurlyQuote":                  []byte("‘"), -	"Oslash":                          []byte("Ø"), -	"Otilde":                          []byte("Õ"), -	"OverBar":                         []byte("‾"), -	"OverBrace":                       []byte("⏞"), -	"OverBracket":                     []byte("⎴"), -	"OverParenthesis":                 []byte("⏜"), -	"PartialD":                        []byte("∂"), -	"PlusMinus":                       []byte("±"), -	"Poincareplane":                   []byte("ℌ"), -	"Precedes":                        []byte("≺"), -	"PrecedesEqual":                   []byte("⪯"), -	"PrecedesSlantEqual":              []byte("≼"), -	"PrecedesTilde":                   []byte("≾"), -	"Product":                         []byte("∏"), -	"Proportion":                      []byte("∷"), -	"Proportional":                    []byte("∝"), -	"QUOT":                            []byte("\""), -	"Racute":                          []byte("Ŕ"), -	"Rcaron":                          []byte("Ř"), -	"Rcedil":                          []byte("Ŗ"), -	"ReverseElement":                  []byte("∋"), -	"ReverseEquilibrium":              []byte("⇋"), -	"ReverseUpEquilibrium":            []byte("⥯"), -	"Rfr":                             []byte("ℜ"), -	"RightAngleBracket":               []byte("⟩"), -	"RightArrow":                      []byte("→"), -	"RightArrowBar":                   []byte("⇥"), -	"RightArrowLeftArrow":             []byte("⇄"), -	"RightCeiling":                    []byte("⌉"), -	"RightDoubleBracket":              []byte("⟧"), -	"RightDownTeeVector":              []byte("⥝"), -	"RightDownVector":                 []byte("⇂"), -	"RightDownVectorBar":              []byte("⥕"), -	"RightFloor":                      []byte("⌋"), -	"RightTee":                        []byte("⊢"), -	"RightTeeArrow":                   []byte("↦"), -	"RightTeeVector":                  []byte("⥛"), -	"RightTriangle":                   []byte("⊳"), -	"RightTriangleBar":                []byte("⧐"), -	"RightTriangleEqual":              []byte("⊵"), -	"RightUpDownVector":               []byte("⥏"), -	"RightUpTeeVector":                []byte("⥜"), -	"RightUpVector":                   []byte("↾"), -	"RightUpVectorBar":                []byte("⥔"), -	"RightVector":                     []byte("⇀"), -	"RightVectorBar":                  []byte("⥓"), -	"Rightarrow":                      []byte("⇒"), -	"RoundImplies":                    []byte("⥰"), -	"Rrightarrow":                     []byte("⇛"), -	"RuleDelayed":                     []byte("⧴"), -	"SHCHcy":                          []byte("Щ"), -	"SOFTcy":                          []byte("Ь"), -	"Sacute":                          []byte("Ś"), -	"Scaron":                          []byte("Š"), -	"Scedil":                          []byte("Ş"), -	"Scirc":                           []byte("Ŝ"), -	"ShortDownArrow":                  []byte("↓"), -	"ShortLeftArrow":                  []byte("←"), -	"ShortRightArrow":                 []byte("→"), -	"ShortUpArrow":                    []byte("↑"), -	"Sigma":                           []byte("Σ"), -	"SmallCircle":                     []byte("∘"), -	"Square":                          []byte("□"), -	"SquareIntersection":              []byte("⊓"), -	"SquareSubset":                    []byte("⊏"), -	"SquareSubsetEqual":               []byte("⊑"), -	"SquareSuperset":                  []byte("⊐"), -	"SquareSupersetEqual":             []byte("⊒"), -	"SquareUnion":                     []byte("⊔"), -	"Subset":                          []byte("⋐"), -	"SubsetEqual":                     []byte("⊆"), -	"Succeeds":                        []byte("≻"), -	"SucceedsEqual":                   []byte("⪰"), -	"SucceedsSlantEqual":              []byte("≽"), -	"SucceedsTilde":                   []byte("≿"), -	"SuchThat":                        []byte("∋"), -	"Superset":                        []byte("⊃"), -	"SupersetEqual":                   []byte("⊇"), -	"Supset":                          []byte("⋑"), -	"THORN":                           []byte("Þ"), -	"Tab":                             []byte("\t"), -	"Tcaron":                          []byte("Ť"), -	"Tcedil":                          []byte("Ţ"), -	"Therefore":                       []byte("∴"), -	"Theta":                           []byte("Θ"), -	"ThinSpace":                       []byte(" "), -	"Tilde":                           []byte("∼"), -	"TildeEqual":                      []byte("≃"), -	"TildeFullEqual":                  []byte("≅"), -	"TildeTilde":                      []byte("≈"), -	"TripleDot":                       []byte("⃛"), -	"Tstrok":                          []byte("Ŧ"), -	"Uacute":                          []byte("Ú"), -	"Uarrocir":                        []byte("⥉"), -	"Ubreve":                          []byte("Ŭ"), -	"Ucirc":                           []byte("Û"), -	"Udblac":                          []byte("Ű"), -	"Ugrave":                          []byte("Ù"), -	"Umacr":                           []byte("Ū"), -	"UnderBar":                        []byte("_"), -	"UnderBrace":                      []byte("⏟"), -	"UnderBracket":                    []byte("⎵"), -	"UnderParenthesis":                []byte("⏝"), -	"Union":                           []byte("⋃"), -	"UnionPlus":                       []byte("⊎"), -	"Uogon":                           []byte("Ų"), -	"UpArrow":                         []byte("↑"), -	"UpArrowBar":                      []byte("⤒"), -	"UpArrowDownArrow":                []byte("⇅"), -	"UpDownArrow":                     []byte("↕"), -	"UpEquilibrium":                   []byte("⥮"), -	"UpTee":                           []byte("⊥"), -	"UpTeeArrow":                      []byte("↥"), -	"Uparrow":                         []byte("⇑"), -	"Updownarrow":                     []byte("⇕"), -	"UpperLeftArrow":                  []byte("↖"), -	"UpperRightArrow":                 []byte("↗"), -	"Upsilon":                         []byte("Υ"), -	"Uring":                           []byte("Ů"), -	"Utilde":                          []byte("Ũ"), -	"Verbar":                          []byte("‖"), -	"VerticalBar":                     []byte("∣"), -	"VerticalLine":                    []byte("|"), -	"VerticalSeparator":               []byte("❘"), -	"VerticalTilde":                   []byte("≀"), -	"VeryThinSpace":                   []byte(" "), -	"Vvdash":                          []byte("⊪"), -	"Wcirc":                           []byte("Ŵ"), -	"Yacute":                          []byte("Ý"), -	"Ycirc":                           []byte("Ŷ"), -	"Zacute":                          []byte("Ź"), -	"Zcaron":                          []byte("Ž"), -	"ZeroWidthSpace":                  []byte("​"), -	"aacute":                          []byte("á"), -	"abreve":                          []byte("ă"), -	"acirc":                           []byte("â"), -	"acute":                           []byte("´"), -	"aelig":                           []byte("æ"), -	"agrave":                          []byte("à"), -	"alefsym":                         []byte("ℵ"), -	"alpha":                           []byte("α"), -	"amacr":                           []byte("ā"), -	"amp":                             []byte("&"), -	"andslope":                        []byte("⩘"), -	"angle":                           []byte("∠"), -	"angmsd":                          []byte("∡"), -	"angmsdaa":                        []byte("⦨"), -	"angmsdab":                        []byte("⦩"), -	"angmsdac":                        []byte("⦪"), -	"angmsdad":                        []byte("⦫"), -	"angmsdae":                        []byte("⦬"), -	"angmsdaf":                        []byte("⦭"), -	"angmsdag":                        []byte("⦮"), -	"angmsdah":                        []byte("⦯"), -	"angrtvb":                         []byte("⊾"), -	"angrtvbd":                        []byte("⦝"), -	"angsph":                          []byte("∢"), -	"angst":                           []byte("Å"), -	"angzarr":                         []byte("⍼"), -	"aogon":                           []byte("ą"), -	"apos":                            []byte("'"), -	"approx":                          []byte("≈"), -	"approxeq":                        []byte("≊"), -	"aring":                           []byte("å"), -	"ast":                             []byte("*"), -	"asymp":                           []byte("≈"), -	"asympeq":                         []byte("≍"), -	"atilde":                          []byte("ã"), -	"awconint":                        []byte("∳"), -	"backcong":                        []byte("≌"), -	"backepsilon":                     []byte("϶"), -	"backprime":                       []byte("‵"), -	"backsim":                         []byte("∽"), -	"backsimeq":                       []byte("⋍"), -	"barvee":                          []byte("⊽"), -	"barwed":                          []byte("⌅"), -	"barwedge":                        []byte("⌅"), -	"bbrktbrk":                        []byte("⎶"), -	"becaus":                          []byte("∵"), -	"because":                         []byte("∵"), -	"bemptyv":                         []byte("⦰"), -	"bernou":                          []byte("ℬ"), -	"between":                         []byte("≬"), -	"bigcap":                          []byte("⋂"), -	"bigcirc":                         []byte("◯"), -	"bigcup":                          []byte("⋃"), -	"bigodot":                         []byte("⨀"), -	"bigoplus":                        []byte("⨁"), -	"bigotimes":                       []byte("⨂"), -	"bigsqcup":                        []byte("⨆"), -	"bigstar":                         []byte("★"), -	"bigtriangledown":                 []byte("▽"), -	"bigtriangleup":                   []byte("△"), -	"biguplus":                        []byte("⨄"), -	"bigvee":                          []byte("⋁"), -	"bigwedge":                        []byte("⋀"), -	"bkarow":                          []byte("⤍"), -	"blacklozenge":                    []byte("⧫"), -	"blacksquare":                     []byte("▪"), -	"blacktriangle":                   []byte("▴"), -	"blacktriangledown":               []byte("▾"), -	"blacktriangleleft":               []byte("◂"), -	"blacktriangleright":              []byte("▸"), -	"bottom":                          []byte("⊥"), -	"bowtie":                          []byte("⋈"), -	"boxminus":                        []byte("⊟"), -	"boxplus":                         []byte("⊞"), -	"boxtimes":                        []byte("⊠"), -	"bprime":                          []byte("‵"), -	"breve":                           []byte("˘"), -	"brvbar":                          []byte("¦"), -	"bsol":                            []byte("\\"), -	"bsolhsub":                        []byte("⟈"), -	"bullet":                          []byte("•"), -	"bumpeq":                          []byte("≏"), -	"cacute":                          []byte("ć"), -	"capbrcup":                        []byte("⩉"), -	"caron":                           []byte("ˇ"), -	"ccaron":                          []byte("č"), -	"ccedil":                          []byte("ç"), -	"ccirc":                           []byte("ĉ"), -	"ccupssm":                         []byte("⩐"), -	"cedil":                           []byte("¸"), -	"cemptyv":                         []byte("⦲"), -	"centerdot":                       []byte("·"), -	"checkmark":                       []byte("✓"), -	"circeq":                          []byte("≗"), -	"circlearrowleft":                 []byte("↺"), -	"circlearrowright":                []byte("↻"), -	"circledR":                        []byte("®"), -	"circledS":                        []byte("Ⓢ"), -	"circledast":                      []byte("⊛"), -	"circledcirc":                     []byte("⊚"), -	"circleddash":                     []byte("⊝"), -	"cirfnint":                        []byte("⨐"), -	"cirscir":                         []byte("⧂"), -	"clubsuit":                        []byte("♣"), -	"colon":                           []byte(":"), -	"colone":                          []byte("≔"), -	"coloneq":                         []byte("≔"), -	"comma":                           []byte(","), -	"commat":                          []byte("@"), -	"compfn":                          []byte("∘"), -	"complement":                      []byte("∁"), -	"complexes":                       []byte("ℂ"), -	"congdot":                         []byte("⩭"), -	"conint":                          []byte("∮"), -	"coprod":                          []byte("∐"), -	"copysr":                          []byte("℗"), -	"cudarrl":                         []byte("⤸"), -	"cudarrr":                         []byte("⤵"), -	"cularr":                          []byte("↶"), -	"cularrp":                         []byte("⤽"), -	"cupbrcap":                        []byte("⩈"), -	"cupdot":                          []byte("⊍"), -	"curarr":                          []byte("↷"), -	"curarrm":                         []byte("⤼"), -	"curlyeqprec":                     []byte("⋞"), -	"curlyeqsucc":                     []byte("⋟"), -	"curlyvee":                        []byte("⋎"), -	"curlywedge":                      []byte("⋏"), -	"curren":                          []byte("¤"), -	"curvearrowleft":                  []byte("↶"), -	"curvearrowright":                 []byte("↷"), -	"cwconint":                        []byte("∲"), -	"cylcty":                          []byte("⌭"), -	"dagger":                          []byte("†"), -	"daleth":                          []byte("ℸ"), -	"dbkarow":                         []byte("⤏"), -	"dblac":                           []byte("˝"), -	"dcaron":                          []byte("ď"), -	"ddagger":                         []byte("‡"), -	"ddotseq":                         []byte("⩷"), -	"delta":                           []byte("δ"), -	"demptyv":                         []byte("⦱"), -	"diamond":                         []byte("⋄"), -	"diamondsuit":                     []byte("♦"), -	"digamma":                         []byte("ϝ"), -	"divide":                          []byte("÷"), -	"divideontimes":                   []byte("⋇"), -	"divonx":                          []byte("⋇"), -	"dlcorn":                          []byte("⌞"), -	"dlcrop":                          []byte("⌍"), -	"dollar":                          []byte("$"), -	"doteqdot":                        []byte("≑"), -	"dotminus":                        []byte("∸"), -	"dotplus":                         []byte("∔"), -	"dotsquare":                       []byte("⊡"), -	"doublebarwedge":                  []byte("⌆"), -	"downarrow":                       []byte("↓"), -	"downdownarrows":                  []byte("⇊"), -	"downharpoonleft":                 []byte("⇃"), -	"downharpoonright":                []byte("⇂"), -	"drbkarow":                        []byte("⤐"), -	"drcorn":                          []byte("⌟"), -	"drcrop":                          []byte("⌌"), -	"dstrok":                          []byte("đ"), -	"dwangle":                         []byte("⦦"), -	"dzigrarr":                        []byte("⟿"), -	"eacute":                          []byte("é"), -	"ecaron":                          []byte("ě"), -	"ecirc":                           []byte("ê"), -	"ecolon":                          []byte("≕"), -	"egrave":                          []byte("è"), -	"elinters":                        []byte("⏧"), -	"emacr":                           []byte("ē"), -	"emptyset":                        []byte("∅"), -	"emptyv":                          []byte("∅"), -	"emsp13":                          []byte(" "), -	"emsp14":                          []byte(" "), -	"eogon":                           []byte("ę"), -	"epsilon":                         []byte("ε"), -	"eqcirc":                          []byte("≖"), -	"eqcolon":                         []byte("≕"), -	"eqsim":                           []byte("≂"), -	"eqslantgtr":                      []byte("⪖"), -	"eqslantless":                     []byte("⪕"), -	"equals":                          []byte("="), -	"equest":                          []byte("≟"), -	"equivDD":                         []byte("⩸"), -	"eqvparsl":                        []byte("⧥"), -	"excl":                            []byte("!"), -	"expectation":                     []byte("ℰ"), -	"exponentiale":                    []byte("ⅇ"), -	"fallingdotseq":                   []byte("≒"), -	"female":                          []byte("♀"), -	"forall":                          []byte("∀"), -	"fpartint":                        []byte("⨍"), -	"frac12":                          []byte("½"), -	"frac13":                          []byte("⅓"), -	"frac14":                          []byte("¼"), -	"frac15":                          []byte("⅕"), -	"frac16":                          []byte("⅙"), -	"frac18":                          []byte("⅛"), -	"frac23":                          []byte("⅔"), -	"frac25":                          []byte("⅖"), -	"frac34":                          []byte("¾"), -	"frac35":                          []byte("⅗"), -	"frac38":                          []byte("⅜"), -	"frac45":                          []byte("⅘"), -	"frac56":                          []byte("⅚"), -	"frac58":                          []byte("⅝"), -	"frac78":                          []byte("⅞"), -	"gacute":                          []byte("ǵ"), -	"gamma":                           []byte("γ"), -	"gammad":                          []byte("ϝ"), -	"gbreve":                          []byte("ğ"), -	"gcirc":                           []byte("ĝ"), -	"geq":                             []byte("≥"), -	"geqq":                            []byte("≧"), -	"geqslant":                        []byte("⩾"), -	"gesdoto":                         []byte("⪂"), -	"gesdotol":                        []byte("⪄"), -	"ggg":                             []byte("⋙"), -	"gnapprox":                        []byte("⪊"), -	"gneq":                            []byte("⪈"), -	"gneqq":                           []byte("≩"), -	"grave":                           []byte("`"), -	"gt":                              []byte(">"), -	"gtquest":                         []byte("⩼"), -	"gtrapprox":                       []byte("⪆"), -	"gtrdot":                          []byte("⋗"), -	"gtreqless":                       []byte("⋛"), -	"gtreqqless":                      []byte("⪌"), -	"gtrless":                         []byte("≷"), -	"gtrsim":                          []byte("≳"), -	"hArr":                            []byte("⇔"), -	"hairsp":                          []byte(" "), -	"hamilt":                          []byte("ℋ"), -	"hardcy":                          []byte("ъ"), -	"harrcir":                         []byte("⥈"), -	"hcirc":                           []byte("ĥ"), -	"hearts":                          []byte("♥"), -	"heartsuit":                       []byte("♥"), -	"hellip":                          []byte("…"), -	"hercon":                          []byte("⊹"), -	"hksearow":                        []byte("⤥"), -	"hkswarow":                        []byte("⤦"), -	"homtht":                          []byte("∻"), -	"hookleftarrow":                   []byte("↩"), -	"hookrightarrow":                  []byte("↪"), -	"horbar":                          []byte("―"), -	"hslash":                          []byte("ℏ"), -	"hstrok":                          []byte("ħ"), -	"hybull":                          []byte("⁃"), -	"hyphen":                          []byte("‐"), -	"iacute":                          []byte("í"), -	"icirc":                           []byte("î"), -	"iexcl":                           []byte("¡"), -	"igrave":                          []byte("ì"), -	"iiiint":                          []byte("⨌"), -	"iiint":                           []byte("∭"), -	"ijlig":                           []byte("ij"), -	"imacr":                           []byte("ī"), -	"image":                           []byte("ℑ"), -	"imagline":                        []byte("ℐ"), -	"imagpart":                        []byte("ℑ"), -	"imath":                           []byte("ı"), -	"imped":                           []byte("Ƶ"), -	"incare":                          []byte("℅"), -	"infintie":                        []byte("⧝"), -	"inodot":                          []byte("ı"), -	"intcal":                          []byte("⊺"), -	"integers":                        []byte("ℤ"), -	"intercal":                        []byte("⊺"), -	"intlarhk":                        []byte("⨗"), -	"intprod":                         []byte("⨼"), -	"iogon":                           []byte("į"), -	"iquest":                          []byte("¿"), -	"isin":                            []byte("∈"), -	"isindot":                         []byte("⋵"), -	"isinsv":                          []byte("⋳"), -	"isinv":                           []byte("∈"), -	"itilde":                          []byte("ĩ"), -	"jcirc":                           []byte("ĵ"), -	"jmath":                           []byte("ȷ"), -	"jsercy":                          []byte("ј"), -	"kappa":                           []byte("κ"), -	"kappav":                          []byte("ϰ"), -	"kcedil":                          []byte("ķ"), -	"kgreen":                          []byte("ĸ"), -	"lacute":                          []byte("ĺ"), -	"laemptyv":                        []byte("⦴"), -	"lagran":                          []byte("ℒ"), -	"lambda":                          []byte("λ"), -	"langle":                          []byte("⟨"), -	"laquo":                           []byte("«"), -	"larrbfs":                         []byte("⤟"), -	"larrhk":                          []byte("↩"), -	"larrlp":                          []byte("↫"), -	"larrsim":                         []byte("⥳"), -	"larrtl":                          []byte("↢"), -	"lbrace":                          []byte("{"), -	"lbrack":                          []byte("["), -	"lbrksld":                         []byte("⦏"), -	"lbrkslu":                         []byte("⦍"), -	"lcaron":                          []byte("ľ"), -	"lcedil":                          []byte("ļ"), -	"lcub":                            []byte("{"), -	"ldquor":                          []byte("„"), -	"ldrdhar":                         []byte("⥧"), -	"ldrushar":                        []byte("⥋"), -	"leftarrow":                       []byte("←"), -	"leftarrowtail":                   []byte("↢"), -	"leftharpoondown":                 []byte("↽"), -	"leftharpoonup":                   []byte("↼"), -	"leftleftarrows":                  []byte("⇇"), -	"leftrightarrow":                  []byte("↔"), -	"leftrightarrows":                 []byte("⇆"), -	"leftrightharpoons":               []byte("⇋"), -	"leftrightsquigarrow":             []byte("↭"), -	"leftthreetimes":                  []byte("⋋"), -	"leq":                             []byte("≤"), -	"leqq":                            []byte("≦"), -	"leqslant":                        []byte("⩽"), -	"lesdoto":                         []byte("⪁"), -	"lesdotor":                        []byte("⪃"), -	"lessapprox":                      []byte("⪅"), -	"lessdot":                         []byte("⋖"), -	"lesseqgtr":                       []byte("⋚"), -	"lesseqqgtr":                      []byte("⪋"), -	"lessgtr":                         []byte("≶"), -	"lesssim":                         []byte("≲"), -	"lfloor":                          []byte("⌊"), -	"llcorner":                        []byte("⌞"), -	"lmidot":                          []byte("ŀ"), -	"lmoust":                          []byte("⎰"), -	"lmoustache":                      []byte("⎰"), -	"lnapprox":                        []byte("⪉"), -	"lneq":                            []byte("⪇"), -	"lneqq":                           []byte("≨"), -	"longleftarrow":                   []byte("⟵"), -	"longleftrightarrow":              []byte("⟷"), -	"longmapsto":                      []byte("⟼"), -	"longrightarrow":                  []byte("⟶"), -	"looparrowleft":                   []byte("↫"), -	"looparrowright":                  []byte("↬"), -	"lotimes":                         []byte("⨴"), -	"lowast":                          []byte("∗"), -	"lowbar":                          []byte("_"), -	"lozenge":                         []byte("◊"), -	"lpar":                            []byte("("), -	"lrcorner":                        []byte("⌟"), -	"lsaquo":                          []byte("‹"), -	"lsqb":                            []byte("["), -	"lsquor":                          []byte("‚"), -	"lstrok":                          []byte("ł"), -	"lt":                              []byte("<"), -	"lthree":                          []byte("⋋"), -	"ltimes":                          []byte("⋉"), -	"ltquest":                         []byte("⩻"), -	"lurdshar":                        []byte("⥊"), -	"luruhar":                         []byte("⥦"), -	"maltese":                         []byte("✠"), -	"mapsto":                          []byte("↦"), -	"mapstodown":                      []byte("↧"), -	"mapstoleft":                      []byte("↤"), -	"mapstoup":                        []byte("↥"), -	"marker":                          []byte("▮"), -	"measuredangle":                   []byte("∡"), -	"micro":                           []byte("µ"), -	"midast":                          []byte("*"), -	"middot":                          []byte("·"), -	"minusb":                          []byte("⊟"), -	"minusd":                          []byte("∸"), -	"minusdu":                         []byte("⨪"), -	"mnplus":                          []byte("∓"), -	"models":                          []byte("⊧"), -	"mstpos":                          []byte("∾"), -	"multimap":                        []byte("⊸"), -	"nLeftarrow":                      []byte("⇍"), -	"nLeftrightarrow":                 []byte("⇎"), -	"nRightarrow":                     []byte("⇏"), -	"nVDash":                          []byte("⊯"), -	"nVdash":                          []byte("⊮"), -	"nabla":                           []byte("∇"), -	"nacute":                          []byte("ń"), -	"napos":                           []byte("ʼn"), -	"napprox":                         []byte("≉"), -	"natural":                         []byte("♮"), -	"naturals":                        []byte("ℕ"), -	"ncaron":                          []byte("ň"), -	"ncedil":                          []byte("ņ"), -	"nearrow":                         []byte("↗"), -	"nequiv":                          []byte("≢"), -	"nesear":                          []byte("⤨"), -	"nexist":                          []byte("∄"), -	"nexists":                         []byte("∄"), -	"ngeq":                            []byte("≱"), -	"ngtr":                            []byte("≯"), -	"niv":                             []byte("∋"), -	"nleftarrow":                      []byte("↚"), -	"nleftrightarrow":                 []byte("↮"), -	"nleq":                            []byte("≰"), -	"nless":                           []byte("≮"), -	"nltrie":                          []byte("⋬"), -	"notinva":                         []byte("∉"), -	"notinvb":                         []byte("⋷"), -	"notinvc":                         []byte("⋶"), -	"notniva":                         []byte("∌"), -	"notnivb":                         []byte("⋾"), -	"notnivc":                         []byte("⋽"), -	"nparallel":                       []byte("∦"), -	"npolint":                         []byte("⨔"), -	"nprcue":                          []byte("⋠"), -	"nprec":                           []byte("⊀"), -	"nrightarrow":                     []byte("↛"), -	"nrtrie":                          []byte("⋭"), -	"nsccue":                          []byte("⋡"), -	"nshortmid":                       []byte("∤"), -	"nshortparallel":                  []byte("∦"), -	"nsimeq":                          []byte("≄"), -	"nsmid":                           []byte("∤"), -	"nspar":                           []byte("∦"), -	"nsqsube":                         []byte("⋢"), -	"nsqsupe":                         []byte("⋣"), -	"nsubseteq":                       []byte("⊈"), -	"nsucc":                           []byte("⊁"), -	"nsupseteq":                       []byte("⊉"), -	"ntilde":                          []byte("ñ"), -	"ntriangleleft":                   []byte("⋪"), -	"ntrianglelefteq":                 []byte("⋬"), -	"ntriangleright":                  []byte("⋫"), -	"ntrianglerighteq":                []byte("⋭"), -	"num":                             []byte("#"), -	"numero":                          []byte("№"), -	"nvDash":                          []byte("⊭"), -	"nvdash":                          []byte("⊬"), -	"nvinfin":                         []byte("⧞"), -	"nwarrow":                         []byte("↖"), -	"oacute":                          []byte("ó"), -	"ocirc":                           []byte("ô"), -	"odblac":                          []byte("ő"), -	"oelig":                           []byte("œ"), -	"ograve":                          []byte("ò"), -	"olcross":                         []byte("⦻"), -	"omacr":                           []byte("ō"), -	"omega":                           []byte("ω"), -	"omicron":                         []byte("ο"), -	"ominus":                          []byte("⊖"), -	"order":                           []byte("ℴ"), -	"orderof":                         []byte("ℴ"), -	"origof":                          []byte("⊶"), -	"orslope":                         []byte("⩗"), -	"oslash":                          []byte("ø"), -	"otilde":                          []byte("õ"), -	"otimes":                          []byte("⊗"), -	"otimesas":                        []byte("⨶"), -	"parallel":                        []byte("∥"), -	"percnt":                          []byte("%"), -	"period":                          []byte("."), -	"permil":                          []byte("‰"), -	"perp":                            []byte("⊥"), -	"pertenk":                         []byte("‱"), -	"phmmat":                          []byte("ℳ"), -	"pitchfork":                       []byte("⋔"), -	"planck":                          []byte("ℏ"), -	"planckh":                         []byte("ℎ"), -	"plankv":                          []byte("ℏ"), -	"plus":                            []byte("+"), -	"plusacir":                        []byte("⨣"), -	"pluscir":                         []byte("⨢"), -	"plusdo":                          []byte("∔"), -	"plusmn":                          []byte("±"), -	"plussim":                         []byte("⨦"), -	"plustwo":                         []byte("⨧"), -	"pointint":                        []byte("⨕"), -	"pound":                           []byte("£"), -	"prec":                            []byte("≺"), -	"precapprox":                      []byte("⪷"), -	"preccurlyeq":                     []byte("≼"), -	"preceq":                          []byte("⪯"), -	"precnapprox":                     []byte("⪹"), -	"precneqq":                        []byte("⪵"), -	"precnsim":                        []byte("⋨"), -	"precsim":                         []byte("≾"), -	"primes":                          []byte("ℙ"), -	"prnsim":                          []byte("⋨"), -	"profalar":                        []byte("⌮"), -	"profline":                        []byte("⌒"), -	"profsurf":                        []byte("⌓"), -	"propto":                          []byte("∝"), -	"prurel":                          []byte("⊰"), -	"puncsp":                          []byte(" "), -	"qprime":                          []byte("⁗"), -	"quaternions":                     []byte("ℍ"), -	"quatint":                         []byte("⨖"), -	"quest":                           []byte("?"), -	"questeq":                         []byte("≟"), -	"quot":                            []byte("\""), -	"racute":                          []byte("ŕ"), -	"radic":                           []byte("√"), -	"raemptyv":                        []byte("⦳"), -	"rangle":                          []byte("⟩"), -	"raquo":                           []byte("»"), -	"rarrbfs":                         []byte("⤠"), -	"rarrhk":                          []byte("↪"), -	"rarrlp":                          []byte("↬"), -	"rarrsim":                         []byte("⥴"), -	"rarrtl":                          []byte("↣"), -	"rationals":                       []byte("ℚ"), -	"rbrace":                          []byte("}"), -	"rbrack":                          []byte("]"), -	"rbrksld":                         []byte("⦎"), -	"rbrkslu":                         []byte("⦐"), -	"rcaron":                          []byte("ř"), -	"rcedil":                          []byte("ŗ"), -	"rcub":                            []byte("}"), -	"rdldhar":                         []byte("⥩"), -	"rdquor":                          []byte("”"), -	"real":                            []byte("ℜ"), -	"realine":                         []byte("ℛ"), -	"realpart":                        []byte("ℜ"), -	"reals":                           []byte("ℝ"), -	"rfloor":                          []byte("⌋"), -	"rightarrow":                      []byte("→"), -	"rightarrowtail":                  []byte("↣"), -	"rightharpoondown":                []byte("⇁"), -	"rightharpoonup":                  []byte("⇀"), -	"rightleftarrows":                 []byte("⇄"), -	"rightleftharpoons":               []byte("⇌"), -	"rightrightarrows":                []byte("⇉"), -	"rightsquigarrow":                 []byte("↝"), -	"rightthreetimes":                 []byte("⋌"), -	"risingdotseq":                    []byte("≓"), -	"rmoust":                          []byte("⎱"), -	"rmoustache":                      []byte("⎱"), -	"rotimes":                         []byte("⨵"), -	"rpar":                            []byte(")"), -	"rppolint":                        []byte("⨒"), -	"rsaquo":                          []byte("›"), -	"rsqb":                            []byte("]"), -	"rsquor":                          []byte("’"), -	"rthree":                          []byte("⋌"), -	"rtimes":                          []byte("⋊"), -	"rtriltri":                        []byte("⧎"), -	"ruluhar":                         []byte("⥨"), -	"sacute":                          []byte("ś"), -	"scaron":                          []byte("š"), -	"scedil":                          []byte("ş"), -	"scirc":                           []byte("ŝ"), -	"scnsim":                          []byte("⋩"), -	"scpolint":                        []byte("⨓"), -	"searrow":                         []byte("↘"), -	"semi":                            []byte(";"), -	"seswar":                          []byte("⤩"), -	"setminus":                        []byte("∖"), -	"sfrown":                          []byte("⌢"), -	"shchcy":                          []byte("щ"), -	"shortmid":                        []byte("∣"), -	"shortparallel":                   []byte("∥"), -	"sigma":                           []byte("σ"), -	"sigmaf":                          []byte("ς"), -	"sigmav":                          []byte("ς"), -	"simeq":                           []byte("≃"), -	"simplus":                         []byte("⨤"), -	"simrarr":                         []byte("⥲"), -	"slarr":                           []byte("←"), -	"smallsetminus":                   []byte("∖"), -	"smeparsl":                        []byte("⧤"), -	"smid":                            []byte("∣"), -	"softcy":                          []byte("ь"), -	"sol":                             []byte("/"), -	"solbar":                          []byte("⌿"), -	"spades":                          []byte("♠"), -	"spadesuit":                       []byte("♠"), -	"spar":                            []byte("∥"), -	"sqsube":                          []byte("⊑"), -	"sqsubset":                        []byte("⊏"), -	"sqsubseteq":                      []byte("⊑"), -	"sqsupe":                          []byte("⊒"), -	"sqsupset":                        []byte("⊐"), -	"sqsupseteq":                      []byte("⊒"), -	"square":                          []byte("□"), -	"squarf":                          []byte("▪"), -	"srarr":                           []byte("→"), -	"ssetmn":                          []byte("∖"), -	"ssmile":                          []byte("⌣"), -	"sstarf":                          []byte("⋆"), -	"straightepsilon":                 []byte("ϵ"), -	"straightphi":                     []byte("ϕ"), -	"strns":                           []byte("¯"), -	"subedot":                         []byte("⫃"), -	"submult":                         []byte("⫁"), -	"subplus":                         []byte("⪿"), -	"subrarr":                         []byte("⥹"), -	"subset":                          []byte("⊂"), -	"subseteq":                        []byte("⊆"), -	"subseteqq":                       []byte("⫅"), -	"subsetneq":                       []byte("⊊"), -	"subsetneqq":                      []byte("⫋"), -	"succ":                            []byte("≻"), -	"succapprox":                      []byte("⪸"), -	"succcurlyeq":                     []byte("≽"), -	"succeq":                          []byte("⪰"), -	"succnapprox":                     []byte("⪺"), -	"succneqq":                        []byte("⪶"), -	"succnsim":                        []byte("⋩"), -	"succsim":                         []byte("≿"), -	"supdsub":                         []byte("⫘"), -	"supedot":                         []byte("⫄"), -	"suphsol":                         []byte("⟉"), -	"suphsub":                         []byte("⫗"), -	"suplarr":                         []byte("⥻"), -	"supmult":                         []byte("⫂"), -	"supplus":                         []byte("⫀"), -	"supset":                          []byte("⊃"), -	"supseteq":                        []byte("⊇"), -	"supseteqq":                       []byte("⫆"), -	"supsetneq":                       []byte("⊋"), -	"supsetneqq":                      []byte("⫌"), -	"swarrow":                         []byte("↙"), -	"szlig":                           []byte("ß"), -	"target":                          []byte("⌖"), -	"tcaron":                          []byte("ť"), -	"tcedil":                          []byte("ţ"), -	"telrec":                          []byte("⌕"), -	"there4":                          []byte("∴"), -	"therefore":                       []byte("∴"), -	"theta":                           []byte("θ"), -	"thetasym":                        []byte("ϑ"), -	"thetav":                          []byte("ϑ"), -	"thickapprox":                     []byte("≈"), -	"thicksim":                        []byte("∼"), -	"thinsp":                          []byte(" "), -	"thkap":                           []byte("≈"), -	"thksim":                          []byte("∼"), -	"thorn":                           []byte("þ"), -	"tilde":                           []byte("˜"), -	"times":                           []byte("×"), -	"timesb":                          []byte("⊠"), -	"timesbar":                        []byte("⨱"), -	"topbot":                          []byte("⌶"), -	"topfork":                         []byte("⫚"), -	"tprime":                          []byte("‴"), -	"triangle":                        []byte("▵"), -	"triangledown":                    []byte("▿"), -	"triangleleft":                    []byte("◃"), -	"trianglelefteq":                  []byte("⊴"), -	"triangleq":                       []byte("≜"), -	"triangleright":                   []byte("▹"), -	"trianglerighteq":                 []byte("⊵"), -	"tridot":                          []byte("◬"), -	"triminus":                        []byte("⨺"), -	"triplus":                         []byte("⨹"), -	"tritime":                         []byte("⨻"), -	"trpezium":                        []byte("⏢"), -	"tstrok":                          []byte("ŧ"), -	"twoheadleftarrow":                []byte("↞"), -	"twoheadrightarrow":               []byte("↠"), -	"uacute":                          []byte("ú"), -	"ubreve":                          []byte("ŭ"), -	"ucirc":                           []byte("û"), -	"udblac":                          []byte("ű"), -	"ugrave":                          []byte("ù"), -	"ulcorn":                          []byte("⌜"), -	"ulcorner":                        []byte("⌜"), -	"ulcrop":                          []byte("⌏"), -	"umacr":                           []byte("ū"), -	"uogon":                           []byte("ų"), -	"uparrow":                         []byte("↑"), -	"updownarrow":                     []byte("↕"), -	"upharpoonleft":                   []byte("↿"), -	"upharpoonright":                  []byte("↾"), -	"upsih":                           []byte("ϒ"), -	"upsilon":                         []byte("υ"), -	"upuparrows":                      []byte("⇈"), -	"urcorn":                          []byte("⌝"), -	"urcorner":                        []byte("⌝"), -	"urcrop":                          []byte("⌎"), -	"uring":                           []byte("ů"), -	"utilde":                          []byte("ũ"), -	"uwangle":                         []byte("⦧"), -	"varepsilon":                      []byte("ϵ"), -	"varkappa":                        []byte("ϰ"), -	"varnothing":                      []byte("∅"), -	"varphi":                          []byte("ϕ"), -	"varpi":                           []byte("ϖ"), -	"varpropto":                       []byte("∝"), -	"varrho":                          []byte("ϱ"), -	"varsigma":                        []byte("ς"), -	"vartheta":                        []byte("ϑ"), -	"vartriangleleft":                 []byte("⊲"), -	"vartriangleright":                []byte("⊳"), -	"vee":                             []byte("∨"), -	"veebar":                          []byte("⊻"), -	"vellip":                          []byte("⋮"), -	"verbar":                          []byte("|"), -	"vert":                            []byte("|"), -	"vprop":                           []byte("∝"), -	"vzigzag":                         []byte("⦚"), -	"wcirc":                           []byte("ŵ"), -	"wedge":                           []byte("∧"), -	"wedgeq":                          []byte("≙"), -	"weierp":                          []byte("℘"), -	"wreath":                          []byte("≀"), -	"xvee":                            []byte("⋁"), -	"xwedge":                          []byte("⋀"), -	"yacute":                          []byte("ý"), -	"ycirc":                           []byte("ŷ"), -	"zacute":                          []byte("ź"), -	"zcaron":                          []byte("ž"), -	"zeetrf":                          []byte("ℨ"), -	"zigrarr":                         []byte("⇝"), -} - -// TextRevEntitiesMap is a map of escapes. -var TextRevEntitiesMap = map[byte][]byte{ -	'<': []byte("<"), -} diff --git a/vendor/github.com/tdewolff/minify/v2/minify.go b/vendor/github.com/tdewolff/minify/v2/minify.go deleted file mode 100644 index a40ec504f..000000000 --- a/vendor/github.com/tdewolff/minify/v2/minify.go +++ /dev/null @@ -1,375 +0,0 @@ -// Package minify relates MIME type to minifiers. Several minifiers are provided in the subpackages. -package minify - -import ( -	"bytes" -	"errors" -	"fmt" -	"io" -	"log" -	"mime" -	"net/http" -	"net/url" -	"os" -	"os/exec" -	"path" -	"regexp" -	"strings" -	"sync" - -	"github.com/tdewolff/parse/v2" -	"github.com/tdewolff/parse/v2/buffer" -) - -// Warning is used to report usage warnings such as using a deprecated feature -var Warning = log.New(os.Stderr, "WARNING: ", 0) - -// ErrNotExist is returned when no minifier exists for a given mimetype. -var ErrNotExist = errors.New("minifier does not exist for mimetype") - -// ErrClosedWriter is returned when writing to a closed writer. -var ErrClosedWriter = errors.New("write on closed writer") // TODO: DEPRECATED, remove - -//////////////////////////////////////////////////////////////// - -// MinifierFunc is a function that implements Minifer. -type MinifierFunc func(*M, io.Writer, io.Reader, map[string]string) error - -// Minify calls f(m, w, r, params) -func (f MinifierFunc) Minify(m *M, w io.Writer, r io.Reader, params map[string]string) error { -	return f(m, w, r, params) -} - -// Minifier is the interface for minifiers. -// The *M parameter is used for minifying embedded resources, such as JS within HTML. -type Minifier interface { -	Minify(*M, io.Writer, io.Reader, map[string]string) error -} - -//////////////////////////////////////////////////////////////// - -type patternMinifier struct { -	pattern *regexp.Regexp -	Minifier -} - -type cmdMinifier struct { -	cmd *exec.Cmd -} - -var cmdArgExtension = regexp.MustCompile(`^\.[0-9a-zA-Z]+`) - -func (c *cmdMinifier) Minify(_ *M, w io.Writer, r io.Reader, _ map[string]string) error { -	cmd := &exec.Cmd{} -	*cmd = *c.cmd // concurrency safety - -	var in, out *os.File -	for i, arg := range cmd.Args { -		if j := strings.Index(arg, "$in"); j != -1 { -			var err error -			ext := cmdArgExtension.FindString(arg[j+3:]) -			if in, err = os.CreateTemp("", "minify-in-*"+ext); err != nil { -				return err -			} -			cmd.Args[i] = arg[:j] + in.Name() + arg[j+3+len(ext):] -		} else if j := strings.Index(arg, "$out"); j != -1 { -			var err error -			ext := cmdArgExtension.FindString(arg[j+4:]) -			if out, err = os.CreateTemp("", "minify-out-*"+ext); err != nil { -				return err -			} -			cmd.Args[i] = arg[:j] + out.Name() + arg[j+4+len(ext):] -		} -	} - -	if in == nil { -		cmd.Stdin = r -	} else if _, err := io.Copy(in, r); err != nil { -		return err -	} -	if out == nil { -		cmd.Stdout = w -	} else { -		defer io.Copy(w, out) -	} -	stderr := &bytes.Buffer{} -	cmd.Stderr = stderr - -	err := cmd.Run() -	if _, ok := err.(*exec.ExitError); ok { -		if stderr.Len() != 0 { -			err = fmt.Errorf("%s", stderr.String()) -		} -		err = fmt.Errorf("command %s failed: %w", cmd.Path, err) -	} -	return err -} - -//////////////////////////////////////////////////////////////// - -// M holds a map of mimetype => function to allow recursive minifier calls of the minifier functions. -type M struct { -	mutex   sync.RWMutex -	literal map[string]Minifier -	pattern []patternMinifier - -	URL *url.URL -} - -// New returns a new M. -func New() *M { -	return &M{ -		sync.RWMutex{}, -		map[string]Minifier{}, -		[]patternMinifier{}, -		nil, -	} -} - -// Add adds a minifier to the mimetype => function map (unsafe for concurrent use). -func (m *M) Add(mimetype string, minifier Minifier) { -	m.mutex.Lock() -	m.literal[mimetype] = minifier -	m.mutex.Unlock() -} - -// AddFunc adds a minify function to the mimetype => function map (unsafe for concurrent use). -func (m *M) AddFunc(mimetype string, minifier MinifierFunc) { -	m.mutex.Lock() -	m.literal[mimetype] = minifier -	m.mutex.Unlock() -} - -// AddRegexp adds a minifier to the mimetype => function map (unsafe for concurrent use). -func (m *M) AddRegexp(pattern *regexp.Regexp, minifier Minifier) { -	m.mutex.Lock() -	m.pattern = append(m.pattern, patternMinifier{pattern, minifier}) -	m.mutex.Unlock() -} - -// AddFuncRegexp adds a minify function to the mimetype => function map (unsafe for concurrent use). -func (m *M) AddFuncRegexp(pattern *regexp.Regexp, minifier MinifierFunc) { -	m.mutex.Lock() -	m.pattern = append(m.pattern, patternMinifier{pattern, minifier}) -	m.mutex.Unlock() -} - -// AddCmd adds a minify function to the mimetype => function map (unsafe for concurrent use) that executes a command to process the minification. -// It allows the use of external tools like ClosureCompiler, UglifyCSS, etc. for a specific mimetype. -func (m *M) AddCmd(mimetype string, cmd *exec.Cmd) { -	m.mutex.Lock() -	m.literal[mimetype] = &cmdMinifier{cmd} -	m.mutex.Unlock() -} - -// AddCmdRegexp adds a minify function to the mimetype => function map (unsafe for concurrent use) that executes a command to process the minification. -// It allows the use of external tools like ClosureCompiler, UglifyCSS, etc. for a specific mimetype regular expression. -func (m *M) AddCmdRegexp(pattern *regexp.Regexp, cmd *exec.Cmd) { -	m.mutex.Lock() -	m.pattern = append(m.pattern, patternMinifier{pattern, &cmdMinifier{cmd}}) -	m.mutex.Unlock() -} - -// Match returns the pattern and minifier that gets matched with the mediatype. -// It returns nil when no matching minifier exists. -// It has the same matching algorithm as Minify. -func (m *M) Match(mediatype string) (string, map[string]string, MinifierFunc) { -	m.mutex.RLock() -	defer m.mutex.RUnlock() - -	mimetype, params := parse.Mediatype([]byte(mediatype)) -	if minifier, ok := m.literal[string(mimetype)]; ok { // string conversion is optimized away -		return string(mimetype), params, minifier.Minify -	} - -	for _, minifier := range m.pattern { -		if minifier.pattern.Match(mimetype) { -			return minifier.pattern.String(), params, minifier.Minify -		} -	} -	return string(mimetype), params, nil -} - -// Minify minifies the content of a Reader and writes it to a Writer (safe for concurrent use). -// An error is returned when no such mimetype exists (ErrNotExist) or when an error occurred in the minifier function. -// Mediatype may take the form of 'text/plain', 'text/*', '*/*' or 'text/plain; charset=UTF-8; version=2.0'. -func (m *M) Minify(mediatype string, w io.Writer, r io.Reader) error { -	mimetype, params := parse.Mediatype([]byte(mediatype)) -	return m.MinifyMimetype(mimetype, w, r, params) -} - -// MinifyMimetype minifies the content of a Reader and writes it to a Writer (safe for concurrent use). -// It is a lower level version of Minify and requires the mediatype to be split up into mimetype and parameters. -// It is mostly used internally by minifiers because it is faster (no need to convert a byte-slice to string and vice versa). -func (m *M) MinifyMimetype(mimetype []byte, w io.Writer, r io.Reader, params map[string]string) error { -	m.mutex.RLock() -	defer m.mutex.RUnlock() - -	if minifier, ok := m.literal[string(mimetype)]; ok { // string conversion is optimized away -		return minifier.Minify(m, w, r, params) -	} -	for _, minifier := range m.pattern { -		if minifier.pattern.Match(mimetype) { -			return minifier.Minify(m, w, r, params) -		} -	} -	return ErrNotExist -} - -// Bytes minifies an array of bytes (safe for concurrent use). When an error occurs it return the original array and the error. -// It returns an error when no such mimetype exists (ErrNotExist) or any error occurred in the minifier function. -func (m *M) Bytes(mediatype string, v []byte) ([]byte, error) { -	out := buffer.NewWriter(make([]byte, 0, len(v))) -	if err := m.Minify(mediatype, out, buffer.NewReader(v)); err != nil { -		return v, err -	} -	return out.Bytes(), nil -} - -// String minifies a string (safe for concurrent use). When an error occurs it return the original string and the error. -// It returns an error when no such mimetype exists (ErrNotExist) or any error occurred in the minifier function. -func (m *M) String(mediatype string, v string) (string, error) { -	out := buffer.NewWriter(make([]byte, 0, len(v))) -	if err := m.Minify(mediatype, out, buffer.NewReader([]byte(v))); err != nil { -		return v, err -	} -	return string(out.Bytes()), nil -} - -// Reader wraps a Reader interface and minifies the stream. -// Errors from the minifier are returned by the reader. -func (m *M) Reader(mediatype string, r io.Reader) io.Reader { -	pr, pw := io.Pipe() -	go func() { -		if err := m.Minify(mediatype, pw, r); err != nil { -			pw.CloseWithError(err) -		} else { -			pw.Close() -		} -	}() -	return pr -} - -// writer makes sure that errors from the minifier are passed down through Close (can be blocking). -type writer struct { -	io.WriteCloser -	wg     sync.WaitGroup -	closed bool -	err    error -} - -// Close must be called when writing has finished. It returns the error from the minifier. -func (z *writer) Close() error { -	if z.closed { -		return nil -	} -	z.closed = true -	err := z.WriteCloser.Close() -	z.wg.Wait() -	if z.err == nil { -		return err -	} -	return z.err -} - -// Writer wraps a Writer interface and minifies the stream. -// Errors from the minifier are returned by Close on the writer. -// The writer must be closed explicitly. -func (m *M) Writer(mediatype string, w io.Writer) io.WriteCloser { -	pr, pw := io.Pipe() -	z := &writer{pw, sync.WaitGroup{}, false, nil} -	z.wg.Add(1) -	go func() { -		defer z.wg.Done() -		defer pr.Close() -		if err := m.Minify(mediatype, w, pr); err != nil { -			z.err = err -		} -	}() -	return z -} - -// responseWriter wraps an http.ResponseWriter and makes sure that errors from the minifier are passed down through Close (can be blocking). -// All writes to the response writer are intercepted and minified on the fly. -// http.ResponseWriter loses all functionality such as Pusher, Hijacker, Flusher, ... -type responseWriter struct { -	http.ResponseWriter - -	z         io.Writer -	m         *M -	mediatype string -} - -// WriteHeader intercepts any header writes and removes the Content-Length header. -func (w *responseWriter) WriteHeader(status int) { -	w.ResponseWriter.Header().Del("Content-Length") -	w.ResponseWriter.WriteHeader(status) -} - -// Write intercepts any writes to the response writer. -// The first write will extract the Content-Type as the mediatype. Otherwise it falls back to the RequestURI extension. -func (w *responseWriter) Write(b []byte) (int, error) { -	if w.z == nil { -		// first write -		if mediatype := w.ResponseWriter.Header().Get("Content-Type"); mediatype != "" { -			w.mediatype = mediatype -		} -		if _, params, minifier := w.m.Match(w.mediatype); minifier != nil { -			pr, pw := io.Pipe() -			z := &writer{pw, sync.WaitGroup{}, false, nil} -			z.wg.Add(1) -			go func() { -				defer z.wg.Done() -				defer pr.Close() -				if err := minifier(w.m, w.ResponseWriter, pr, params); err != nil { -					z.err = err -				} -			}() -			w.z = z -		} else { -			w.z = w.ResponseWriter -		} -	} -	return w.z.Write(b) -} - -// Close must be called when writing has finished. It returns the error from the minifier. -func (w *responseWriter) Close() error { -	if closer, ok := w.z.(interface{ Close() error }); ok { -		return closer.Close() -	} -	return nil -} - -// ResponseWriter minifies any writes to the http.ResponseWriter. -// http.ResponseWriter loses all functionality such as Pusher, Hijacker, Flusher, ... -// Minification might be slower than just sending the original file! Caching is advised. -func (m *M) ResponseWriter(w http.ResponseWriter, r *http.Request) *responseWriter { -	mediatype := mime.TypeByExtension(path.Ext(r.RequestURI)) -	return &responseWriter{w, nil, m, mediatype} -} - -// Middleware provides a middleware function that minifies content on the fly by intercepting writes to http.ResponseWriter. -// http.ResponseWriter loses all functionality such as Pusher, Hijacker, Flusher, ... -// Minification might be slower than just sending the original file! Caching is advised. -func (m *M) Middleware(next http.Handler) http.Handler { -	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { -		mw := m.ResponseWriter(w, r) -		next.ServeHTTP(mw, r) -		mw.Close() -	}) -} - -// MiddlewareWithError provides a middleware function that minifies content on the fly by intercepting writes to http.ResponseWriter. The error function allows handling minification errors. -// http.ResponseWriter loses all functionality such as Pusher, Hijacker, Flusher, ... -// Minification might be slower than just sending the original file! Caching is advised. -func (m *M) MiddlewareWithError(next http.Handler, errorFunc func(w http.ResponseWriter, r *http.Request, err error)) http.Handler { -	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { -		mw := m.ResponseWriter(w, r) -		next.ServeHTTP(mw, r) -		if err := mw.Close(); err != nil { -			errorFunc(w, r, err) -			return -		} -	}) -}  | 
