change the name from markup to tttml - tttml - converters for a simpler syntax than markdown HTML git clone git://bitreich.org/tttml git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/tttml DIR Log DIR Files DIR Refs DIR Tags DIR README --- DIR commit fd08ceaed88288f846c89bbb7b191379064625ee DIR parent 61a2462794d4f5804122646f524c7913bc809529 HTML Author: Josuah Demangeon <mail@josuah.net> Date: Sun, 6 May 2018 17:31:15 +0200 change the name from markup to tttml Diffstat: M Makefile | 6 +++--- M README | 33 +++++++++++++++---------------- D markup-fmt | 136 ------------------------------- D markup-fmt.1 | 64 ------------------------------- D markup-gopher.1 | 106 ------------------------------ A tttml-fmt | 135 +++++++++++++++++++++++++++++++ A tttml-fmt.1 | 65 +++++++++++++++++++++++++++++++ R markup-gopher -> tttml-gopher | 0 A tttml-gopher.1 | 106 ++++++++++++++++++++++++++++++ R markup-html -> tttml-html | 0 R markup.5 -> tttml.5 | 0 11 files changed, 325 insertions(+), 326 deletions(-) --- DIR diff --git a/Makefile b/Makefile @@ -1,6 +1,6 @@ -BIN = markup-fmt markup-gopher -MAN1 = markup-fmt.1 markup-gopher.1 -MAN5 = markup.5 +BIN = tttml-fmt tttml-gopher +MAN1 = tttml-fmt.1 tttml-gopher.1 +MAN5 = tttml.5 all: DIR diff --git a/README b/README @@ -78,7 +78,7 @@ DESCRIPTION SEE ALSO smu(1), simple markup - markdown like syntax: - https://github.com/Gottox/smu + https://github.com/Gottox/smu AUTHORS Josuah Demangeon <mail@josuah.net> @@ -87,20 +87,20 @@ OpenBSD 6.3 April 19, 2018 OpenBSD 6.3 ------------------------------------------------------------------------------ -MARKUP-FMT(1) General Commands Manual MARKUP-FMT(1) +TTTML-FMT(1) General Commands Manual TTTML-FMT(1) NAME - markup-fmt pretty-print and fix a markup file + tttml-fmt format/pretty-print a tttml file SYNOPSIS - markup-fmt [file...] + tttml-fmt [file...] DESCRIPTION - The markup-fmt utility reformat a markup(5) and print valid format to + The tttml-fmt utility reformat a tttml(5) and print valid format to stdout. - Most markdown documents can be converted to markup(5) format if they do - not have recursive elents such as nested lists or quotes. + Most markdown documents can be converted to tttml(5) with if they do not + have recursive elents such as nested lists or nested quotes. The paragraphs are being filled to 80 columns, @@ -116,8 +116,8 @@ DESCRIPTION on their own line. SEE ALSO - markup-gopher(1), smu(1), markup(5), simple markup - markdown like - syntax: https://github.com/Gottox/smu + tttml-gopher(1), smu(1), tttml(5), simple tttml - markdown like syntax: + https://github.com/Gottox/smu AUTHORS Josuah Demangeon <mail@josuah.net> @@ -126,20 +126,19 @@ OpenBSD 6.3 April 19, 2018 OpenBSD 6.3 ------------------------------------------------------------------------------ -MARKUP-GOPHER(1) General Commands Manual MARKUP-GOPHER(1) +TTTML-GOPHER(1) General Commands Manual TTTML-GOPHER(1) NAME - markup-gopher generate a gophermap from a markup file + tttml-gopher generate a gophermap from a tttml file SYNOPSIS - markup-opher host port [file...] + tttml-gopher host port [file...] DESCRIPTION - The markup-gopher utility convert file to a gophermap format, simply by + The tttml-gopher utility convert file to a gophermap format, simply by converting all link entries, converting tabs into spaces and printing the rest. host and port is used to set the host in links that do not have a - host, such as - /path/to/file.txt + host, such as /path/to/file.txt All URI starting with a / and ending with a / are printed using the 1 entry type @@ -148,8 +147,8 @@ DESCRIPTION using the 0 All URI starting with 0, 1, 7, 8, 9, a, g, h or - I followed by a / and all li gopher:// URI are printed - using the corresponding entry type. + I followed by a / and all gopher:// URI are printed using + the corresponding entry type. All other URI are printed using the h entry type DIR diff --git a/markup-fmt b/markup-fmt @@ -1,136 +0,0 @@ -#!/usr/bin/awk -f - -function fold(blk, first, prefix) -{ - len = length(prefix); - gsub("\t", " ", blk); - gsub(" +", " ", blk); - gsub("\\*+", "*", blk); gsub("_+", "_", blk); gsub("/+", "/", blk); - sub("^ *", "", blk); sub(" *$", "", blk); - gsub("[.!?] ", "& ", blk); - - if (match(blk, /^[0-9.]+ /)) - blk = substr(blk, RMATCH, RLENGTH - 1) substr(blk, RLENGTH + 1); - - for (p = first; (line = substr(blk, 1, 80 - len)) != ""; p = prefix) { - if (length(line) == 80 - len) - sub(" +[^ ]*$", "", line); - print(p line); - blk = substr(blk, length(line) + 1); - sub("^ *", "", blk); - } -} - -function tag(blk) -{ - match(blk, /^\*[^*]*\*:/); - print(substr(blk, 1, RLENGTH)); - blk = substr(blk, RLENGTH + 1); - fold(blk, "", ""); -} - -function link(blk) -{ - match(blk, /^\[[^]]*\]: [^ \t]*/) - print(substr(blk, 0, RLENGTH)); - fold(substr(blk, RLENGTH + 1), "", ""); -} - -function literal() -{ - print(""); - do { - print($0); - } while (getline && match($0, /^\t/)); -} - -function title(blk) -{ - fold(blk, "", ""); - half = "========================================"; - print(half half); -} - -function heading(blk) -{ - print("\n"); - fold(blk, "", ""); - half = "----------------------------------------"; - print(half half); -} - -function subheading(str) -{ - print("\n\n### " str); -} - -function printblk(blk) -{ - if (blk) print(""); - - if (type == PARAGRAPH) fold(blk, "", ""); - else if (type == QUOTE) fold(blk, "> ", "> "); - else if (type == LIST) fold(blk, "- ", " "); - else if (type == TAG) tag(blk); - else if (type == LINK) link(blk); -} - -BEGIN { - PARAGRAPH = 1; QUOTE = 2; LIST = 3; TAG = 4; LINK = 5; -} - -# print the append line set type or skip append -# last block to current print the to block -# right now block or not current block (see the end) - -/^[ \t]*$/ { - printblk(blk); blk = $0; type = PARAGRAPH; next; -} - -sub(/^[-*] /, "") { - printblk(blk); blk = $0; type = LIST; next; -} - -/^\[[^]]*\]: / { - printblk(blk); blk = $0; type = LINK; next; -} - -/^\*[^*]*\*:/ { - printblk(blk); blk = $0; type = TAG; next; -} - -sub(/^> */, "") { - type = QUOTE; -} - -/^\t/ { - printblk(blk); blk = ""; literal(); next; -} - -sub(/^# +/, "") { - printblk(blk); blk = ""; title($0); next; -} - -sub(/^## +/, "") { - printblk(blk); blk = ""; heading($0); next; -} - -sub(/^###+ */, "") { - printblk(blk); blk = ""; subheading($0); next; -} - -/^=+$/ { - title(blk); blk = ""; next; -} - -/^-+$/ { - heading(blk); blk = ""; next; -} - -{ - blk = blk " " $0; -} - -END { - printblk(blk); -} DIR diff --git a/markup-fmt.1 b/markup-fmt.1 @@ -1,64 +0,0 @@ -.Dd $Mdocdate: April 19 2018$ -.Dt MARKUP-FMT 1 -.Os -. -. -.Sh NAME -. -.Nm markup-fmt -.Nd pretty-print and fix a markup file -. -. -.Sh SYNOPSIS -. -.Nm -.Op Ar file... -. -. -.Sh DESCRIPTION -. -The -.Nm -utility reformat a -.Xr markup 5 -and print valid format to stdout. -. -.Pp -Most markdown documents can be converted to -.Xr markup 5 -format if they do not have recursive elents such as nested lists -or quotes. -. -.Bl -bullet -width 6n -. -.It -The paragraphs are being filled to 80 columns, -. -.It -The empty lines are set as apropriate -. -.It -The blocks merged together are separated, such as lists without -separating blank spaces. -. -.It -The title and heading horizontal lines are expanded to 80 columns. -. -.It -The tags with the tagline merged with the paragraph are separated -on their own line. -. -.El -. -.Sh SEE ALSO -. -.Xr markup-gopher 1 , -.Xr smu 1 , -.Xr markup 5 , -.Lk https://github.com/Gottox/smu "simple markup - markdown like syntax" -. -. -.Sh AUTHORS -. -.An Josuah Demangeon -.Aq Mt mail@josuah.net DIR diff --git a/markup-gopher.1 b/markup-gopher.1 @@ -1,106 +0,0 @@ -.Dd $Mdocdate: April 19 2018$ -.Dt MARKUP-GOPHER 1 -.Os -. -. -.Sh NAME -. -.Nm markup-gopher -.Nd generate a gophermap from a markup file -. -. -.Sh SYNOPSIS -. -.Nm -.Ar host -.Ar port -.Op Ar file... -. -. -.Sh DESCRIPTION -. -The -.Nm -utility convert -.Ar file -to a gophermap format, simply by converting all link entries, -converting tabs into spaces and printing the rest. -. -.Ar host -and -.Ar port -is used to set the host in links that do not have a host, such as -.Pa /path/to/file.txt -. -.Bl -bullet -width 6n -. -.It -All URI starting with a -.Sq Li / -and ending with a -.Sq Li / -are printed using the -.Sq Li 1 -entry type -. -.It -All URI starting with a -.Sq Li / -and not ending with a -.Sq Li / -are printed using the -.Sq Li 0 -. -.It -All URI starting with -.Sq Li 0 , -.Sq Li 1 , -.Sq Li 7 , -.Sq Li 8 , -.Sq Li 9 , -.Sq Li a , -.Sq Li g , -.Sq Li h -or -.Sq Li I -followed by a -.Sq Li / -and all -.Dq Li gopher:// -URI are printed using the corresponding entry type. -. -.It -All other URI are printed using the -.Sq Li h -entry type -. -.El -. -.\" .Sh CONTEXT -.\" For section 9 functions only. -.\" .Sh RETURN VALUES -.\" For sections 2, 3, and 9 function return values only. -.\" .Sh ENVIRONMENT -.\" For sections 1, 6, 7, and 8 only. -.\" .Sh FILES -.\" .Sh EXIT STATUS -.\" For sections 1, 6, and 8 only. -.\" .Sh EXAMPLES -.\" .Sh DIAGNOSTICS -.\" For sections 1, 4, 6, 7, 8, and 9 printf/stderr messages only. -.\" .Sh ERRORS -.\" For sections 2, 3, 4, and 9 errno settings only. -.\" .Sh SEE ALSO -.\" .Xr foobar 1 -.\" .Sh STANDARDS -.\" .Sh HISTORY -. -. -.Sh AUTHORS -. -.An Josuah Demangeon -.Aq Mt mail@josuah.net -. -. -.\" .Sh CAVEATS -.\" .Sh BUGS DIR diff --git a/tttml-fmt b/tttml-fmt @@ -0,0 +1,135 @@ +#!/usr/bin/awk -f + +function fold(blk, first, prefix) +{ + len = length(prefix); + gsub("\t", " ", blk); + gsub(" +", " ", blk); + sub("^ *", "", blk); sub(" *$", "", blk); + gsub("[.!?] ", "& ", blk); + + if (match(blk, /^[0-9.]+ /)) + blk = substr(blk, RMATCH, RLENGTH - 1) substr(blk, RLENGTH + 1); + + for (p = first; (line = substr(blk, 1, 80 - len)) != ""; p = prefix) { + if (length(line) == 80 - len) + sub(" +[^ ]*$", "", line); + print(p line); + blk = substr(blk, length(line) + 1); + sub("^ *", "", blk); + } +} + +function tag(blk) +{ + match(blk, /^\*[^*]*\*:/); + print(substr(blk, 1, RLENGTH)); + blk = substr(blk, RLENGTH + 1); + fold(blk, "", ""); +} + +function link(blk) +{ + match(blk, /^\[[^]]*\]: [^ \t]*/) + print(substr(blk, 0, RLENGTH)); + fold(substr(blk, RLENGTH + 1), "", ""); +} + +function literal() +{ + print(""); + do { + print($0); + } while (getline && match($0, /^\t/)); +} + +function title(blk) +{ + fold(blk, "", ""); + half = "========================================"; + print(half half); +} + +function heading(blk) +{ + print("\n"); + fold(blk, "", ""); + half = "----------------------------------------"; + print(half half); +} + +function subheading(str) +{ + print("\n\n### " str); +} + +function printblk(blk) +{ + if (blk) print(""); + + if (type == PARAGRAPH) fold(blk, "", ""); + else if (type == QUOTE) fold(blk, "> ", "> "); + else if (type == LIST) fold(blk, "- ", " "); + else if (type == TAG) tag(blk); + else if (type == LINK) link(blk); +} + +BEGIN { + PARAGRAPH = 1; QUOTE = 2; LIST = 3; TAG = 4; LINK = 5; +} + +# print the append line set type or skip append +# last block to current print the to block +# right now block or not current block (see the end) + +/^[ \t]*$/ { + printblk(blk); blk = $0; type = PARAGRAPH; next; +} + +sub(/^[-*] /, "") { + printblk(blk); blk = $0; type = LIST; next; +} + +/^\[[^]]*\]: / { + printblk(blk); blk = $0; type = LINK; next; +} + +/^\*[^*]*\*:/ { + printblk(blk); blk = $0; type = TAG; next; +} + +sub(/^> */, "") { + type = QUOTE; +} + +/^\t/ { + printblk(blk); blk = ""; literal(); next; +} + +sub(/^# +/, "") { + printblk(blk); blk = ""; title($0); next; +} + +sub(/^## +/, "") { + printblk(blk); blk = ""; heading($0); next; +} + +sub(/^###+ */, "") { + printblk(blk); blk = ""; subheading($0); next; +} + +/^=+$/ { + title(blk); blk = ""; next; +} + +/^-+$/ { + heading(blk); blk = ""; next; +} + +{ + blk = blk " " $0; +} + +END { + printblk(blk); +} DIR diff --git a/tttml-fmt.1 b/tttml-fmt.1 @@ -0,0 +1,65 @@ +.Dd $Mdocdate: April 19 2018$ +.Dt TTTML-FMT 1 +.Os +. +. +.Sh NAME +. +.Nm tttml-fmt +.Nd format/pretty-print a tttml file +. +. +.Sh SYNOPSIS +. +.Nm +.Op Ar file... +. +. +.Sh DESCRIPTION +. +The +.Nm +utility reformat a +.Xr tttml 5 +and print valid format to stdout. +. +.Pp +Most markdown documents can be converted to +.Xr tttml 5 +with +.nm +if they do not have recursive elents such as nested lists or nested quotes. +. +.Bl -bullet -width 6n +. +.It +The paragraphs are being filled to 80 columns, +. +.It +The empty lines are set as apropriate +. +.It +The blocks merged together are separated, such as lists without +separating blank spaces. +. +.It +The title and heading horizontal lines are expanded to 80 columns. +. +.It +The tags with the tagline merged with the paragraph are separated +on their own line. +. +.El +. +.Sh SEE ALSO +. +.Xr tttml-gopher 1 , +.Xr smu 1 , +.Xr tttml 5 , +.Lk https://github.com/Gottox/smu "simple tttml - markdown like syntax" +. +. +.Sh AUTHORS +. +.An Josuah Demangeon +.Aq Mt mail@josuah.net DIR diff --git a/markup-gopher b/tttml-gopher DIR diff --git a/tttml-gopher.1 b/tttml-gopher.1 @@ -0,0 +1,106 @@ +.Dd $Mdocdate: April 19 2018$ +.Dt TTTML-GOPHER 1 +.Os +. +. +.Sh NAME +. +.Nm tttml-gopher +.Nd generate a gophermap from a tttml file +. +. +.Sh SYNOPSIS +. +.Nm +.Ar host +.Ar port +.Op Ar file... +. +. +.Sh DESCRIPTION +. +The +.Nm +utility convert +.Ar file +to a gophermap format, simply by converting all link entries, +converting tabs into spaces and printing the rest. +. +.Ar host +and +.Ar port +is used to set the host in links that do not have a host, such as +.Pa /path/to/file.txt +. +.Bl -bullet -width 6n +. +.It +All URI starting with a +.Sq Li / +and ending with a +.Sq Li / +are printed using the +.Sq Li 1 +entry type +. +.It +All URI starting with a +.Sq Li / +and not ending with a +.Sq Li / +are printed using the +.Sq Li 0 +. +.It +All URI starting with +.Sq Li 0 , +.Sq Li 1 , +.Sq Li 7 , +.Sq Li 8 , +.Sq Li 9 , +.Sq Li a , +.Sq Li g , +.Sq Li h +or +.Sq Li I +followed by a +.Sq Li / +and all +.Dq Li gopher:// +URI are printed using the corresponding entry type. +. +.It +All other URI are printed using the +.Sq Li h +entry type +. +.El +. +.\" .Sh CONTEXT +.\" For section 9 functions only. +.\" .Sh RETURN VALUES +.\" For sections 2, 3, and 9 function return values only. +.\" .Sh ENVIRONMENT +.\" For sections 1, 6, 7, and 8 only. +.\" .Sh FILES +.\" .Sh EXIT STATUS +.\" For sections 1, 6, and 8 only. +.\" .Sh EXAMPLES +.\" .Sh DIAGNOSTICS +.\" For sections 1, 4, 6, 7, 8, and 9 printf/stderr messages only. +.\" .Sh ERRORS +.\" For sections 2, 3, 4, and 9 errno settings only. +.\" .Sh SEE ALSO +.\" .Xr foobar 1 +.\" .Sh STANDARDS +.\" .Sh HISTORY +. +. +.Sh AUTHORS +. +.An Josuah Demangeon +.Aq Mt mail@josuah.net +. +. +.\" .Sh CAVEATS +.\" .Sh BUGS DIR diff --git a/markup-html b/tttml-html DIR diff --git a/markup.5 b/tttml.5