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 From 108819b8d4039c5a3daad74c4773e6f3466d29f2 Mon Sep 17 00:00:00 2001 From: Benjamin Chausse Date: Tue, 28 May 2019 15:35:17 -0400 Subject: runs fully in stdout now (no .ms files created) Also, There is no .R1 .R2 now since you can just use the -c option while running refer --- groffdown | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'groffdown') diff --git a/groffdown b/groffdown index f13f96a..60e7721 100755 --- a/groffdown +++ b/groffdown @@ -5,7 +5,7 @@ dir=$(dirname "$file") base="${file%.*}" -output=$( sed -e '1s/---/\.R1\naccumulate\n\.R2\n\.EQ\ndelim\ $$\n\.EN\n/ +output=$( sed -e '1s/---/\.EQ\ndelim\ $$\n\.EN\n/ s/title:/\.TL\n/ s/author:/\.AU\n/ s/date:/\.ND\n/ @@ -51,5 +51,6 @@ output=$( sed -e '1s/---/\.R1\naccumulate\n\.R2\n\.EQ\ndelim\ $$\n\.EN\n/ # 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 +# echo "$output" > "$base".ms +echo "$output" # groff -ms $base.ms -T pdf > $base.pdf -- cgit v1.2.3 From 152d46f2ccbd5e6aea910d7242dd511b313f8236 Mon Sep 17 00:00:00 2001 From: Benjamin Chausse Date: Tue, 28 May 2019 18:50:33 -0400 Subject: delim substituted by command in compiler --- groffdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'groffdown') diff --git a/groffdown b/groffdown index 60e7721..5d20104 100755 --- a/groffdown +++ b/groffdown @@ -5,7 +5,7 @@ dir=$(dirname "$file") base="${file%.*}" -output=$( sed -e '1s/---/\.EQ\ndelim\ $$\n\.EN\n/ +output=$( sed -e '1s/---// s/title:/\.TL\n/ s/author:/\.AU\n/ s/date:/\.ND\n/ -- cgit v1.2.3 From 9baaeac2f1eb7e5553e17a83e980985644a198be Mon Sep 17 00:00:00 2001 From: Benjamin Chausse Date: Thu, 19 Sep 2019 21:52:25 -0400 Subject: Testing groffdown support by gh syntax --- .gitignore | 3 +- README.gd | 62 ++++++++++++++++++++++++++++++++++++++++ README.md | 62 ++++++++++++++++++++++++++++++++++++++++ README.pdf | Bin 0 -> 24003 bytes groffdown | 94 ++++++++++++++++++++++++++++++------------------------------- sample.md | 24 ---------------- 6 files changed, 171 insertions(+), 74 deletions(-) create mode 100644 README.gd create mode 100644 README.md create mode 100644 README.pdf delete mode 100644 sample.md (limited to 'groffdown') diff --git a/.gitignore b/.gitignore index 1c096a3..a136337 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ -# Test files -sample.* +*.pdf diff --git a/README.gd b/README.gd new file mode 100644 index 0000000..1cf90e9 --- /dev/null +++ b/README.gd @@ -0,0 +1,62 @@ +--- +title: Groffdown +author: Benjamin Chausse +date: 2019-09-19 +Markdown syntax with GNU/Troff-like compilation speeds. +--- + + +# What is Groffdown? +Groffdown aims to take the already existing (and well-known) +markdown syntax and make it compile at speed similar to the +ones of groff. The main compiler for markdown to pdf usually +being `pandoc`, it can be quite long to compile a document (up +to four seconds for one page documents +in some cases) unlike Groff which is known +to usually compile very quickly (0.1 second on average for +one page documents). + +Groffdown is a script which when run on a markdown document, +will convert the most typical markdown syntax into groff +(using the `ms` macros) to then send it to standard output. +Therefore, it can be piped directly into groff (or +it's related software). + +# Example piping workflow +groffdown .gd | refer -PS -e "-p$REFERBIB" | groff -me -ms -kejpt -T pdf > .pdf + +# Syntax goals +- Speed +- Markdown Syntax (with yaml preamble) +- LaTeX where markdown lacks + + +## Existing Syntax + +### Commands similar to markdown +- Headers (1-5) +- Italic +- Bold +- Bold & Italic +- Bullet points + +### Commands similar to LaTeX +- Abstract +- Inline equations +- Centered equations +- Citations + +### Commands similar to YAML +- Titles +- Authors +- Dates +- Author's Institution + +# Current issues +- All text formatings need to be on the same line (you can't start bold + on one line and finish on the other) Doing otherwise seems to trigger + an unescapable recursive loop on the groff side of things. + +# Needed implementations +- Numbered lists +- multi-macro compatibility (mom macros for urls) diff --git a/README.md b/README.md new file mode 100644 index 0000000..1cf90e9 --- /dev/null +++ b/README.md @@ -0,0 +1,62 @@ +--- +title: Groffdown +author: Benjamin Chausse +date: 2019-09-19 +Markdown syntax with GNU/Troff-like compilation speeds. +--- + + +# What is Groffdown? +Groffdown aims to take the already existing (and well-known) +markdown syntax and make it compile at speed similar to the +ones of groff. The main compiler for markdown to pdf usually +being `pandoc`, it can be quite long to compile a document (up +to four seconds for one page documents +in some cases) unlike Groff which is known +to usually compile very quickly (0.1 second on average for +one page documents). + +Groffdown is a script which when run on a markdown document, +will convert the most typical markdown syntax into groff +(using the `ms` macros) to then send it to standard output. +Therefore, it can be piped directly into groff (or +it's related software). + +# Example piping workflow +groffdown .gd | refer -PS -e "-p$REFERBIB" | groff -me -ms -kejpt -T pdf > .pdf + +# Syntax goals +- Speed +- Markdown Syntax (with yaml preamble) +- LaTeX where markdown lacks + + +## Existing Syntax + +### Commands similar to markdown +- Headers (1-5) +- Italic +- Bold +- Bold & Italic +- Bullet points + +### Commands similar to LaTeX +- Abstract +- Inline equations +- Centered equations +- Citations + +### Commands similar to YAML +- Titles +- Authors +- Dates +- Author's Institution + +# Current issues +- All text formatings need to be on the same line (you can't start bold + on one line and finish on the other) Doing otherwise seems to trigger + an unescapable recursive loop on the groff side of things. + +# Needed implementations +- Numbered lists +- multi-macro compatibility (mom macros for urls) diff --git a/README.pdf b/README.pdf new file mode 100644 index 0000000..29c9771 Binary files /dev/null and b/README.pdf differ diff --git a/groffdown b/groffdown index 5d20104..f2810a5 100755 --- a/groffdown +++ b/groffdown @@ -1,56 +1,54 @@ -#!/bin/sh +#!/bin/bash file=$(readlink -f "$1") dir=$(dirname "$file") base="${file%.*}" - -output=$( sed -e '1s/---// - 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/\\begin{equation}/\.EQ/ - s/\\end{equation}/\.EN/ - - s/\\\$/$delim\ @@$\ $@delim\ $$@/g - - 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/\\cite{\(.*\)}/\n\.\[\n\1\n\.\]/g - - s/^-\ /.IP\ \\(bu\ 2\n/g - - ' $1) +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 -# 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 -echo "$output" +# 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 deleted file mode 100644 index 437b6d6..0000000 --- a/sample.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -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