From 5cf85f14363d58fa306ff5bd10102a5769e21de2 Mon Sep 17 00:00:00 2001 From: Benjamin Chausse Date: Wed, 1 May 2019 21:01:52 -0400 Subject: Initial commit --- groffdown | 40 ++++++++++++++++++++++++++++++++++++++++ sample.md | 24 ++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100755 groffdown create mode 100644 sample.md 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! -- cgit v1.2.3