summaryrefslogtreecommitdiff
path: root/viewhtml
diff options
context:
space:
mode:
Diffstat (limited to 'viewhtml')
-rwxr-xr-xviewhtml19
1 files changed, 10 insertions, 9 deletions
diff --git a/viewhtml b/viewhtml
index f853dc3..f7eedaa 100755
--- a/viewhtml
+++ b/viewhtml
@@ -2,6 +2,7 @@
package require tclgumbo
package require Tk
+# TODO: General notes enclose the script into functions, this is ugly right now.
text .t -yscrollcommand {.s set} -relief flat -font {Times 12} -wrap word -border 4
scrollbar .s -command {.t yview}
@@ -28,7 +29,7 @@ $w tag bind a <Enter> "$w config -cursor hand2"
$w tag bind a <Leave> "$w config -cursor {}"
$w tag bind a <ButtonRelease-1> "click $w %x %y"
-# TODO:
+# TODO: Extend argument parsing and handling
set baseAddress [lindex $argv 1]
set file [open [lindex $argv 0]]
set html [read $file]
@@ -40,13 +41,13 @@ proc click {w x y} {
set range [$w tag prevrange href [$w index @$x,$y]]
set address [eval $w get $range]
- # TODO:
+ # TODO: Handle external base address nicely
+ # TODO: Handle /-prefixed addresses
+ # TODO: Use browse script instead of viewhtml directly
if {0 == [regexp {^https?.*} $address]} {
- exec "./html.tcl" "$baseAddress/$address" $baseAddress
- exit
+ exec "./viewhtml" "$baseAddress/$address" $baseAddress
} else {
- exec "./html.tcl" $address $address
- exit
+ exec "./viewhtml" $address $address
}
}
@@ -60,7 +61,7 @@ proc displayNode {node tagList} {
set tag [gumbo::element_get_tag_name $node]
set attributes [gumbo::element_get_attributes $node]
- # TODO:
+ # TODO: This could be simplified in a way that allows for easy extension and won't end up in a long if-elseif-chain
if {$tag == "a"} {
$w insert end [lindex [array get $attributes] 1] [concat $tagList href]
} elseif {$tag == "img"} {
@@ -76,14 +77,14 @@ proc displayNode {node tagList} {
displayNode $child_node [concat $tag $tagList]
}
- # TODO:
+ # TODO: Handle margins and blocks better than this.
if {$tag == "h1" || $tag == "h2" || $tag == "p"} {
$w insert end "\n\n" {}
} elseif {$tag == "pre" || $tag == "li" || $tag == "dt" || $tag == "ul" || $tag == "dd" || $tag == "dl"} {
$w insert end "\n" {}
}
} elseif {$type == $gumbo::GUMBO_NODE_TEXT} {
- # TODO:
+ # TODO: This could be simplified.
if {0 <= [lsearch $tagList pre]} {
$w insert end [gumbo::text_get_text $node] $tagList
} else {