File: shtmlview-mkdoc.tcl

package info (click to toggle)
tklib 0.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 23,156 kB
  • sloc: tcl: 105,088; sh: 2,573; ansic: 792; pascal: 359; makefile: 69; sed: 53; exp: 21
file content (47 lines) | stat: -rw-r--r-- 1,155 bytes parent folder | download | duplicates (2)
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