1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
# -*- tcl -*-
#
# $Id: idx.wiki,v 1.2 2004/01/15 06:36:12 andreas_kupries Exp $
#
# Engine to convert a docidx document into Wiki markup.
#
# Copyright (c) 2003 Andreas Kupries <andreas_kupries@sourceforge.net>
# Freely redistributable.
#
######################################################################
dt_source _idx_common.tcl ; # Shared code
######################################################################
proc idx_postprocess {wiki} {
# Strip empty lines out of the generated wiki source
# and trim leading blanks, except in code samples.
#
set lines [list]
foreach line [split $wiki \n] {
if {[string match " |*" $line]} {
# Verbatim / example
lappend lines [string trimright $line]
} elseif {[string match ". *" $line]} {
# Verbatim / regular
lappend lines [string range [string trimright $line] 1 end]
} elseif {[string match " \* *" $line]} {
# Itemized lists.
lappend lines [string map {[ [[ ] ]]} [string trimright $line]]
} elseif {[string match " 1. *" $line]} {
# Enumerated lists
lappend lines [string map {[ [[ ] ]]} [string trimright $line]]
} elseif {[regexp "^ (\[^:\]): " $line]} {
# Definition list
lappend lines [string map {[ [[ ] ]]} [string trimright $line]]
} elseif {[string match " *" $line]} {
# Unwanted indentation
lappend lines [string map {[ [[ ] ]]} [string trim $line]]
} else {
# Everything else
lappend lines [string map {[ [[ ] ]]} [string trimright $line]]
}
}
set wiki [join $lines \n]\n
regsub {^[ ]+} $wiki {} wiki
return $wiki
}
proc fmt_plain_text {text} {return {}}
################################################################
## Backend for wiki markup
proc fmt_index_begin {label title} {return "Index '''$label'''\n'''[string trim $title]'''\n"}
proc fmt_index_end {} {return {}}
proc fmt_key {text} {return "\n '''[string trim $text]''': "}
proc fmt_manpage {file label} {return "$file "}
proc fmt_url {url label} {return "$url "}
proc fmt_comment {text} {return {}}
################################################################
|