[Home]WikiPatches/OrderedListNumbering

UseModWiki | WikiPatches | RecentChanges | Preferences

I devised this patch for a corporate internal wiki that we're using to collect use cases. Some of my users wanted more control over numbered lists, to support the listing of steps in a use case's 'main scenario' and 'extension scenarios'. The patch allows you to control the starting number and numbering style of a numbered list or sublist. It is perforce based closely on HTML's ordered list functionality. This goes a bit beyond what most people would want to do with UseMod formatting, but we find it useful.

The patch is provided below as a unified diff against UseMod 1.0. It also includes a change from center- to left-justification for table cells, simply because this is a change that I have locally and it touches a single nearby line. You can easily remove that if you like.

-- DanMuller


--- wiki.pl	2005-05-23 15:50:56.000000000 -0400
+++ wiki-ordered-list-numbering-and-table-left.pl	2005-05-27 14:56:53.000000000 -0400
@@ -1711,15 +1711,18 @@
     } elsif (s/^(\*+)/<li>/) {
       $code = "UL";
       $depth = length $1;
-    } elsif (s/^(\#+)/<li>/) {
+    } elsif (s/^(\#+)(\d*)([aAiI]?)/'<li' . ($2 ? " VALUE=\"$2\"" : '') . '>'/e) {
       $code = "OL";
       $depth = length $1;
+      if ($3) {
+        $codeAttributes = " TYPE=\"$3\"";
+      }
     } elsif ($TableSyntax &&
              s/^((\|\|)+)(.*)\|\|\s*$/"<TR VALIGN='CENTER' "
-                                      . "ALIGN='CENTER'><TD colspan='"
+                                      . "ALIGN='LEFT'><TD colspan='"
                                . (length($1)\/2) . "'>$3<\/TD><\/TR>\n"/e) {
       $code = 'TABLE';
-      $codeAttributes = "BORDER='1'";
+      $codeAttributes = " BORDER='1'";
       $TableMode = 1;
       $depth = 1;
     } elsif (/^[ \t].*\S/) {
@@ -1742,7 +1745,7 @@
       }
       while (@htmlStack < $depth) {
         push(@htmlStack, $code);
-        $pageHtml .= "<$code $codeAttributes>\n";
+        $pageHtml .= "<$code$codeAttributes>\n";
       }
     }
     if (!$ParseParas) {


UseModWiki | WikiPatches | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited November 17, 2007 6:56 pm by MarkusLude (diff)
Search: