4 out=`python3 -c 'import sys, html; print(html.escape(sys.argv[1]))' "$1"`
8 read_and_escape_file() {
13 get_uuid_from_meta_file() {
14 probable_uuid=$(cat "$1" | head -1)
15 if printf "$probable_uuid" | grep -Eq "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"; then
16 printf "$probable_uuid"
18 echo "Malformed UUID in meta file." >&2
23 get_creation_date_from_meta_file_seconds() {
24 cat "$1" | sed -n '2p' | cut -d'_' -f1
27 get_creation_date_from_meta_file_nanoseconds() {
28 cat "$1" | sed -n '2p'
31 get_lastmod_date_from_meta_file() {
32 cat "$1" | sed -n '4p'
36 out=`python3 -c 'import sys, urllib.parse; print(urllib.parse.quote(sys.argv[1]))' "$1"`
42 redo-ifchange "$url_file"
43 base_url=`cat "$url_file" | head -1`
44 url_protocol=`echo $base_url | cut -d ':' -f 1`
45 url_basepath=`echo $base_url | cut -d '/' -f 3-`
46 url_basepath_escaped=`escape_url "$url_basepath"`
47 basepath="$url_protocol""://""$url_basepath_escaped"
48 printf "%s" "$basepath"
52 md_file="../${1%.*}.md"
53 rst_file="../${1%.*}.rst"
54 if [ -f "$rst_file" ]; then
56 elif [ -f "$md_file" ]; then
61 redo-ifchange "$src_file"
62 printf "%s" "$src_file"
66 # Escape characters that confuse sed in a replacement string. Also replace
67 # occurences of % (which the templating uses as a variable marker) with
68 # non-printable placeholder \a (clear input of it first), to be replaced by
69 # % again when the templating has finished (so that no replacement string gets
70 # interpreted by the templating).
71 sedsafe_pattern='s/\\/\\\\/g; s/\//\\\//g; s/&/\\\&/g; $!s/$/\\/g; '
72 sed "$sedsafe_pattern" | tr -d '\a' | tr '%' '\a'