improve tttml-html qualityness and replace markup->tttml again - 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 83b0368ca37208587a5abadefd12628d80374ab4 DIR parent fd08ceaed88288f846c89bbb7b191379064625ee HTML Author: Josuah Demangeon <mail@josuah.net> Date: Fri, 11 May 2018 19:57:26 +0200 improve tttml-html qualityness and replace markup->tttml again In awk, even if a match() happen in an external funciton, it sets RLENGTH an friends, so these variables needs to be saved before calling other functions. match(string, /patttttern/); match_inside™(); substr(string, 1, RLENGTH); becomes: match(string, /patttttern/); len = RLENGTH; match_inside™(); substr(string, 1, len); Diffstat: M Makefile | 2 +- M README | 56 ++++++++++++++++---------------- M tttml-gopher | 2 +- M tttml-html | 24 +++++++++++++++++++----- M tttml.5 | 10 +++++----- 5 files changed, 54 insertions(+), 40 deletions(-) --- DIR diff --git a/Makefile b/Makefile @@ -5,7 +5,7 @@ MAN5 = tttml.5 all: README: Makefile $(MAN1) $(MAN5) - mandoc -T utf8 $(MAN5) $(MAN1) | col -bx >$@ + mandoc -T ascii $(MAN5) $(MAN1) | col -bx >$@ install: mkdir -p $(PREFIX)/bin DIR diff --git a/README b/README @@ -1,14 +1,14 @@ -MARKUP(5) File Formats Manual MARKUP(5) +TTTML(5) File Formats Manual TTTML(5) NAME - markup simpler markup syntax than markdown + tttml - simpler markup syntax than markdown SYNOPSIS - markup.md + file.md DESCRIPTION - The markup format is a very simple format for writiing text that look - good enough to be published without conversion. It lacks the markdown + The tttml format is a very simple format for writiing text that look good + enough to be published without conversion. It lacks the markdown recursive syntax (such as recursive lists anb quotes) which also remove markdown ambiguities. Each block of text is separated from anotherone by an empty line. @@ -20,22 +20,22 @@ DESCRIPTION Second paragraph of text. - title Block that ends by a line with only =: + title Block that ends by a line with only `=': Title can therefore have multiple lines if required although it is not advised. ====================================================== heading - Block that ends with a line with only -: + Block that ends with a line with only `-': Heading can also have multiple lines ------------------------------------------------------ subheading - Block with a single line with at least 3 leading # characters + Block with a single line with at least 3 leading `#' characters starting at subheading and going down the outline (subheading, - subsubheading ...) every time an additionnal # is added: + subsubheading ...) every time an additionnal `#' is added: ### Subheading @@ -56,7 +56,7 @@ DESCRIPTION - Note that multi-paragraph lists are not handled - quote Block that has a leading > on every line: + quote Block that has a leading `>' on every line: > Mail-style quoting. Note that nested quotes > are not handled. @@ -71,14 +71,14 @@ DESCRIPTION link Block that start with a label line and eventual subsequent description lines: - [label]: git://josuah.net/git/markup.git - git repository for the markup set of tools + [label]: git://josuah.net/git/tttml + git repository for the tttml set of tools [label2]: /url/without/description.txt 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> @@ -90,7 +90,7 @@ OpenBSD 6.3 April 19, 2018 OpenBSD 6.3 TTTML-FMT(1) General Commands Manual TTTML-FMT(1) NAME - tttml-fmt format/pretty-print a tttml file + tttml-fmt - format/pretty-print a tttml file SYNOPSIS tttml-fmt [file...] @@ -102,22 +102,22 @@ DESCRIPTION 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, + o The paragraphs are being filled to 80 columns, - The empty lines are set as apropriate + o The empty lines are set as apropriate - The blocks merged together are separated, such as lists without + o The blocks merged together are separated, such as lists without separating blank spaces. - The title and heading horizontal lines are expanded to 80 + o The title and heading horizontal lines are expanded to 80 columns. - The tags with the tagline merged with the paragraph are separated + o The tags with the tagline merged with the paragraph are separated on their own line. SEE ALSO tttml-gopher(1), smu(1), tttml(5), simple tttml - markdown like syntax: - https://github.com/Gottox/smu + https://github.com/Gottox/smu AUTHORS Josuah Demangeon <mail@josuah.net> @@ -129,7 +129,7 @@ OpenBSD 6.3 April 19, 2018 OpenBSD 6.3 TTTML-GOPHER(1) General Commands Manual TTTML-GOPHER(1) NAME - tttml-gopher generate a gophermap from a tttml file + tttml-gopher - generate a gophermap from a tttml file SYNOPSIS tttml-gopher host port [file...] @@ -140,17 +140,17 @@ DESCRIPTION rest. host and port is used to set the host in links that do not have a host, such as /path/to/file.txt - All URI starting with a / and ending with a / are printed - using the 1 entry type + o All URI starting with a `/' and ending with a `/' are printed + using the `1' entry type - All URI starting with a / and not ending with a / are printed - using the 0 + o All URI starting with a `/' and not ending with a `/' are printed + using the `0' - All URI starting with 0, 1, 7, 8, 9, a, g, h or - I followed by a / and all gopher:// URI are printed using + o All URI starting with `0', `1', `7', `8', `9', `a', `g', `h' or + `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 + o All other URI are printed using the `h' entry type AUTHORS Josuah Demangeon <mail@josuah.net> DIR diff --git a/tttml-gopher b/tttml-gopher @@ -13,7 +13,7 @@ BEGIN { if (ARGC < 3 || 4 < ARGC) { - print("usage: markup-gph <host> <port> [<file>]"); + print("usage: tttml-gph <host> <port> [<file>]"); exit(1); } HOST = ARGV[1]; DIR diff --git a/tttml-html b/tttml-html @@ -6,12 +6,13 @@ function esc(str) gsub("<", "\\<", str); gsub(">", "\\>", str); gsub("\"", "\\"", str); + gsub("'", "\\'", str); return str; } function format(blk) { - gsub("[*_]", "", blk); + gsub("[*_/]", "", blk); for (out = ""; match(blk, /\[[^]]+\]/);) { out = out substr(blk, 1, RSTART - 1); @@ -29,6 +30,18 @@ function paragraph(blk) print("<p>" format(esc(blk)) "</p>"); } +function blockquote(blk) +{ + if (blk) + print("<blockquote>" format(esc(blk)) "</blockquote>"); +} + +function list(blk) +{ + if (blk) + print("<ul><li>" format(esc(blk)) "</li></ul>"); +} + function title(blk) { print("\n<h1>" esc(blk) "</h1>\n"); @@ -48,8 +61,9 @@ function tag(blk) { print(""); match(blk, /^\*[^*]*\*:/); - print("<dt>" esc(substr(blk, 1, RLENGTH)) "</dt>"); - print("<dd>" esc(substr(blk, RLENGTH + 1)) "</dd>"); + len = RLENGTH; + print("<dt>" format(esc(substr(blk, 1, len - 2))) "</dt>"); + print("<dd>" format(esc(substr(blk, len + 2))) "</dd>"); } function link(blk) @@ -78,8 +92,8 @@ function literal() function printblk(blk) { if (type == PARAGRAPH) paragraph(blk); - else if (type == QUOTE) quote(blk, "> ", "> "); - else if (type == LIST) list(blk, "- ", " "); + else if (type == QUOTE) blockquote(blk); + else if (type == LIST) list(blk); else if (type == TAG) tag(blk); else if (type == LINK) link(blk); } DIR diff --git a/tttml.5 b/tttml.5 @@ -1,17 +1,17 @@ .Dd $Mdocdate: April 19 2018$ -.Dt MARKUP 5 +.Dt TTTML 5 .Os . . .Sh NAME . -.Nm markup +.Nm tttml .Nd simpler markup syntax than markdown . . .Sh SYNOPSIS . -.Pa markup.md +.Pa file.md . . .Sh DESCRIPTION @@ -115,8 +115,8 @@ Block that start with a label line and eventual subsequent description lines: . .Bd -literal -offset 3n -[label]: git://josuah.net/git/markup.git -git repository for the markup set of tools +[label]: git://josuah.net/git/tttml +git repository for the tttml set of tools [label2]: /url/without/description.txt .Ed