|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Update the specifications |
| 4 | + |
| 5 | +# Check if pandoc is installed |
| 6 | +if ! command -v pandoc &> /dev/null |
| 7 | +then |
| 8 | + echo "pandoc could not be found. Please install it to run this script." |
| 9 | + exit 1 |
| 10 | +fi |
| 11 | + |
| 12 | +URLS=( |
| 13 | + "https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html" |
| 14 | + "https://openid.net/specs/openid-federation-1_0.html" |
| 15 | + "https://www.w3.org/TR/vc-data-model-2.0/" |
| 16 | + "https://www.w3.org/TR/vc-jose-cose/" |
| 17 | + "https://openid.net/specs/openid-connect-core-1_0.html" |
| 18 | + "https://openid.net/specs/openid-connect-discovery-1_0.html" |
| 19 | + "https://openid.net/specs/openid-connect-rpinitiated-1_0.html" |
| 20 | + "https://openid.net/specs/openid-connect-frontchannel-1_0.html" |
| 21 | + "https://openid.net/specs/openid-connect-backchannel-1_0.html" |
| 22 | +) |
| 23 | + |
| 24 | +# For each of the specifications, fetch the content from the URL and save it |
| 25 | +# to a local markdown file. Use `pandoc` to convert the HTML to markdown. |
| 26 | +# The output file should be named after the last part of the URL, without the |
| 27 | +# extension. For example, for the URL "https://example.com/specs/spec1.html", |
| 28 | +# the output file should be "spec1.md". |
| 29 | +# The output file should be saved in the "specifications" directory. |
| 30 | + |
| 31 | +SPEC_DIR="$(dirname "$0")" |
| 32 | + |
| 33 | +for URL in "${URLS[@]}" |
| 34 | +do |
| 35 | + # Extract the filename without extension |
| 36 | + FILENAME=$(basename "$URL" .html) |
| 37 | + OUTPUT_FILE="$SPEC_DIR/$FILENAME.md" |
| 38 | + |
| 39 | + echo "Updating $FILENAME..." |
| 40 | + |
| 41 | + # Fetch and convert |
| 42 | + # -f html: from HTML |
| 43 | + # -t markdown: to Markdown, with additional extensions to clean up the output |
| 44 | + # -s: standalone |
| 45 | + # --wrap=none: optional, to avoid unnecessary line breaks if preferred |
| 46 | + |
| 47 | + PANDOC_FORMAT="markdown-fenced_divs-bracketed_spans-header_attributes-link_attributes-inline_code_attributes-raw_html-native_divs-native_spans" |
| 48 | + |
| 49 | + if curl -s "$URL" | pandoc -f html -t "$PANDOC_FORMAT" -s --wrap=none -o "$OUTPUT_FILE"; then |
| 50 | + echo "Successfully updated $OUTPUT_FILE" |
| 51 | + else |
| 52 | + echo "Failed to update $FILENAME" |
| 53 | + fi |
| 54 | +done |
| 55 | + |
| 56 | + |
0 commit comments