From 2e07183d8b710b91dd2876fc7c0ae8c8b11a9a61 Mon Sep 17 00:00:00 2001 From: Aki Date: Wed, 5 Aug 2020 23:24:57 +0200 Subject: Cleaned up and inserted missing comments --- viewhtml | 19 ++++++++++--------- 1 file 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 "$w config -cursor hand2" $w tag bind a "$w config -cursor {}" $w tag bind a "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 { -- cgit v1.1