dot

packages and services management
Log | Files | Refs | README

commit bb69408539f8056dd50d3b7122be803d291a890b
parent 825a42cb27116e73e6ba4acf754aafd4978fc9f5
Author: Josuah Demangeon <josuah.demangeon@gandi.net>
Date:   Tue, 18 Jul 2017 01:02:25 +0200

txt is working great !

Diffstat:
Mbin/txt | 33+++++++++++++++++++++------------
Mbin/www | 6+++---
2 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/bin/txt b/bin/txt @@ -1,33 +1,40 @@ awk ' +!ELEMENT && /^$/ { next } + +ELEMENT && /^$/ { + print "</" ELEMENT ">\n" + ELEMENT = "" + next +} + !ELEMENT && /^\t/ { print "<pre>" do { sub("^\t", "", $0) - print + print $0 } while (getline && $0 !~ /^[^\t]/) print "</pre>" ELEMENT = "" } -!ELEMENT && /^$/ { next } - -ELEMENT && /^$/ { - print "</" ELEMENT ">" - ELEMENT = "" - next -} - -match($0, /^=+ /) { +!ELEMENT && match($0, /^=+ /) { sub(/^=* */, "", $0) sub(/ *=*$/, "", $0) lv = RLENGTH - 1 id = match($0, /^[0-9.]*/) ? substr($0, 1, RLENGTH) : "" - print "<h" lv " id=\"" id "\">" $0 "</h" lv ">" + print "\n<h" lv " id=\"" id "\">" $0 "</h" lv ">\n" ELEMENT = "" next } +!ELEMENT && /^- / { + sub(/^- /, "", $0) + print "<li>\n" $0 + ELEMENT = "li" + next +} + # other rules go here !ELEMENT { @@ -37,4 +44,6 @@ match($0, /^=+ /) { } { print } -' + +END { if (ELEMENT) print "</" ELEMENT ">" } +' "$@" diff --git a/bin/www b/bin/www @@ -35,8 +35,8 @@ root() nav() { - find -L . -mindepth 1 -maxdepth 1 -type d ! -name '.*' | sed 's|..||' | - while IFS='' read -r path + find -L . -mindepth 1 -maxdepth 1 -type d ! -name '.*' | sort | + sed 's|..||' | while IFS='' read -r path do printf ' <a href="%s">%s</a>' "$(root "$1")/$path" "$path" done } @@ -47,7 +47,7 @@ list() [ "$1" != . ] && find -L "$1" -mindepth 1 -maxdepth 1 ! -name 'index*' | sort | sed 's|.*/||' | while IFS='' read -r path do - printf -- '- <a href="%s">%s%s</a>\n' "$path" "$path" "$( + printf -- '<li><a href="%s">%s%s</a></li>\n' "$path" "$path" "$( [ -f "$path/index" ] && sed 's|^| - | q' "$path/index" )" done