dot

packages and services management
Log | Files | Refs | README

commit 251e5db7c2738a17acf45e6a6aeb89c3ccc170e1
parent ac3117f4f15cd314135848afb4c14afef216371f
Author: Josuah Demangeon <josuah.demangeon@gandi.net>
Date:   Sat, 19 Aug 2017 19:56:23 +0200

shell/bin/txt-html: text to html conversion tool

Diffstat:
Mshell/bin/txt | 1-
Ashell/bin/txt-html | 69+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aunbound/tar | 1+
3 files changed, 70 insertions(+), 1 deletion(-)

diff --git a/shell/bin/txt b/shell/bin/txt @@ -2,7 +2,6 @@ awk ' BEGIN { RS="\n\n+" - margin["li"] = 2 } diff --git a/shell/bin/txt-html b/shell/bin/txt-html @@ -0,0 +1,69 @@ +awk ' + +BEGIN { + RS="\n\n+" +} + +{ + gsub("&", "\\&amp;") + gsub("<", "\\&lt;") + gsub(">", "\\&gt;") +} + + +# litterals + +/^---\n.*\n---$/ { + sub("^---\n", "\n<pre>\n") + sub("\n---$", "\n</pre>") + print + next +} + +/^---\n/ { + block = "pre" + sub("^---\n", "\n<pre>\n") + print + next +} + +/\n---$/ { + block = "" + sub("\n---$", "\n</pre>") + print + next +} + +block == "pre" { + print "\n" $0 + next +} + + +# title + +NR == 1 { + sub("\n-+", "") + print "\n<h1>" $0 "</h1>" + next +} + + +# heading + +sub("^--- +", "") { + level = 1 + + while (sub("[0-9#]+\\.", "")) level++ + if (sub("[0-9#]+ ", "")) level++ + + sub("^[-. ]*", "") + sub(" *-* *$", "") + + print "\n<h" level ">" $0 "</h" level ">" + next +} + +{ + print "\n<p>" $0 "</p>" +}' "$@" diff --git a/unbound/tar b/unbound/tar @@ -0,0 +1 @@ +http://unbound.net/downloads/unbound-latest.tar.gz