Skip to main content

Add coloured highlighting to the pp_xml script

ID
0ff324e
date
2024-03-27 10:34:09+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
11f4fcf
message
Add coloured highlighting to the `pp_xml` script
changed files
5 files, 12 additions, 8 deletions

Changed files

config.fish (7080) → config.fish (7122)

diff --git a/config.fish b/config.fish
index eec3456..4985b64 100644
--- a/config.fish
+++ b/config.fish
@@ -179,6 +179,7 @@ end
 
 __create_bash_script_alias flickr/flapi.sh
 __create_bash_script_alias flickr/flphoto.sh
+__create_bash_script_alias text/pp_xml.sh
 
 __create_python_script_alias flickr/fluser_lookup.py
 __create_python_script_alias fs/emptydir.py

requirements.in (342) → requirements.in (351)

diff --git a/requirements.in b/requirements.in
index 455da23..3f20c3b 100644
--- a/requirements.in
+++ b/requirements.in
@@ -19,6 +19,7 @@ naturalsort==1.5.1
 Pillow
 pillow_heif
 pip-tools
+pygments
 pypdf
 pytest
 regex

requirements.txt (4957) → requirements.txt (5019)

diff --git a/requirements.txt b/requirements.txt
index ef31309..cd12160 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -2,7 +2,7 @@
 # This file is autogenerated by pip-compile with Python 3.12
 # by the following command:
 #
-#    pip-compile
+#    pip-compile requirements.in
 #
 aiofiles==23.2.1
     # via datasette
@@ -179,6 +179,8 @@ pycryptodomex==3.19.0
     # via yt-dlp
 pyflakes==3.1.0
     # via flake8
+pygments==2.17.2
+    # via -r requirements.in
 pyparsing==3.1.1
     # via httplib2
 pypdf==3.17.2

text/README.md (8535) → text/README.md (8652)

diff --git a/text/README.md b/text/README.md
index 9c51007..44ee734 100644
--- a/text/README.md
+++ b/text/README.md
@@ -67,9 +67,9 @@ scripts = [
         "description": "removes the `list` query parameter from a YouTube URL; I use it with `youtube-dl`",
     },
     {
-        "name": "pp_xml < [TEXT]",
+        "name": "pp_xml.sh < [TEXT]",
         "description": """
-        alias for <code>xmllint --format -</code>, which pretty-prints a blob of XML.
+        alias for <code>xmllint --format - | pygmentize -l xml</code>, which pretty-prints a blob of XML with coloured syntax highlighting.
         """,
     },
     {
@@ -205,12 +205,12 @@ cog_helpers.create_description_table(folder_name=folder_name, scripts=scripts)
   </dd>
 
   <dt>
-    <a href="https://github.com/alexwlchan/scripts/blob/main/text/pp_xml">
-      <code>pp_xml < [TEXT]</code>
+    <a href="https://github.com/alexwlchan/scripts/blob/main/text/pp_xml.sh">
+      <code>pp_xml.sh < [TEXT]</code>
     </a>
   </dt>
   <dd>
-    alias for <code>xmllint --format -</code>, which pretty-prints a blob of XML.
+    alias for <code>xmllint --format - | pygmentize -l xml</code>, which pretty-prints a blob of XML with coloured syntax highlighting.
   </dd>
 
   <dt>
@@ -280,4 +280,4 @@ cog_helpers.create_description_table(folder_name=folder_name, scripts=scripts)
     "codepoints. This is a Docker wrapper around <a href="https://github.com/lunasorcery/utf8info">a tool of the same name</a> by @lunasorcery.
   </dd>
 </dl>
-<!-- [[[end]]] (checksum: 49d227b94b5dd07ca39ceeda39ef31c2) -->
\ No newline at end of file
+<!-- [[[end]]] (checksum: 53b60d7b751d2a00cb982810e1a4c682) -->
\ No newline at end of file

text/pp_xml (71) → text/pp_xml.sh (91)

diff --git a/text/pp_xml b/text/pp_xml.sh
similarity index 75%
rename from text/pp_xml
rename to text/pp_xml.sh
index f661e12..93a3783 100755
--- a/text/pp_xml
+++ b/text/pp_xml.sh
@@ -3,4 +3,4 @@
 set -o errexit
 set -o nounset
 
-xmllint --format -
+xmllint --format - | pygmentize -l xml