npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

htmlclean-cli

v1.0.9

Published

Simple and safety HTML/SVG cleaner to minify without changing its structure.

Downloads

27

Readme

htmlclean-cli

npm GitHub issues David license

Command Line Tool - Simple and safety HTML/SVG cleaner to minify without changing its structure.
This is CLI for htmlclean.

Installation

npm install -g htmlclean-cli

Drag & Drop & Clean

In GUI environment, you can drag-and-drop one or more target files or directories to the htmlclean icon, or a short cut (alias, link, etc.) icon on the desktop also works.
desktop

The htmlclean icon is found in:

npm bin -g

Command Line

htmlclean [options] [input1 [input2 ...]]

Options

<input> / <output>

An argument that have no option is considered as input.
For example:

htmlclean A.html

equals:

htmlclean -i A.html

A - is specified as STDIN or STDOUT.

If multiple inputs and outputs are specified, the content from a first input is written to a first output, and the content from a second input is written to a second output..., in this way.
The all arguments that have no option are added to last of the input list.
If no inputs are specified, it's considered as one STDIN.
The outputs exceeding inputs are ignored.
For example:

htmlclean -o A.html -o B.html

A first input is STDIN, B.html is ignored.

If a file is specified to the input of a pair and a directory is specified to the output of this pair, the content is written to the same named file in the specified directory. In this case, if the input path is located under the path that is specified to the --root option, the directory tree under the root path is created into the output directory.
If a file is specified to the input of a pair and the output of this pair isn't specified, the content is written to the file named <input>.min.<ext>. For example, if the name of file as input is index.html, then the content is written to index.min.html.
If STDIN is specified to the input of a pair and the output of this pair isn't specified (or a directory is specified), the content is written to STDOUT.

The input can be Glob pattern like *.html.
For Glob pattern syntax, see:
https://github.com/isaacs/node-glob
https://github.com/isaacs/minimatch

If a directory is specified to the input, it is considered as directory/**/*.html. And this directory is set to default of the --root option.
If the input of a pair points to multiple files and a directory is specified to the output of this pair, the each content is written to the same named file in the specified directory. In this case, if the input path is located under the path that is specified to the --root option, the directory tree under the root path is created into the output directory.
If the input of a pair points to multiple files and the output of this pair isn't specified, the each content is written to the file named <input>.min.<ext>. For example, if the name of file as input is index.html, then the content is written to index.min.html.
If the input of a pair points to multiple files and a file (or STDOUT) is specified to the output of this pair, a concatenated content from all input files of this pair is written to the output.

Examples

  • Clean index.html, and write to index.min.html.
htmlclean index.html
  • Clean index.html, and overwrite it.
htmlclean index.html -o index.html
  • Clean all HTML files in src directory, and write into public directory.
htmlclean src -o public
  • Clean index.html in src directory, and write into public directory.
htmlclean src/index.html -o public
  • Clean 2 files.
htmlclean -i A.html -o A.cln.html -i B.html -o B.cln.html
  • Clean 2 files in src directory, and write into public directory.
htmlclean -i src/A.html -o public -i src/B.html -o public
  • Equal to above.
htmlclean -i "src/@(A|B).html" -o public
  • Clean all SVG files.
htmlclean *.svg
  • Get and clean web page on URL, and write to index.html.
wget -q -O - https://github.com/ | htmlclean -o index.html
  • Clean and compress index.html, and write to index.gz.
htmlclean index.html -o - | gzip > index.gz
  • From STDIN to public/A.html, from src/B.html to STDOUT.
htmlclean -i - -o public/A.html -i src/B.html -o -
  • Clean 3 files, and write into 1 file.
htmlclean -i head.html -i body.html -i foot.html \
-o index.html -o index.html -o index.html
  • Clean all HTML and SVG and PHP files.
htmlclean *.{html,svg,php}
  • Clean all files that has a number as the first character, and extension is html or htm.
htmlclean [0-9]*.htm?(l)

--protect / --unprotect

These must be a text like /pattern/flags as RegExp.
The multiple options can be specified.
See: Options of htmlclean

For example, for some Template Framework and AngularJS.

htmlclean \
-p "/<\!--%fooTemplate\b.*?%-->/g" \
-p "/<\!--%barTemplate\b.*?%-->/g" \
-P "/<script [^>]*\btype="text\/ng-template"[\s\S]+?<\/script>/ig"

Note

On Windows XP, 2000 + Node v0.11-, the redirecting doesn't work, the piping works.
Therefore, use this:

type file.html | htmlclean

instead of:

htmlclean < file.html