Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/evotecit/psparsehtml

PSParseHTML is PowerShell module that's main purpose is to be a helper module for PSWriteHTML. However it's functionality can be utilized in other projects, not related to PSWriteHTML, therefore it's available as a separate module.
https://github.com/evotecit/psparsehtml

css hacktoberfest html javascript powershell pswritehtml

Last synced: about 2 months ago
JSON representation

PSParseHTML is PowerShell module that's main purpose is to be a helper module for PSWriteHTML. However it's functionality can be utilized in other projects, not related to PSWriteHTML, therefore it's available as a separate module.

Awesome Lists containing this project

README

        

















# PSParseHTML

**PSParseHTML** started as a suite of data processing Cmdlets to help [PSWriteHTML](https://github.com/EvotecIT/PSWriteHTML), but it has gained functionality enough to be its own module. Basic usage instructions are described [on this blog post](https://evotec.xyz/formatting-and-minifying-resources-html-css-javascript-with-powershell/).

**PSParseHTML** provides the following ten (10) functions:

- Convert-HTMLToText
- ConvertFrom-HtmlTable
- ConvertFrom-HTMLAttributes (aliases: `ConvertFrom-HTMLTag`, `ConvertFrom-HTMLClass`)
- ConvertFrom-HTML
- Format-CSS
- Format-HTML
- Format-JavaScript
- Optimize-CSS
- Optimize-HTML
- Optimize-JavaScript

The expected input is a string literal or string data read from a file. The output can be PowerShell objects (classes are `HtmlNode` or `AngleSharp.Html.Dom.HtmlElement` depending on the chosen processing engine) or string literals written to `stdout`.

It may not seem like much, but those ten functions are powerful enough to realize robust HTML processing in shell.

## Installation

### Install from PSGallery

```powershell
Install-Module -Name PSParseHTML -AllowClobber -Force
```

Force and AllowClobber aren't necessary but they do skip errors in case some appear.

### Update from PSGallery

```powershell
Update-Module -Name PSParseHTML
```

That's it. Whenever there's a new version you simply run the `Update-Module` command and enjoy. Remember that you may need to close, re-open your **PowerShell** session if you had used the module prior to updating it.

As usual, **remember module updates may break your scripts**: if your scripts work for you in production, retain those versions until you test new versions in a dev environment. I may make small changes which are big enough so that your automated updates will break your scripts. For example, I might make a small rename to a parameter — boom, your code stops working! Be responsible!

## 3rd party references

This module utilizes several external dependencies to do its work. The authors of those libraries have done fantastic work — I've just added some PowerShell to the mix.

- [AngleSharp](https://github.com/AngleSharp/AngleSharp) - MIT License
- [AngleSharp CSS](https://github.com/AngleSharp/AngleSharp.Css) - MIT License
- [Jsbeautifier](https://github.com/denis-ivanov/Jsbeautifier) - MIT License
- [NUglify](https://github.com/trullock/NUglify) - BSD-Clause 2 license
- [Html Agility Pack](https://github.com/zzzprojects/html-agility-pack) - MIT License