Index: openacs.org-dev/packages/acs-tcl/tcl/text-html-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-tcl/tcl/text-html-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs.org-dev/packages/acs-tcl/tcl/text-html-procs.tcl 9 Jul 2002 17:34:59 -0000 1.1 +++ openacs.org-dev/packages/acs-tcl/tcl/text-html-procs.tcl 17 Sep 2002 18:25:51 -0000 1.2 @@ -55,6 +55,12 @@ # we quote the ones entered by the user: set text [ad_quotehtml $text] + # Convert _single_ CRLF's to
's to preserve line breaks + regsub -all {\r*\n} $text "
" text + + # Convert every two spaces to an nbsp + regsub -all { } $text "\\\  " text + # turn CRLFCRLF into

if { [regsub -all {\r\n\s*\r\n} $text "

" text] == 0 } { # try LFLF @@ -66,13 +72,16 @@ if { !$no_links_p } { # Dress the links and emails with A HREF - regsub -all {([]!?.:;,<>\(\)\}-]+)(eNdUrL\t)} $text {\2\1} text - regsub -all {([]!?.:;,<>\(\)\}-]+)(eNdEmAiL\t)} $text {\2\1} text + regsub -all {([]!?.:;,<>\(\)\}"'-]+)(eNdUrL\t)} $text {\2\1} text + regsub -all {([]!?.:;,<>\(\)\}"'-]+)(eNdEmAiL\t)} $text {\2\1} text regsub -all {\tsTaRtUrL([^\t]*)eNdUrL\t} $text {\1} text regsub -all {\tsTaRtEmAiL([^\t]*)eNdEmAiL\t} $text {\1} text set text [string trimleft $text] } + # Convert every tab to 4 nbsp's + regsub -all {\t} $text {\ \ \ \ } text + return $text } @@ -133,7 +142,7 @@ @param break_hard the number of characters you want the html fragment truncated to. Will truncate, regardless of what tag is currently in action. - @author Jeff Davis (davis@arsdigita.com) + @author Jeff Davis (davis@xarg.net) } { set frag $html_fragment @@ -1260,9 +1269,46 @@ } +##### +# +# Truncate +# +##### +ad_proc string_truncate { + {-len 200} + {-format html} + string +} { + Truncates a string to len characters (defaults to the + parameter TruncateDescriptionLength), adding an ellipsis (...) if the + string was truncated. If format is html (default), any open + HTML tags are closed. Otherwise, it's converted to text using + ad_html_to_text. + @param len The lenght to truncate to. Defaults to parameter TruncateDescriptionLength. + @param format html or text. + @param string The string to truncate. + @return The truncated string, with HTML tags cloosed or + converted to text, depending on format. + @author Lars Pind (lars@pinds.com) + @creation-date September 8, 2002 +} { + if { [string length $string] > $len } { + set string "[string range $string 0 $len]..." + } + + if { [string equal $format "html"] } { + set string [util_close_html_tags $string] + } else { + set string [ad_html_to_text -- $string] + } + return $string +} + + + #################### # # Legacy stuff