summary refs log tree commit diff
path: root/pkgs/misc/documentation-highlighter/update.sh
diff options
context:
space:
mode:
authorGraham Christensen <graham@grahamc.com>2018-03-26 21:06:42 -0400
committerGraham Christensen <graham@grahamc.com>2018-03-26 21:23:41 -0400
commita8d08b04a2d2397ad1b189ac80981513f03eb891 (patch)
treed773f37586014e5d5c0c98051096c280a5109ef4 /pkgs/misc/documentation-highlighter/update.sh
parent63406fa1cf98d500aaa0ad4735ff248d0727723b (diff)
downloadnixpkgs-a8d08b04a2d2397ad1b189ac80981513f03eb891.tar
nixpkgs-a8d08b04a2d2397ad1b189ac80981513f03eb891.tar.gz
nixpkgs-a8d08b04a2d2397ad1b189ac80981513f03eb891.tar.bz2
nixpkgs-a8d08b04a2d2397ad1b189ac80981513f03eb891.tar.lz
nixpkgs-a8d08b04a2d2397ad1b189ac80981513f03eb891.tar.xz
nixpkgs-a8d08b04a2d2397ad1b189ac80981513f03eb891.tar.zst
nixpkgs-a8d08b04a2d2397ad1b189ac80981513f03eb891.zip
documentation-highlighter: init
Diffstat (limited to 'pkgs/misc/documentation-highlighter/update.sh')
-rwxr-xr-xpkgs/misc/documentation-highlighter/update.sh42
1 files changed, 42 insertions, 0 deletions
diff --git a/pkgs/misc/documentation-highlighter/update.sh b/pkgs/misc/documentation-highlighter/update.sh
new file mode 100755
index 00000000000..3b77af4af41
--- /dev/null
+++ b/pkgs/misc/documentation-highlighter/update.sh
@@ -0,0 +1,42 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -i bash -p curl -p unzip
+
+set -eu
+set -o pipefail
+
+root=$(pwd)
+
+if [ ! -f "./update.sh" ]; then
+    echo "Please run this script from within pkgs/misc/documentation-highlighter/!"
+    exit 1
+fi
+
+scratch=$(mktemp -d -t tmp.XXXXXXXXXX)
+function finish {
+  rm -rf "$scratch"
+}
+trap finish EXIT
+
+
+mkdir $scratch/src
+cd $scratch/src
+
+token=$(curl https://highlightjs.org/download/ -c "$scratch/jar" \
+    | grep csrf \
+    | cut -d"'" -f6)
+
+curl --header "Referer: https://highlightjs.org/download/"\
+    -b "$scratch/jar" \
+    --data "csrfmiddlewaretoken=$token&nix.js=on&bash.js=on" \
+    https://highlightjs.org/download/ > $scratch/out.zip
+
+unzip "$scratch/out.zip"
+out="$root/"
+mkdir -p "$out"
+cp ./{highlight.pack.js,LICENSE,styles/mono-blue.css} "$out"
+
+(
+    echo "This file was generated with pkgs/misc/documentation-highlighter/update.sh"
+    echo ""
+    cat README.md
+) > "$out/README.md"