From 4d3abe74035d7d3c2c5d6927cc0cbb9032486b30 Mon Sep 17 00:00:00 2001
From: Jonas Smedegaard
Date: Fri, 31 Aug 2012 15:12:31 +0200
Subject: Add tidying scripts.
---
report/mkmd.sh | 18 ++++++++++++++++++
report/normalize-html.pl | 29 +++++++++++++++++++++++++++++
2 files changed, 47 insertions(+)
create mode 100755 report/mkmd.sh
create mode 100755 report/normalize-html.pl
(limited to 'report')
diff --git a/report/mkmd.sh b/report/mkmd.sh
new file mode 100755
index 0000000..39ec83d
--- /dev/null
+++ b/report/mkmd.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+set -e
+
+#stem="Greens-IslandsofResiliences"
+stem="Greens-IslandsofResilience"
+
+pdftohtml -q -c -s -i -noframes -stdout "$stem.pdf" tmp
+
+infile=tmp.html
+
+outfile="${2:-$(basename "$infile" .html).md}"
+
+#perl ./normalize-html.pl tmp.html | less
+perl ./normalize-html.pl tmp.html \
+ |pandoc --normalize --no-wrap --parse-raw -f html -t markdown -o "$stem.md"
+
+pandoc --standalone --toc -f markdown -t html5 -i "$stem.md" -o "$stem.html"
diff --git a/report/normalize-html.pl b/report/normalize-html.pl
new file mode 100755
index 0000000..7245a4e
--- /dev/null
+++ b/report/normalize-html.pl
@@ -0,0 +1,29 @@
+#!/usr/bin/perl
+
+use File::Slurp;
+
+my $_ = read_file( $ARGV[0] ) ;
+
+#s!( )! !g; # filler horisontal space
+s!( )+! !g; # filler horisontal space
+#s!(\s*
\s*)+!
!g; # filler vertical space
+s!(\s*
\s*)+!
!g; # filler vertical space
+s,
(?=(?:)?
),,ig; # filler horisontal space
+s,\s*
,,ig; # filler horisontal space
+s!\s*\s*\s*!!g; # filler vertical space
+s!!!gi; # page dividers
+#s!]+>\K
(.+?)!$1
!i; # H1
+#s!
(.+?)!$1
!i; # H1
+s!\.(ft\d+){font\-size:52px;.*?\K]*\bclass="\1"[^>]*>(.*?)
!$2
!is;
+s!\.(ft\d+){font\-size:19px;.*?\K]*\bclass="\1"[^>]*>(.*?)
!$2
!isg;
+s!\.(ft\d+){font\-size:16px;.*?\K]*\bclass="\1"[^>]*>(.*?)
!$2
!isg;
+s!]*>([^<\s][^<]*?)
!$1
!isg;
+s,]*>(?!),
,isg;
+s,,,isg;
+s,,,isg;
+s,