#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;
}
#-- script blocks
/script-$/,/^ *-- *$/ {
s@script-@script:@;
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
\
@;
}
#----------------------------
#-- The virtual machine state
/^[ ]*-machine-/,/^[ ]*$/ {
s@^\([ ]*\)-machine-$@\1@;
/^ *-/ {
s@-workbuffer:@-workspace:@;
s@^\([ ]*\)-workspace:\(.*\)$@\1workspace | \2 |
@g;
s@^\([ ]*\)-peep:\(.*\)$@\1peep | \2 |
@g;
s@,@@g;
s@^\([ ]*\)-\([^:]*\):\(.*\)$@\1 | \2 | \3 |
@g;
}
s@^\([ ]*\)$@\1
\
@;
}
#----------------------------
#-- the page 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@"[ ]*(wikip)@" (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
#----------------------------
#-- format: the @workspace
s@\@\([^ ,.:][^ ,.:]*\)\([ ,.:]\)@ \δ \1\2@Ig
s@\@\([^ ,.:][^ ,.:]*\)$@ \δ \1 @Ig
#----------------------------
#-- this format provide a link to documents for the virtual machine language.
s@":\([^"][^"]*\)"@ \δ \1 @Ig
#----------------------------
#-- 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@"\([^"][^"]*\)" [ ]*file:\([^ ][^ ]*\)@\1@g
s@"\([^"][^"]*\)" [ ]*doc:\([^ ][^ ]*\)@\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@ dir:\([^ ][^ ]*\)@ \1@g
s@^dir:\([^ ][^ ]*\)@ \1@g
#----------------------------
#-- format: doc:some.file
s@ doc:\([^ ][^ ]*\)@ \1@g
s@^doc:\([^ ][^ ]*\)@ \1@g
#----------------------------
#-- format: file:
s@ file://\([^ ][^ ]*\)\.txt\.html@ \1@g
s@^file://\([^ ][^ ]*\)\.txt\.html@ \1@g
s@ file://\([^ ][^ ]*\)@ \1@g
s@^file://\([^ ][^ ]*\)\.txt\.html@ \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
\
@;
}
#----------------------------
#-- ordered lists, alphabetic style
/^[ ]*a-/,/^[ ]*$/ {
s@^\([ ]*\)a-@\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@^\([ ]*\)\*\(.*\)@\1- \2
- @;
s@^\([ ]*\)(-/jour-)@\1
@;
}
#----------------------------
s@^\([ ]*\)$@@;
s@:$@:
@;
#----------------------------
#-- make -text- bold
s@-\([a-z][a-z]*\)- @\1 @Ig;