#l;
#-- replace all tabs with two spaces
s@ @ @g;
#-- html entities.
s@&@\&@g;
s@<@\<@g;
s@>@\>@g;
#-- stop formatting between '-->' and '--<'
/^ *-->/,/^ *--</ {
s/-->/
/;
s/--</<\/pre>/;
b;
}
#-- stop formatting on line that has ":>"
/^ *:>/ {
s@:>@
\ \ \ @;
s@$@
@;
b;
}
#-- mark up language generative grammar rules
/^ *rule: / {
s@rule:\(.*\)$@\1
@;
}
#-- if the file contains DOS newlines line below may be necessary
#-- in order to get rid of the "\r" characters.
#s@.$@@g
#
s@\([ ][ ]*\)@ @g
#--------------------------
#-- 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- \2
- @;
s@^\([ ]*\)D-\(.*\): @\1
- \2
- @;
s@^\([ ]*\)-\(.*\): @\1
- \2
- @;
s@^\([ ]*\)-\(.*\):$@\1
- \2
- @;
s@^\([ ]*\)$@\1
\
@;
}
#-- attempt to mark up sections of text which refer to the
#-- state of a virtual machine
/^[ ]*-machine-/,/^[ ]*$/ {
s@^\([ ]*\)-machine-$@\1@;
/^ *-/ {
s@-workbuffer:@-workspace:@;
s@^\([ ]*\)-workspace:\(.*\)$@\1| workspace | \2 |
@g;
s@,@@g;
s@^\([ ]*\)-\([^:]*\):\(.*\)$@\1 | | \2 | \3 |
@g;
}
s@^\([ ]*\)$@\1
\
@;
}
#-- title
s@^[ ]*==\(.*\)@
\1
@
#-- headings
#s@^[ ]*\*\*\(.*\)@
\1
@
s@^[ ]*\*\*\(.*\)@\♣\1
@
#-- files
s@ \(/[^ /][^ /]*/[^ ]*\)@ \1@g
#-- 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" (wikipedia)
s@"[ ]*(wikipedia)@" (wikisearch)@Ig;
s@"[ ]*(wpsearch)@" (wikisearch)@Ig;
s@"\([^"][^"]*\)"[ ]*(wikisearch)@\1\
\
\→W@g
#-- format: "term" (wikipedia:nn) where "nn" is any language code
s@"\([^"][^"]*\)"[ ]*(wikipedia:\([a-z][a-z]\))@\1@g
#-- format: "term" (google:nn)
s@"\([^"][^"]*\)"[ ]*(google:\([a-z][a-z]\))@\1@g
#-- links
#-- format: the "something" command
s@the *"\([^"][^"]*\)" command@the "\1" command@Ig
#-- format: file "filename"
s@file *"\([^"][^"]*\)"@file \1@Ig
#-- format: the "something" directory
s@the *"\([^"][^"]*\)" *directory@the \1 directory@g
s@"\([^"][^"]*\)" [ ]*link://\([^ ][^ ]*\)@\1@g
s@"\([^"][^"]*\)" [ ]*file://\([^ ][^ ]*\)@\1@g
s@"\([^"][^"]*\)" [ ]*vir://\([^ ][^ ]*\)@\1@g
s@"\([^"][^"]*\)" [ ]*\(http://[^ ][^ ]*\)@\1@g
s@"\([^"][^"]*\)" [ ]*\(ftp://[^ ][^ ]*\)@\1@g
s@"\([^"][^"]*\)" [ ]*\(www\.[^ ][^ ]*\)@\1@g
#-- "vir" works in conjunction with apache mod rewrite rules
#-- to display text files as html
s@ vir://\([^ ][^ ]*\)@ \1@g
s@^vir://\([^ ][^ ]*\)@ \1@g
s@ file://\([^ ][^ ]*\)@ \1@g
s@^file://\([^ ][^ ]*\)@ \1@g
s@ link://\([^ ][^ ]*\)@ \1@g
s@^link://\([^ ][^ ]*\)@ \1@g
s@ \(http://[^ ][^ ]*\)@ \1@g
s@^\(http://[^ ][^ ]*\)@\1@g
s@ \(ftp://[^ ][^ ]*\)@ \1@g
s@^\(ftp://[^ ][^ ]*\)@\1@g
s@ \(gopher://[^ ][^ ]*\)@ \1@g
s@^\(gopher://[^ ][^ ]*\)@\1@g
s@ \(www\.[^ ][^ ]*\)@ \1@g
s@^\(www\.[^ ][^ ]*\)@\1@g
s@-->@\→@g
s@<--@\←@g
#-- unordered lists
/^[ ]*u-/,/^[ ]*$/ {
s@^\([ ]*\)u-@\1- @;
s@^\([ ]*\)-@\1
- @;
s@^\([ ]*\)$@\1
\
@;
}
#-- ordered lists
/^[ ]*o-/,/^[ ]*$/ {
s@^\([ ]*\)o-@\1- @;
s@^\([ ]*\)-@\1
- @;
s@^\([ ]*\)$@\1
\
@;
}
#-- attempts to mark up "faq" (frequently asked questions) sections of documents
#-- example of format
#-- (-faq-)
#-- * what is an faq?
#-- an faq is a set of questions and answers
#-- (-/faq-)
/^[ ]*(-faq-)/,/^[ ]*(-\/faq-)/ {
s@^\([ ]*\)(-faq-)@\1@;
s@^\([ ]*\)\*@\1- @;
s@?@?
- @;
s@^\([ ]*\)(-/faq-)@\1
@;
}
#-- journal
/^[ ]*(-jour-)/,/^[ ]*(-\/jour-)/ {
s@^\([ ]*\)(-jour-)@\1@;
s@^\([ ]*\)\([0-9][0-9].*\)@\1- \2
- @;
s@^\([ ]*\)(-/jour-)@\1
@;
}
s@^\([ ]*\)$@@;
s@:$@:
@;