groffdown

Markdown to groff/troff conversion script.
Log | Files | Refs | README | LICENSE

commit 5cf85f14363d58fa306ff5bd10102a5769e21de2
Author: Benjamin Chausse <benjaminchausse@gmail.com>
Date:   Wed,  1 May 2019 21:01:52 -0400

Initial commit

Diffstat:
Agroffdown | 40++++++++++++++++++++++++++++++++++++++++
Asample.md | 24++++++++++++++++++++++++
2 files changed, 64 insertions(+), 0 deletions(-)

diff --git a/groffdown 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 @@ -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!