summaryrefslogtreecommitdiff
path: root/legacy/groffdown
diff options
context:
space:
mode:
authorBenjamin Chausse <benjamin@chausse.xyz>2021-01-03 02:07:50 -0500
committerBenjamin Chausse <benjamin@chausse.xyz>2021-01-03 02:07:50 -0500
commit3bc7d8d894fc6c50636dfb9f3c04e72cce02cb28 (patch)
tree0c6bfcfe405123ebd688cf49533ed3063c904f27 /legacy/groffdown
parente686830c06560f69489c6a9edae909da9e42f4df (diff)
Moving developpement to a C implementation
Diffstat (limited to 'legacy/groffdown')
-rwxr-xr-xlegacy/groffdown54
1 files changed, 54 insertions, 0 deletions
diff --git a/legacy/groffdown b/legacy/groffdown
new file mode 100755
index 0000000..f2810a5
--- /dev/null
+++ b/legacy/groffdown
@@ -0,0 +1,54 @@
+#!/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/institution:/\.AI\n/
+
+ s/\\begin{abstract}/\.AB/
+ s/\\end{abstract}/\.AE/
+
+ 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\.BI\ \"\1\"\ \"\2\"/g
+ s/\*\*\*\(.*\)\*\*\*\(.\)/\n\.BI\ \"\1\"\ \"\2\"\n/g
+
+ s/\*\*\(.*\)\*\*$/\n\.B\ \"\1\"\ /g
+ s/\*\*\(.*\)\*\*\(.\)$/\n\.B\ \"\1\"\ \"\2\"/g
+ s/\*\*\(.*\)\*\*\(.\)/\n\.B\ \"\1\"\ \"\2\"\n/g
+
+ s/\*\(.*\)\*$/\n\.I\ \"\1\"\ /g
+ s/\*\(.*\)\*\(.\)$/\n\.I\ \"\1\"\ \"\2\"/g
+ s/\*\(.*\)\*\(.\)/\n\.I\ \"\1\"\ \"\2\"\n/g
+
+ s/`\(.*\)`$/\n\.CW\ \"\1\"\ /g
+ s/`\(.*\)`\(.\)$/\n\.CW\ \"\1\"\ \"\2\"/g
+ s/`\(.*\)`\(.\)/\n\.CW\ \"\1\"\ \"\2\"\n/g
+
+ s/^\ ...............-\ /.IP\ \\(bu\ 10\n/g
+ s/^\ ...........-\ /.IP\ \\(bu\ 8\n/g
+ s/^\ .......-\ /.IP\ \\(bu\ 6\n/g
+ s/^\ ...-\ /.IP\ \\(bu\ 4\n/g
+ s/^-\ /.IP\ \\(bu\ 2\n/g
+ s/^\ .*-\ /.IP\ \\(bu\ 12\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