[Richard Suchenwirth] 2001-01-03 - One of the core Wiki functionalities is to translate its own simple markup "language" into HTML. In ten days Christmas vacations offline, I still wanted to prepare some Wiki pages. Being both impatient and blessed with more time than usual, I wrote me the following converter. It doesn't handle all "WikiML" features (in fact, the language seems to be called [STX]), but * preformatted vs. regular text, * links (with '.' content - this is a previewer only!), * rulers, bullets, bold and italic are all there and seem to work similar to the Real Wiki. Enjoy! ====== proc wiki2html fn { set fp [open $fn] set text [read $fp [file size $fn]] regsub {[\n\t ]+$} $text "" text set s [split $text \n] close $fp if [regexp {TITLE: (.+)} [lindex $s 0] -> title] { set s [lreplace $s 0 0] } else {set title $fn} set ofn [file rootname $fn].htm set fp [open $ofn w] set pre 0; set p 0 puts $fp "
}; set p 1; continue } elseif {$pre && [string trim $i]==""} { puts $fp ""; continue } elseif {!$pre && $i=="----"} { puts $fp
}; set p 0 } else { if $pre {set pre 0; puts $fp}; set p 0 } puts $fp $i } if $pre {puts $fp } set now [clock format [clock seconds]] puts $fp "