From 5ab7d1080f0f009fa6df2d02de4ddcf38f0beb9c Mon Sep 17 00:00:00 2001 From: Alhadis Date: Wed, 8 Sep 2021 22:47:31 +1000 Subject: [PATCH 1/8] Improve syntax highlighting of command examples --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 52c318a..c40c593 100644 --- a/README.md +++ b/README.md @@ -3,13 +3,13 @@ Like jq, but for HTML. Uses CSS selectors to extract bits of content from HTML f ## Installation -``` +```sh cargo install htmlq ``` ## Usage -``` +```console $ htmlq -h htmlq 0.2.0 Runs CSS selectors on HTML @@ -38,7 +38,7 @@ $ ### Using with cURL to find part of a page by ID -```bash +```console $ curl --silent https://www.rust-lang.org/ | htmlq '#get-help'

Get help!

@@ -61,7 +61,7 @@ $ curl --silent https://www.rust-lang.org/ | htmlq '#get-help' ### Find all the links in a page -```bash +```console $ curl --silent https://www.rust-lang.org/ | htmlq --attribute href a / /tools/install @@ -79,7 +79,7 @@ $ ### Get the text content of a post -``` +```console $ curl --silent https://nixos.org/nixos/about.html | htmlq --text .main About NixOS @@ -100,7 +100,7 @@ to change that. NixOS has many innovative features: (This is a bit of a work in progress) -``` +```console $ curl --silent https://mgdm.net | htmlq --pretty '#posts'

I write about... From da8150ff98be86051194fd65e6747baad3018475 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Wed, 8 Sep 2021 22:54:51 +1000 Subject: [PATCH 2/8] Add link to JQ's homepage and tidy preamble --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c40c593..2205cf6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # htmlq -Like jq, but for HTML. Uses CSS selectors to extract bits of content from HTML files. Mozilla's MDN has a good reference for CSS selector syntax. +Like [`jq`](https://stedolan.github.io/jq/), but for HTML. Uses [CSS selectors](https://developer.mozilla.org/en-US/docs/Learn/CSS/Introduction_to_CSS/Selectors) to extract bits of content from HTML files. ## Installation From daa083c4290be3f24064f437eb793d8db0d5bb0d Mon Sep 17 00:00:00 2001 From: Alhadis Date: Wed, 8 Sep 2021 23:45:10 +1000 Subject: [PATCH 3/8] Include an example showing how to highlight output Refs: https://github.com/mgdm/htmlq/pull/17#issuecomment-915206105 --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 2205cf6..3440a69 100644 --- a/README.md +++ b/README.md @@ -116,3 +116,11 @@ $ curl --silent https://mgdm.net | htmlq --pretty '#posts' [...] ``` + +### Syntax highlighting with [`bat`](https://github.com/sharkdp/bat) + +```console +$ curl -sL https://mdn.io/Array | htmlq '#description ~ *' | bat -l html +``` + +> ![Syntax highlighted output](https://user-images.githubusercontent.com/2346707/132520957-2098026d-7513-4771-a590-ca54c0e14f09.png) From 21f430cfb5ceeaa5d1b30bc128c065dbf076fbd6 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Wed, 8 Sep 2021 23:55:49 +1000 Subject: [PATCH 4/8] Limit screenshot width to 700px --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3440a69..8c69ce9 100644 --- a/README.md +++ b/README.md @@ -123,4 +123,4 @@ $ curl --silent https://mgdm.net | htmlq --pretty '#posts' $ curl -sL https://mdn.io/Array | htmlq '#description ~ *' | bat -l html ``` -> ![Syntax highlighted output](https://user-images.githubusercontent.com/2346707/132520957-2098026d-7513-4771-a590-ca54c0e14f09.png) +> Syntax highlighted output From 2be26518fd179f756db7a1e3392ef5381c82b91b Mon Sep 17 00:00:00 2001 From: Alhadis Date: Thu, 9 Sep 2021 21:15:01 +1000 Subject: [PATCH 5/8] Use a more reproducible highlighting example Refs: https://github.com/mgdm/htmlq/pull/18/files#r705092112 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8c69ce9..9be3672 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,7 @@ $ curl --silent https://mgdm.net | htmlq --pretty '#posts' ### Syntax highlighting with [`bat`](https://github.com/sharkdp/bat) ```console -$ curl -sL https://mdn.io/Array | htmlq '#description ~ *' | bat -l html +$ curl -s example.com | htmlq 'body' | bat -l html ``` -> Syntax highlighted output +> Syntax highlighted output From 4ef7162a2cc902ade4745c2b9cab734a25288ffc Mon Sep 17 00:00:00 2001 From: Alhadis Date: Fri, 10 Sep 2021 16:21:18 +1000 Subject: [PATCH 6/8] Align with #11 and crop command from screenshot --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9be3672..36e0878 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,7 @@ $ curl --silent https://mgdm.net | htmlq --pretty '#posts' ### Syntax highlighting with [`bat`](https://github.com/sharkdp/bat) ```console -$ curl -s example.com | htmlq 'body' | bat -l html +$ curl --silent example.com | htmlq 'body' | bat --language html ``` -> Syntax highlighted output +> Syntax highlighted output From 06fad97ec396fc255c052086242278ef6b9aa448 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Wed, 15 Sep 2021 20:01:45 +1000 Subject: [PATCH 7/8] Add permalinks to headings added in 014ae25 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6f0e198..e2df1fd 100644 --- a/README.md +++ b/README.md @@ -3,13 +3,13 @@ Like [`jq`](https://stedolan.github.io/jq/), but for HTML. Uses [CSS selectors]( ## Installation -### Cargo +### [Cargo](https://docs.rs/htmlq) ```sh cargo install htmlq ``` -### Homebrew +### [Homebrew](https://formulae.brew.sh/formula/htmlq) ```sh brew install htmlq From a84cf185b38dd490497f204d635a866e71842d3b Mon Sep 17 00:00:00 2001 From: Alhadis Date: Wed, 15 Sep 2021 20:03:34 +1000 Subject: [PATCH 8/8] Remove redundant trailing lines in console output --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index e2df1fd..215e235 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,6 @@ OPTIONS: ARGS: ... The CSS expression to select -$ ``` ## Examples @@ -82,7 +81,6 @@ https://blog.rust-lang.org/ https://blog.rust-lang.org/2019/04/25/Rust-1.34.1.html https://blog.rust-lang.org/2018/12/06/Rust-1.31-and-rust-2018.html [...] -$ ``` ### Get the text content of a post