Index: openacs-4/packages/acs-tcl/tcl/text-html-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/text-html-procs.tcl,v diff -u -r1.21 -r1.22 --- openacs-4/packages/acs-tcl/tcl/text-html-procs.tcl 23 Sep 2003 08:24:50 -0000 1.21 +++ openacs-4/packages/acs-tcl/tcl/text-html-procs.tcl 23 Sep 2003 19:51:38 -0000 1.22 @@ -735,9 +735,16 @@ # append everything up to and not including the tag-opening < ad_html_to_text_put_text output [string range $html $last_tag_end [expr {$i - 1}]] - # Check that tag doesn't start with whitespace, in which case it's just a lone < that - # was errorneously left unquoted - if { $i >= [expr $length-1] || ![string is alpha [string index $html [expr $i + 1]]] } { + # Check that: + # - we're not past the end of the string + # - and that the tag starts with either + # - alpha or + # - a slash, and then alpha + # Otherwise, it's probably just a lone < character + if { $i >= [expr $length-1] || \ + (![string is alpha [string index $html [expr $i + 1]]] && \ + (![string equal "/" [string index $html [expr $i + 1]]] || \ + ![string is alpha [string index $html [expr $i + 2]]])) } { # Output the < and continue with next character ad_html_to_text_put_text output "<" set last_tag_end [incr i] @@ -840,29 +847,31 @@ ad_html_to_text_put_text output "_" } a { - if { [empty_string_p $slash] && !$no_format_p} { - if { [info exists attribute_array(href)] } { - if { [info exists attribute_array(title)] } { - set title ": '$attribute_array(title)'" - } else { - set title "" - } - set href_no [expr [llength $href_urls] + 1] - lappend href_urls "\[$href_no\] $attribute_array(href) " - lappend href_stack "\[$href_no$title\]" - } elseif { [info exists attribute_array(title)] } { - lappend href_stack "\[$attribute_array(title)\]" - } else { - lappend href_stack {} - } - } else { - if { [llength $href_stack] > 0 } { - if { ![empty_string_p [lindex $href_stack end]] } { - ad_html_to_text_put_text output [lindex $href_stack end] - } - set href_stack [lreplace $href_stack end end] - } - } + if { !$no_format_p } { + if { [empty_string_p $slash]} { + if { [info exists attribute_array(href)] } { + if { [info exists attribute_array(title)] } { + set title ": '$attribute_array(title)'" + } else { + set title "" + } + set href_no [expr [llength $href_urls] + 1] + lappend href_urls "\[$href_no\] $attribute_array(href) " + lappend href_stack "\[$href_no$title\]" + } elseif { [info exists attribute_array(title)] } { + lappend href_stack "\[$attribute_array(title)\]" + } else { + lappend href_stack {} + } + } else { + if { [llength $href_stack] > 0 } { + if { ![empty_string_p [lindex $href_stack end]] } { + ad_html_to_text_put_text output " [lindex $href_stack end]" + } + set href_stack [lreplace $href_stack end end] + } + } + } } pre { set output(p) 1 Index: openacs-4/packages/acs-tcl/tcl/test/acs-tcl-test-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/test/acs-tcl-test-procs.tcl,v diff -u -r1.9 -r1.10 --- openacs-4/packages/acs-tcl/tcl/test/acs-tcl-test-procs.tcl 23 Sep 2003 09:19:44 -0000 1.9 +++ openacs-4/packages/acs-tcl/tcl/test/acs-tcl-test-procs.tcl 23 Sep 2003 19:51:38 -0000 1.10 @@ -370,6 +370,13 @@ } else { aa_log "Text version: $text_version" } + + # Test placement of [1] reference + set html {Here is http://openacs.org my friend} + + set text_version [ad_html_to_text -- $html] + + aa_log "Text version: $text_version" } aa_register_case ad_page_contract_filters {