#!/bin/sed -f #l; #-- replace all tabs with two spaces s@ @ @g; #-- html entities. #-- allow literal html between /^ */,/^ *<\/html>/ { s///g; s/<\/html>//g; b; } s@&@\&@g; s@<@\<@g; s@>@\>@g; /^ *-\+ *$/d #-- stop formatting between '-->' and '--<' /^ *-->/,/^ *-- { s/-->/
/; s/--<\/pre>/; b; } #-- stop formatting on line that starts with ":>" /^ *:>/ { s@:>@@; s@$@@; b; } #-- stop formatting on line that starts with ">>" /^ *>>/ { s@>>@@; s@$@@; b; } #-- if the file contains DOS newlines line below may be necessary #-- in order to get rid of the "\r" characters. #s@.$@@g # s/[ ][ ]*/ /g #-- get rid of leading spaces to simplify matches s/^[[:blank:]]\+//; #-- use the gnu 'e' command to execute shell commands embedded #-- in pages format: [** shell-command ] /^\[\*\*/ { s/\[\*\*//; s/\]//; e } #-------------------------- # widgets #-- use the gnu 'e' command to "widgets" in the format [@@name] # # eg: [@@filelist /img/*.txt] /^\[@@filelist/ { s|\[@@filelist *|../htdocs/webscript/file-list.sh '|; s/\]/'/; e } #-------------------------- #-- lists #-- definition lists, the term begins with a "-" and #-- ends which a ":" at the end of a line or followed by a #-- space. The list end with a blank line eg; #-- D- sea: a lot of water #-- - see: look with the eyes #-- /^[ ]*D-/,/^[ ]*$/ { s@^\([ ]*\)D-\(.*\):$@\1
workspace | \2 | ||||
peep | \2 | @g; s@^\([ ]*\)-\([^:]*\):\(.*\)$@\1 | |||
\2 | \3 |
\ @; } #---------------------------- #-- the page title #-- formats: && title #-- = title = s@^[ ]*=\(.*\)=@
\1
@
#----------------------------
#-- make file names fixed pitch, links
s@ \([-a-zA-Z/]\+\.[^ ]\+\) file@\1
@
#----------------------------
#-- make file names fixed pitch, links
s@file \([-a-zA-Z/]\+\.[^ ]\+\)@\1
@
#----------------------------
#-- make folder names fixed pitch, links
s@\([-a-zA-Z]\+/\) folder@\1
@
#----------------------------
#-- make folder names fixed pitch, links
s@\([-a-zA-Z]\+/ \)dir@\1
@
#----------------------------
#-- make function names fixed pitch italic
s@\([a-zA-Z]\+() \)@\1
@
#----------------------------
#-- special links
#-- format: "location" (googlemap)
s@"[ ]*(maplink)@" (googlemap)@Ig;
s@"[ ]*(map)@" (googlemap)@Ig;
s@"\([^"][^"]*\)"[ ]*(googlemap)@\1@g
#-- format: "term" (google)
s@"\([^"][^"]*\)"[ ]*(google)@\1@g
#----------------------------
#-- format: "term" (google:nn)
s@"\([^"][^"]*\)"[ ]*(google:\([a-z][a-z]\))@\1@g
#s@"\([^"]\+\)" \+\(/[^ ]\+\)@\1@g
s@"\([^"]\+\)" \+file://\([^ ]\+\)@\1@g
s@"\([^"]\+\)" \+doc:\([^ ]\+\)@\1@g
s@"\([^"]\+\)" \+\(http://[^ ]\+\)@\1@g
s@"\([^"]\+\)" \+\(ftp://[^ ]\+\)@\1@g
s@"\([^"]\+\)" \+\(www\.[^ ]\+\)@\1@g
#----------------------------
#-- format: file:
s@\bdoc:\([^ ]\+\)@ \1@g
s@\bfile://\([^ ]\+\)@ \1@g
s@[^"]\(http://[^ ]\+\)@ \1@g
s@[^"]\(https://[^ ]\+\)@ \1@g
s@\(https://[^ ]\+\)@ \1@g
s@[^"]\(https\?://[^ ]\+\)@ \1@g
s@[^"]\(ftps\?://[^ ]\+\)@ \1@g
s@ \(www\.[^ ][^ ]*\)@ \1@g
s@^\(www\.[^ ][^ ]*\)@ \1@g
s@-->@\→@g
s@<--@\←@g
#----------------------------
#-- unordered lists
/^[ ]*u-/,/^[ ]*$/ {
s@^\([ ]*\)u-@\1@;
s@:$@:
@;
#----------------------------
#-- make -text- bold
s@-\([a-z][a-z]*\)- @\1 @Ig;