summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Chausse <benjaminchausse@gmail.com>2019-05-01 21:01:52 -0400
committerBenjamin Chausse <benjaminchausse@gmail.com>2019-05-01 21:01:52 -0400
commit5cf85f14363d58fa306ff5bd10102a5769e21de2 (patch)
treeebf9c3ef5cc4d45df5aa5d918da28def01df2227
Initial commit
-rwxr-xr-xgroffdown40
-rw-r--r--sample.md24
2 files changed, 64 insertions, 0 deletions
diff --git a/groffdown b/groffdown
new file mode 100755
index 0000000..f6c9820
--- /dev/null
+++ b/groffdown
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+file=$(readlink -f "$1")
+dir=$(dirname "$file")
+base="${file%.*}"
+
+output=$( sed -e '1,1d
+ s/title:/\.TL\n/
+ s/author:/\.AU\n/
+ s/date:/\.ND\n/
+ s/---//
+
+ s/^\#####.\(.*\)/\.NH 5\n\1\n\.PP/g
+ s/^\####.\(.*\)/\.NH 4\n\1\n\.PP/g
+ s/^\###.\(.*\)/\.NH 3\n\1\n\.PP/g
+ s/^\##.\(.*\)/\.NH 2\n\1\n\.PP/g
+ s/^\#.\(.*\)/\.NH 1\n\1\n\.PP/g
+
+ s/\*\*\*\(.*\)\*\*\*$/\n\.BI\ \"\1\"\ /g
+ s/\*\*\(.*\)\*\*$/\n\.B\ \"\1\"\ /g
+ s/\*\(.*\)\*$/\n\.I\ \"\1\"\ /g
+
+ s/\*\*\*\(.*\)\*\*\*\(.\)$/\n\.BI\ \"\1\"\ \"\2\"/g
+ s/\*\*\(.*\)\*\*\(.\)$/\n\.B\ \"\1\"\ \"\2\"/g
+ s/\*\(.*\)\*\(.\)$/\n\.I\ \"\1\"\ \"\2\"/g
+
+ s/\*\*\*\(.*\)\*\*\*\(.\)/\n\.BI\ \"\1\"\ \"\2\"\n/g
+ s/\*\*\(.*\)\*\*\(.\)/\n\.B\ \"\1\"\ \"\2\"\n/g
+ s/\*\(.*\)\*\(.\)/\n\.I\ \"\1\"\ \"\2\"\n/g
+
+ ' $1)
+echo "$output" | groff -me -ms -kejpt -T pdf > $base.pdf
+
+# echo "$output" > $base.ms
+# groff -ms $base.ms -T pdf > $base.pdf
+
+# echo "$output"
+
+# $output >> output.ms
+# s/\*\*\*.*\*\*\*/Hi\1hi/g
diff --git a/sample.md b/sample.md
new file mode 100644
index 0000000..437b6d6
--- /dev/null
+++ b/sample.md
@@ -0,0 +1,24 @@
+---
+title: The Flight of the Bumblebee
+author: Benjamin Chausse
+date: 21 Septembre 2042
+---
+
+# Heading 1
+This is a test paragraph which is meant to be relatively long
+for what it is meant to express. I expect it
+to contain (at least) some *italic* text, but
+perhaps some text that is **bold**!
+Perhaps even, if I'm lucky, I may, **very well**
+want to integrate some ***Bold and italic*** text!
+*Even* at the **beggining of line**...
+This is an amazing alternative!!!
+
+## Assistant to the Regional Heading
+Yes this was a *The Office* joke...
+
+### I will now
+
+#### Got up to....
+
+##### FIVE! YAAAY!