summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Chausse <benjaminchausse@gmail.com>2019-05-27 16:27:09 -0400
committerBenjamin Chausse <benjaminchausse@gmail.com>2019-05-27 16:27:09 -0400
commit7d24844312e7359434ab91b858c04e606d82a316 (patch)
tree815e5a34dc474bc480862d82b1e3adccdc6e83c4
parent35e3b3c670eadd252e539cf90e6c57589359e858 (diff)
EQN improvements as well as refer
- $$ concatenates inline math - \$ escapes inline math - \begin{equation} - \end{equation} format
-rw-r--r--.gitignore2
-rwxr-xr-xgroffdown72
2 files changed, 41 insertions, 33 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..1c096a3
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+# Test files
+sample.*
diff --git a/groffdown b/groffdown
index 6e490a4..f13f96a 100755
--- a/groffdown
+++ b/groffdown
@@ -1,49 +1,55 @@
-#!/bin/bash
+#!/bin/sh
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/
+output=$( sed -e '1s/---/\.R1\naccumulate\n\.R2\n\.EQ\ndelim\ $$\n\.EN\n/
+ s/title:/\.TL\n/
+ s/author:/\.AU\n/
+ s/date:/\.ND\n/
+ s/institution:/\.AI\n/
- 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/\\begin{abstract}/\.AB/
+ s/\\end{abstract}/\.AE/
- s/\*\*\*\(.*\)\*\*\*$/\n\.BI\ \"\1\"\ /g
- s/\*\*\*\(.*\)\*\*\*\(.\)$/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" | groff -me -ms -kejpt -T pdf > $base.pdf
+ 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
-echo "$output" > $base.ms
-groff -ms $base.ms -T pdf > $base.pdf
+ s/\\cite{\(.*\)}/\n\.\[\n\1\n\.\]/g
-# echo "$output"
+ s/^-\ /.IP\ \\(bu\ 2\n/g
+
+ ' $1)
+# echo "$output" | groff -me -ms -kejpt -T pdf > $base.pdf
-# $output >> output.ms
-# s/\*\*\*.*\*\*\*/Hi\1hi/g
+# This script will compile the md document into a groff .ms file.
+# Good for reviewing compiled .ms text for debugging the ms output
+# as you code.
+echo "$output" > "$base".ms
+# groff -ms $base.ms -T pdf > $base.pdf