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.9.2.5 -r1.9.2.6 --- openacs-4/packages/acs-tcl/tcl/text-html-procs.tcl 5 Mar 2003 14:40:42 -0000 1.9.2.5 +++ openacs-4/packages/acs-tcl/tcl/text-html-procs.tcl 26 Mar 2003 15:58:57 -0000 1.9.2.6 @@ -18,6 +18,7 @@ -no_links:boolean -no_lines:boolean -no_quote:boolean + -includes_html:boolean text } { Converts plaintext to html. Also translates any recognized @@ -71,7 +72,7 @@ # Convert line breaks if { !$no_lines_p } { - set text [util_convert_line_breaks_to_html $text] + set text [util_convert_line_breaks_to_html -includes_html=$includes_html_p -- $text] } if { !$no_quote_p } { @@ -103,6 +104,7 @@ } ad_proc -public util_convert_line_breaks_to_html { + {-includes_html:boolean} text } { Convert line breaks to

and
tags, respectively. @@ -115,8 +117,10 @@ regsub -all {\r\n} $text "\n" text regsub -all {\r} $text "\n" text - # Remove whitespace around \n's - regsub -all {\s+\n\s+} $text "\n" text + # Remove whitespace before \n's + regsub -all {[ \t]*\n} $text "\n" text + + # Wrap P's around paragraphs set text "

$text

" @@ -125,6 +129,14 @@ # Convert _single_ CRLF's to
's to preserve line breaks # Lars: This must be done after we've made P tags, because otherwise the line # breaks will already have been converted into BR's. + + # remove line breaks right before HTML tags that will insert a paragraph break themselves + if { $includes_html_p } { + foreach tag { ul ol li blockquote p div table tr td th } { + regsub -all -nocase "\\n\\s*(<${tag}\\s*\[^>\]*>)" $text {\1} text + } + } + regsub -all {\n} $text "
\n" text # Add line breaks to P tags @@ -1282,7 +1294,7 @@ @author Lars Pind (lars@pinds.com) @creation-date 2003-01-27 } { - return [ad_text_to_html -no_quote -- [util_close_html_tags $text]] + return [ad_text_to_html -no_quote -includes_html -- [util_close_html_tags $text]] } ad_proc -public ad_enhanced_text_to_plain_text {