diff options
author | Nick White <git@njw.name> | 2014-03-16 14:08:25 -0400 |
---|---|---|
committer | Nick White <git@njw.name> | 2014-03-16 14:08:25 -0400 |
commit | 3d4c629ac293711074ac5a692b58db32f9c8bbc9 (patch) | |
tree | 29a00872e22a2201d576b50c5ad5bafc3ad32fd7 | |
parent | 2a2919d9d26756e898a6fec0572ca01acbaff24b (diff) | |
download | tkread-3d4c629ac293711074ac5a692b58db32f9c8bbc9.tar.bz2 tkread-3d4c629ac293711074ac5a692b58db32f9c8bbc9.zip |
Improve image link parsing, and remove links completely for now
-rwxr-xr-x | tkread | 29 |
1 files changed, 28 insertions, 1 deletions
@@ -123,13 +123,40 @@ proc markup {widget} { if [file exists $localfile] { set curimg [image create photo -file $localfile] $widget image create $insertion -image $curimg + set cur $insertion } else { - $widget insert [indexmovechar $insertion "- 2"] $alt + $widget insert $insertion $alt + set cur [indexmovechar $insertion "+ [string length $alt]"] } set cur [$widget search {![} $cur end] } + # remove links + # TODO: save the link contents and allow the links to be shown / hidden with a keystroke + set cur [$widget search {[} 0.0 end] + while {$cur != ""} { + set altstart [indexmovechar $cur "+ 1"] + set cur [$widget search "](" $cur end] + if {$cur == ""} { break } + set altend $cur + set srcstart [indexmovechar $cur "+ 1"] + set cur [$widget search ")" $cur end] + if {$cur == ""} { break } + set srcend $cur + + set alt [$widget get $altstart $altend] + set src [$widget get $srcstart $srcend] + + $widget delete [indexmovechar $altstart "- 1"] [indexmovechar $srcend "+ 1"] + set insertion [indexmovechar $altstart "- 1"] + $widget insert $insertion $alt + + set cur [indexmovechar $insertion "+ [string length $alt]"] + set cur [$widget search {[} $cur end] + } + + # process underlined headings foreach fmt $underlinefmt { set searchchar [lindex $fmt 0] |