The functionality below is present in Tkoutline 0.93 and later. By default export to html gives list items. With the
tree set root maxHeader 4
trick, the first 4 levels are output as html headers and any deeper levels are output as list items.
20-Aug-03 Laurent Duperval - Here is a quick hack for [mapping levels to headings]. It shows one way of doing it. The maxHeader is hard-coded here, but it could conceivable be an option for the document, that is carried along with the outline. I haven't looked at how this could be done elegantly.
Same day Brian Theado - I changed your
set maxHeader 4
to
set maxHeader -1
if {[$tree keyexists root -key maxHeader]} {
set maxHeader [$tree set root -key maxHeader]
}Now it isn't hard coded and the value will be carried along with the outline. If you want a value of 4 for a particular outline then execute the following in the console (<F2>) while your outline is active:
tree set root -key maxHeader 4
Thanks for the modified code, Laurent. I will include this in the next release of tkoutline.
proc treeToHtml {tree} {
set html {}
append html "<html><head></head><body>"
set bulletType bullet
if {[$tree keyexists root -key bulletType]} {
set bulletType [$tree set root -key bulletType]
}
set maxHeader -1
if {[$tree keyexists root -key maxHeader]} {
set maxHeader [$tree set root -key maxHeader]
}
if {$bulletType == "bullet"} {
set listTag "ul"
} else {
set listTag "ol"
}
$tree walk root -order both -command {
switch %a {
enter {
if {[%t depth %n] <= $maxHeader} {
append html "<h[%t depth %n]>[%t set %n]</h[%t depth %n]>"
} else {
if {[%t depth %n] != 0} {
append html "<li>[%t set %n]\n"
}
if {![%t isleaf %n]} {
append html "<$listTag>\n"
}
}
}
leave {
if {![%t isleaf %n]} {
append html "</$listTag>\n"
}
}
}
}
append html "</body></html>"
return $html
}| Updated 17 Jan 2007, 14:06 GMT Search - Recent Changes - 2 References - About WiKit - Go to Tkoutline - Help |