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
|
# -*- tcl -*-
##
## (C) 2022 Dr. Detlef Groth, Germany, Andreas Kupries
##
## shtmlview extension adding support for mkdoc markup
# #############################################################
## Requirements - Viewer widget, and easy mkdoc conversion
package require shtmlview::shtmlview
package require mkdoc::mkdoc
# #############################################################
## Register the new converter
::shtmlview::converter .tcl {Tcl+mkdoc files} ::shtmlview::mkdoc
::shtmlview::converter .tm {Tcl+mkdoc modules} ::shtmlview::mkdoc
# #############################################################
## Exported API
proc ::shtmlview::mkdoc {url} {
close [file tempfile htmltemp .html]
mkdoc::mkdoc $url $htmltemp -html
if {[catch {
open $htmltemp r
} result]} {
# result :: string, error message
return -code error "Cannot open $url: $result"
}
# result :: channel handle
set html [read $result]
close $result
file delete $htmltemp
return $html
}
# #############################################################
## Publish package to Tcl
package provide shtmlview::mkdoc 0.1
return
|