diff options
author | Minijackson <minijackson@riseup.net> | 2022-02-10 15:36:11 +0100 |
---|---|---|
committer | Minijackson <minijackson@riseup.net> | 2022-02-10 15:36:11 +0100 |
commit | 27e0a89d85a647a706fc70986e3ece91e33a7cbb (patch) | |
tree | 8b3a80ca1ecaa4d1336ced63963ab72bd6729f61 /documentation-highlighter/update.sh | |
parent | e7a9dd23668d99da97b2ca7a1145df8990482df3 (diff) | |
download | nix-module-doc-27e0a89d85a647a706fc70986e3ece91e33a7cbb.tar.gz nix-module-doc-27e0a89d85a647a706fc70986e3ece91e33a7cbb.zip |
mdbook: use own highlighter.js to support other languages
Diffstat (limited to 'documentation-highlighter/update.sh')
-rwxr-xr-x | documentation-highlighter/update.sh | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/documentation-highlighter/update.sh b/documentation-highlighter/update.sh new file mode 100755 index 0000000..8e31a96 --- /dev/null +++ b/documentation-highlighter/update.sh | |||
@@ -0,0 +1,44 @@ | |||
1 | #!/usr/bin/env nix-shell | ||
2 | #!nix-shell -i bash -p curl -p unzip | ||
3 | |||
4 | # Adapted from <nixpkgs>/pkgs/misc/documentation-highlighter/update.sh | ||
5 | |||
6 | set -eu | ||
7 | set -o pipefail | ||
8 | |||
9 | root=$(pwd) | ||
10 | |||
11 | if [ ! -f "./update.sh" ]; then | ||
12 | echo "Please run this script from within pkgs/misc/documentation-highlighter/!" | ||
13 | exit 1 | ||
14 | fi | ||
15 | |||
16 | scratch=$(mktemp -d -t tmp.XXXXXXXXXX) | ||
17 | function finish { | ||
18 | rm -rf "$scratch" | ||
19 | } | ||
20 | trap finish EXIT | ||
21 | |||
22 | |||
23 | mkdir $scratch/src | ||
24 | cd $scratch/src | ||
25 | |||
26 | token=$(curl https://highlightjs.org/download/ -c "$scratch/jar" \ | ||
27 | | grep csrf \ | ||
28 | | cut -d'"' -f6) | ||
29 | |||
30 | curl --header "Referer: https://highlightjs.org/download/"\ | ||
31 | -b "$scratch/jar" \ | ||
32 | --data "csrfmiddlewaretoken=$token&nix.js=on&bash.js=on&python.js=on&makefile.js=on&ini.js=on" \ | ||
33 | https://highlightjs.org/download/ > $scratch/out.zip | ||
34 | |||
35 | unzip "$scratch/out.zip" | ||
36 | out="$root/" | ||
37 | mkdir -p "$out" | ||
38 | cp ./{highlight.min.js,LICENSE,styles/mono-blue.min.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" | ||