From 7d24844312e7359434ab91b858c04e606d82a316 Mon Sep 17 00:00:00 2001 From: Benjamin Chausse Date: Mon, 27 May 2019 16:27:09 -0400 Subject: EQN improvements as well as refer - $$ concatenates inline math - \$ escapes inline math - \begin{equation} - \end{equation} format --- groffdown | 72 ++++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 39 insertions(+), 33 deletions(-) (limited to 'groffdown') 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/\*\*\*\(.*\)\*\*\*\(.\)$/\n\.BI\ \"\1\"\ \"\2\"/g - s/\*\*\*\(.*\)\*\*\*\(.\)/\n\.BI\ \"\1\"\ \"\2\"\n/g + s/\\begin{equation}/\.EQ/ + s/\\end{equation}/\.EN/ - s/\*\*\(.*\)\*\*$/\n\.B\ \"\1\"\ /g - s/\*\*\(.*\)\*\*\(.\)$/\n\.B\ \"\1\"\ \"\2\"/g - s/\*\*\(.*\)\*\*\(.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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 -- cgit v1.2.3