4 out=`python3 -c 'import sys, html; print(html.escape(sys.argv[1]))' "$1"`
8 read_and_escape_file() {
14 out=`python3 -c 'import sys, urllib.parse; print(urllib.parse.quote(sys.argv[1]))' "$1"`
20 redo-ifchange "$url_file"
21 base_url=`cat "$url_file" | head -1`
22 url_protocol=`echo $base_url | cut -d ':' -f 1`
23 url_basepath=`echo $base_url | cut -d '/' -f 3-`
24 url_basepath_escaped=`escape_url "$url_basepath"`
25 basepath="$url_protocol""://""$url_basepath_escaped"
26 printf "%s" "$basepath"
30 md_file="../${1%.*}.md"
31 rst_file="../${1%.*}.rst"
32 if [ -f "$rst_file" ]; then
34 elif [ -f "$md_file" ]; then
39 redo-ifchange "$src_file"
40 printf "%s" "$src_file"
44 # Escape characters that confuse sed in a replacement string. Also replace
45 # occurences of % (which the templating uses as a variable marker) with
46 # non-printable placeholder \a (clear input of it first), to be replaced by
47 # % again when the templating has finished (so that no replacement string gets
48 # interpreted by the templating).
49 sedsafe_pattern='s/\\/\\\\/g; s/\//\\\//g; s/&/\\\&/g; $!s/$/\\/g; '
50 sed "$sedsafe_pattern" | tr -d '\a' | tr '%' '\a'