#!/usr/bin/tclsh # # Copyright (C) Jun-2002 Oliver Dippel # (oliver@multixmedia.de) # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2, or (at your option) any # later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. set FILE [open "/root/man.wiki" r] while {[gets $FILE LINE] >= 0} { if {[string match "= * =" "$LINE"]} { set TITLE "[string trim $LINE "= "]" puts ".TH $TITLE" } elseif {[string match "== * ==" "$LINE"]} { puts "[string trim $LINE "= "]" } elseif {[string match "=== * ===" "$LINE"]} { puts ".SH [string trim $LINE "= "]" } else { set HK "0" set HK_START "0" set DP "0" set OUTPUT "" foreach CHAR [split [string trim $LINE "= "] ""] { if {"$CHAR" == "-"} { set CHAR "\\$CHAR" set HK "0" set DP "0" } elseif {"$CHAR" == "\["} { set CHAR "$CHAR" set HK "0" set DP "0" } elseif {"$CHAR" == "\]"} { set CHAR "\\$CHAR" set HK "0" set DP "0" } elseif {"$CHAR" == "'"} { set CHAR "" incr HK set DP "0" if {$HK_START == "0" && $HK == "3"} { set HK_START "1" set CHAR "\\fB" } elseif {$HK_START == "1" && $HK == "3"} { set HK_START "0" set CHAR "\\fR" } } elseif {"$CHAR" == ":"} { set CHAR "" set HK "0" incr DP if {$DP == "2"} { set DP "0" set OUTPUT "\\fB$OUTPUT\\fR\n" } } else { set HK "0" set DP "0" } append OUTPUT "$CHAR" } puts "$OUTPUT" } } close $FILE