Tags:
create new tag
view all tags

Question

Hello,

I often write long list items and feel that the raw text looks really ugly with absolutely no blank lines allowed between successive items. I therefore made a very small change to lib/Render.pm to enable a single blank line to be not counted as a list terminator but two lines to be counted as a list terminator.

This patch is simply (its actually just four or five changed/new lines):

Fri Sep 30 21:48:18 PDT 2005  srinathava@gmail.com
  * two blank lines to terminate a list instead of one
diff -rN -u old-lib/TWiki/Render.pm new-lib/TWiki/Render.pm
--- old-lib/TWiki/Render.pm     2005-09-30 22:03:03.580648768 -0700
+++ new-lib/TWiki/Render.pm     2005-09-30 22:02:27.000000000 -0700
@@ -899,6 +899,7 @@
     $insideTABLE = 0;
     $insideNoAutoLink = 0;      # PTh 02 Feb 2001: Added Codev.DisableWikiWordLinks
     $isList = 0;
+       my $blankLines = 0;
     @listTypes = ();
     @listElements = ();

@@ -934,6 +935,7 @@
         m|</pre>|i && ( $insidePRE = 0 );
         m|<noautolink>|i   && ( $insideNoAutoLink = 1 );
         m|</noautolink>|i  && ( $insideNoAutoLink = 0 );
+               m|\S| && ( $blankLines = 0 );

         if( $insidePRE ) {
             # inside <PRE>
@@ -1016,7 +1018,7 @@
             }

 # Lists and paragraphs
-            s/^\s*$/<p \/>/o                 && ( $isList = 0 );
+            s/^\s*$/<p \/>/o                 && ( $blankLines = $blankLines + 1);
             m/^(\S+?)/o                      && ( $isList = 0 );
            # Definition list
             s/^(\t+)\$\s(([^:]+|:[^\s]+)+?):\s/<dt> $2 <\/dt><dd> /o && ( $result .= &emitList( "dl", "dd", length $1 ) );
@@ -1026,7 +1028,7 @@
            # Numbered list
             s/^(\t+)([1AaIi]\.|\d+\.?) ?/<li> /o && ( $result .= &emitList( "ol", "li", length $1, $2 ) );
            # Finish the list
-            if( ! $isList ) {
+            if( $blankLines >= 2 ) {
                 $result .= &emitList( "", "", 0 );
                 $isList = 0;
             }

This however introduces a very strange (and ugly) side-effect. Namely the "Edit", "Attach" and "Printable" links are now shown on three lines actually as a list rather than on a single line...

The toolbar code with the patch becomes:

<div class="twikiToolBar"><div>



<li> <a href="/%7Esrinath/twiki/bin/edit.cgi/Main/WebHome?t=1128143273"><b>Edit</b></a>
</li>
<li> <a href="/%7Esrinath/twiki/bin/attach.cgi/Main/WebHome">Attach</a>

</li>
<li> <a href="/%7Esrinath/twiki/bin/view.cgi/Main/WebHome?skin=print.pattern">Printable</a>
</li></div>

Without the patch, the toolbar code is

div class="twikiToolBar"><div>
<ul>
<li> <a href="/%7Esrinath/twiki/bin/edit.cgi/Main/WebHome?t=1128143649"><b>Edit</b></a>

</li>
<li> <a href="/%7Esrinath/twiki/bin/attach.cgi/Main/WebHome">Attach</a>
</li>
<li> <a href="/%7Esrinath/twiki/bin/view.cgi/Main/WebHome?skin=print.pattern">Printable</a>
</li>
</ul>
</div>

Could anyone please let me know of a good way to approach the fix?

PS: I know that this issue has been disussed multiple times at:

and other places. But I would like for the raw text to remain readable and all the solutions so far seem to ask the user to put extra stuff in the raw text.

Environment

TWiki version: TWikiRelease02Sep2004
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS:  
Web server:  
Perl version:  
Client OS:  
Web Browser:  
Categories: Contributing code

-- SrinathAvadhanula - 01 Oct 2005

Answer

ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.

This is better posted as a ChangeProposal in the Codev web.

-- PeterThoeny - 01 Nov 2005

Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r2 - 2005-11-01 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.