From 7f893cb7b502e4e24b88d124504a3978cec04d3b Mon Sep 17 00:00:00 2001 From: Yaroslav Date: Wed, 26 Feb 2020 22:22:39 +0300 Subject: added little to print wdiff output to pdf; updated install script --- dotfiles/.local/bin/wdifftopdf | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 dotfiles/.local/bin/wdifftopdf (limited to 'dotfiles/.local') 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" -- cgit v1.2.3