aboutsummaryrefslogtreecommitdiff
path: root/dotfiles/.local
diff options
context:
space:
mode:
authorYaroslav <contact@yaroslavps.com>2020-02-26 22:22:39 +0300
committerYaroslav <contact@yaroslavps.com>2020-02-26 22:22:39 +0300
commit7f893cb7b502e4e24b88d124504a3978cec04d3b (patch)
tree8ebd4e4841d8282784d08e21f4344d6559f499ee /dotfiles/.local
parent4125ff153814f5904476a9fa669e93c6a9d0c5dd (diff)
downloadswayrice-7f893cb7b502e4e24b88d124504a3978cec04d3b.tar.gz
swayrice-7f893cb7b502e4e24b88d124504a3978cec04d3b.zip
added little to print wdiff output to pdf; updated install script
Diffstat (limited to 'dotfiles/.local')
-rwxr-xr-xdotfiles/.local/bin/wdifftopdf24
1 files changed, 24 insertions, 0 deletions
diff --git a/dotfiles/.local/bin/wdifftopdf b/dotfiles/.local/bin/wdifftopdf
new file mode 100755
index 0000000..d44b920
--- /dev/null
+++ b/dotfiles/.local/bin/wdifftopdf
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+# Little dirty script to print wdiff's output to a pdf file using pandoc and latex
+
+title="wdiff to pdf"
+
+if [ -z "$1" ] || [ -z "$2" ]; then
+ echo "Please specify two files to wdiff"
+ exit
+fi
+
+if [ ! -z "$3" ]; then
+ title="$3"
+fi
+
+body="$(wdiff "$1" "$2" | sed 's/\[-/\\sout{\\textcolor[rgb]{0.5,0,0}{/g;s/-\]/}}/g;s/{+/\\textcolor[rgb]{0,0.64,0.1}{/g;s/+}/}/g')"
+
+file=$(readlink -f "$1")
+pandocfile="${file%.*}.md"
+resultfile="${file%.*}.pdf"
+
+printf -- "---\ntitle: %s\noutput: pdf_document\nheader-includes:\n \\\\usepackage{ulem}\n \\\\usepackage[margin=3cm]{geometry}\n---\n\n%s" "$title" "$body" > "$pandocfile"
+
+pandoc "$pandocfile" -o "$resultfile"