diff roundup/cgi/templating.py @ 7864:b080cdb8b199

fix: document/fix wrapped HtmlProperty method. The wrapped method was not documented in reference.txt. It is now documented in reference.txt. The docstring documented that it would not break up long words. Fixed by adding break_long_words=False to prevent breaking string longer than the wrap length. Wrapping was breaking the hyperlinking of long urls. Added columns argument to set the wrap length (default 80 columns).
author John Rouillard <rouilj@ieee.org>
date Sun, 07 Apr 2024 15:27:18 -0400
parents 219fc5804345
children 9bbc1d951677
line wrap: on
line diff
--- a/roundup/cgi/templating.py	Sun Apr 07 15:21:00 2024 -0400
+++ b/roundup/cgi/templating.py	Sun Apr 07 15:27:18 2024 -0400
@@ -1835,7 +1835,7 @@
             s = self.hyper_re.sub(self._hyper_repl, s)
         return s
 
-    def wrapped(self, escape=1, hyperlink=1):
+    def wrapped(self, escape=1, hyperlink=1, columns=80):
         """Render a "wrapped" representation of the property.
 
         We wrap long lines at 80 columns on the nearest whitespace. Lines
@@ -1847,13 +1847,16 @@
         - "escape" turns on/off HTML quoting
         - "hyperlink" turns on/off in-text hyperlinking of URLs, email
           addresses and designators
+        - "columns" sets the column where the wrapping will occur.
+          Default of 80.
         """
         if not self.is_view_ok():
             return self._('[hidden]')
 
         if self._value is None:
             return ''
-        s = '\n'.join(textwrap.wrap(str(self._value), 80))
+        s = '\n'.join(textwrap.wrap(str(self._value), columns,
+                                    break_long_words=False))
         if escape:
             s = html_escape(s)
         if hyperlink:

Roundup Issue Tracker: http://roundup-tracker.org/