Skip to content

Commit

Permalink
Update README and bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
mgdm committed Jan 3, 2022
1 parent 00a25d3 commit 1361c8c
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 9 deletions.
4 changes: 3 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ documentation = "https://github.com/mgdm/htmlq/blob/master/README.md"
readme = "README.md"
license = "MIT"
license-file = "LICENSE.md"
version = "0.3.0"
version = "0.4.0"
authors = ["Michael Maclean <michael@mgdm.net>"]
edition = "2018"
exclude = ["/.github"]
Expand Down
52 changes: 46 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ brew install htmlq

```console
$ htmlq -h
htmlq 0.3.0
htmlq 0.4.0
Michael Maclean <michael@mgdm.net>
Runs CSS selectors on HTML

USAGE:
htmlq [FLAGS] [OPTIONS] [selector]...
htmlq [FLAGS] [OPTIONS] [--] [selector]...

FLAGS:
-B, --detect-base Try to detect the base URL from the <base> tag in the document. If not found, default to
Expand All @@ -36,10 +36,12 @@ FLAGS:
-V, --version Prints version information

OPTIONS:
-a, --attribute <attribute> Only return this attribute (if present) from selected elements
-b, --base <base> Use this URL as the base for links
-f, --filename <FILE> The input file. Defaults to stdin
-o, --output <FILE> The output file. Defaults to stdout
-a, --attribute <attribute> Only return this attribute (if present) from selected elements
-b, --base <base> Use this URL as the base for links
-f, --filename <FILE> The input file. Defaults to stdin
-o, --output <FILE> The output file. Defaults to stdout
-r, --remove-nodes <SELECTOR>... Remove nodes matching this expression before output. May be specified multiple
times

ARGS:
<selector>... The CSS expression to select [default: html]
Expand Down Expand Up @@ -107,6 +109,44 @@ to change that. NixOS has many innovative features:
[...]
```

### Remove a node before output

There's a big SVG image in this page that I don't need, so here's how to remove it.

```console
$ curl --silent https://nixos.org/ | ./target/debug/htmlq '.whynix' --remove-nodes svg
<ul class="whynix">
<li>

<h2>Reproducible</h2>
<p>
Nix builds packages in isolation from each other. This ensures that they
are reproducible and don't have undeclared dependencies, so <strong>if a
package works on one machine, it will also work on another</strong>.
</p>
</li>
<li>

<h2>Declarative</h2>
<p>
Nix makes it <strong>trivial to share development and build
environments</strong> for your projects, regardless of what programming
languages and tools you’re using.
</p>
</li>
<li>

<h2>Reliable</h2>
<p>
Nix ensures that installing or upgrading one package <strong>cannot
break other packages</strong>. It allows you to <strong>roll back to
previous versions</strong>, and ensures that no package is in an
inconsistent state during an upgrade.
</p>
</li>
</ul>
```

### Pretty print HTML

(This is a bit of a work in progress)
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ fn serialize_text(node: &NodeRef, ignore_whitespace: bool) -> String {

fn get_config<'a, 'b>() -> App<'a, 'b> {
App::new("htmlq")
.version("0.3.0")
.version("0.4.0")
.author("Michael Maclean <michael@mgdm.net>")
.about("Runs CSS selectors on HTML")
.arg(
Expand Down Expand Up @@ -177,6 +177,7 @@ fn get_config<'a, 'b>() -> App<'a, 'b> {
.multiple(true)
.number_of_values(1)
.takes_value(true)
.value_name("SELECTOR")
.help("Remove nodes matching this expression before output. May be specified multiple times")
)
.arg(
Expand Down

0 comments on commit 1361c8c

Please sign in to comment.