1#!/usr/bin/env nix-shell
2#!nix-shell -i bash -p curl -p unzip
3
4set -eu
5set -o pipefail
6
7root=$(pwd)
8
9if [ ! -f "./update.sh" ]; then
10 echo "Please run this script from within pkgs/misc/documentation-highlighter/!"
11 exit 1
12fi
13
14scratch=$(mktemp -d -t tmp.XXXXXXXXXX)
15function finish {
16 rm -rf "$scratch"
17}
18trap finish EXIT
19
20
21mkdir $scratch/src
22cd $scratch/src
23
24curl \
25 -X POST \
26 -H 'Content-Type: application/json' \
27 --data-raw '{
28 "api": 2,
29 "languages": ["bash", "nix", "shell"]
30 }' \
31 https://highlightjs.org/api/download > $scratch/out.zip
32
33
34unzip "$scratch/out.zip"
35out="$root/"
36mkdir -p "$out"
37cp ./highlight.min.js "$out/highlight.pack.js"
38cp ./{LICENSE,styles/mono-blue.css} "$out"
39
40(
41 echo "This file was generated with pkgs/misc/documentation-highlighter/update.sh"
42 echo ""
43 cat README.md
44) > "$out/README.md"