Index: openacs-4/packages/acs-tcl/tcl/00-icanuse-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/00-icanuse-procs.tcl,v diff -u -r1.1.2.36 -r1.1.2.37 --- openacs-4/packages/acs-tcl/tcl/00-icanuse-procs.tcl 22 Jan 2022 12:09:30 -0000 1.1.2.36 +++ openacs-4/packages/acs-tcl/tcl/00-icanuse-procs.tcl 25 Jan 2022 23:12:04 -0000 1.1.2.37 @@ -115,6 +115,7 @@ ::acs::register_icanuse "ns_pg pid" [acs::cmd_has_subcommand ns_pg pid] ::acs::register_icanuse "nsf::parseargs -asdict" [acs::cmd_error_contains {nsf::parseargs} -asdict] ::acs::register_icanuse "ns_parsequery -charset" [acs::cmd_error_contains {ns_parsequery} -charset] +::acs::register_icanuse "ns_reflow_text -offset" [acs::cmd_error_contains {ns_reflow_text} -offset] # # At the time "ns_trim -prefix was introduced, a memory leak in # nsv_dict was removed that could lead to a growing size of NaviServer 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.109.2.24 -r1.109.2.25 --- openacs-4/packages/acs-tcl/tcl/text-html-procs.tcl 6 Sep 2021 16:56:46 -0000 1.109.2.24 +++ openacs-4/packages/acs-tcl/tcl/text-html-procs.tcl 25 Jan 2022 23:12:04 -0000 1.109.2.25 @@ -1817,7 +1817,9 @@ # Expand entities before outputting set text [util_expand_entities $text] - # If we're not in a PRE + # + # If we're not inside an HTML "
" element.
+        #
         if { $output(pre) <= 0 } {
             # collapse all whitespace
             regsub -all -- {\s+} $text { } text
@@ -1839,7 +1841,10 @@
                 set text [string trimleft $text]
             }
         } else {
-            # we're in a PRE: clean line breaks and tabs
+            #
+            # We're inside an HTML 
 element: clean line breaks
+            # and tabs.
+            #
             regsub -all -- {\r\n} $text "\n" text
             regsub -all -- {\r} $text "\n" text
             # tabs become four spaces
@@ -1875,8 +1880,32 @@
         }
 
 
-        if {1} {
-            # If there's a blockquote in the beginning of the text, we wouldn't have caught it before
+        if {[::acs::icanuse "ns_reflow_text -offset"]} {
+            #
+            # Reflow based on "ns_reflow_text -offset". This is
+            # substantially faster, especially on longer text strings.
+            #
+            set plain [ns_reflow_text \
+                           -offset $output(linelen) \
+                           -width $output(maxlen) \
+                           -- $text]
+            #ns_log notice "XXXX -> <$plain>"
+            set lastNewLine [string last \n $plain]
+            if {$lastNewLine == -1} {
+                incr output(linelen) [string length $plain]
+            } else {
+                set output(linelen) [expr {[string length $plain] - $lastNewLine}]
+            }
+            set plain [join [split $plain \n] \n[string repeat {    } $output(blockquote)]]
+            #ns_log notice "plain\n$plain"
+            #ns_log notice "blockquote $output(blockquote) linelen $output(linelen) maxlen $output(maxlen)"
+            append output(text) $plain
+
+        } else {
+            #
+            # If there's a blockquote in the beginning of the text, we
+            # wouldn't have caught it before.
+            #
             if { $output(text) eq "" } {
                 append output(text) [string repeat {    } $output(blockquote)]
             }
@@ -1908,27 +1937,6 @@
                     }
                 }
             }
-        } else {
-            #
-            # This is an experimental version that requires a version
-            # of NaviServer supporting the "-offset" argument. So it
-            # is deactivated for the time being for public use.
-            #
-            set plain [ns_reflow_text \
-                           -offset $output(linelen) \
-                           -width $output(maxlen) \
-                           $text]
-            set lastNewLine [string last \n $plain]
-            #ns_log notice "ns_reflow_text -width $output(maxlen) <$text>\ntext: $text\nplain $plain"
-            if {$lastNewLine == -1} {
-                incr output(linelen) [string length $plain]
-            } else {
-                set output(linelen) [expr {[string length $plain] - $lastNewLine}]
-            }
-            set plain [join [split $plain \n] \n[string repeat {    } $output(blockquote)]]
-            #ns_log notice "plain\n$plain"
-            #ns_log notice "blockquote $output(blockquote) linelen $output(linelen) maxlen $output(maxlen)"
-            append output(text) $plain
         }
     }