home · contact · privacy
Move all scripts etc. to their own directory.
[redo-blog] / processor / helpers.sh
diff --git a/processor/helpers.sh b/processor/helpers.sh
new file mode 100644 (file)
index 0000000..c90e077
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+escape_html()
+{
+out=`python3 -c 'import sys, html; print(html.escape(sys.argv[1]))' "$1"`
+printf "%s" "$out"
+}
+
+read_and_escape_file()
+{
+in=`cat "$1"`
+escape_html "$in"
+}
+
+escape_url()
+{
+out=`python3 -c 'import sys, urllib.parse; print(urllib.parse.quote(sys.argv[1]))' "$1"`
+printf "%s" "$out"
+}