TitleEnhanceNumberedListWithStartAtIndex
Date17-Jul-2006 19:01:29 EEST
JSPWiki version2.2.33
SubmitterMartin Hache
Idea CategoryMarkupIdea
Reference
Idea StatusNewIdea

Desired Behavior#

Using the current markup, it's not possible to start, interrupt and restart an numbered list without it starting back at 1. Or, to start at an arbitrary number.

Here's an example, of what's I'm proposing

I want to start numbering at any value, not just 1.

5. start of a list (there is no 1, 2, 3 or 4)
6. Another item
    1. An indent

A new paragraph interrupts the numbered list

7. But that's OK because I can use #(7) to continue it!
8. and another.

Suggested Syntax#

I propose adding a (\d) attribute to the right of the #, bullets 7 and 8 would look like this:

#(7) But that's OK because I can use #(7) to continue it!
# and another.

Generated HTML code#

HTML allows you to add a "value=" attribute to the <li>. It also supports a "start=" on the <ol> but I thought that the <li> was simpler and more flexible. So it looks like this:

<li value="7"> But that's OK because I can use #(7) to continue it!

Example Implementation#

I'm sure that my implementation is less than exemplary (and bullet proof - no pun intended) but I wanted to keep things simple and restrict my changes as much as possible.

I edited the 2.2.33 version of com.ecyrd.jspwiki.TranslatorReader and modified the HTMLRenderer.openListItem() on line 2806.

it used to just be return "<li>"; but now it's like this:

public String openListItem() throws IOException
{

    // Get the start argument (\d) if present
    String startArgument = readWhile( "(01234567890)" );
        	
    // Default the start output to ""
    String startArgumentHTML = "";

    // if a StartArg was present and the first char is ( and the last char is ) then we'll assume a vale
    if (startArgument != null 
                    && !"".equals(startArgument) 
                    &&  startArgument.charAt(0) == '(' 
        		    && startArgument.charAt(startArgument.length() - 1) == ')'
        		    && isNumber(startArgument.substring(1, startArgument.length() - 1))) {
    {
        // set the start argument
	startArgumentHTML = " VALUE=\"" + startArgument.substring(1, startArgument.length() - 1) + "\"  "; 
    }
        	
    return "<li" + startArgumentHTML + ">";
}

Known issues#

  • I'm using readWhile() which increaments the pointer rather than a Reg Ex so even though my checks eliminate things like #((9), #)9(, etc... from getting into the value="" they are also removed from screen.
  • It won't work with the Counter plugin because it appears to be generated after the bullet :-(
  • I don't differentiate between the * and # so unordered lists get a value as well, but the browser (at least IE 6.0) does not care
  • I don't handle spaces between # and (\d) but maybe that's a good thing.

That's a nice idea, actually. I'll certainly think about it!

-- JanneJalkanen

Add new attachment

Only authorized users are allowed to upload new attachments.
« This page (revision-13) was last changed on 17-Jul-2006 22:17 by Janne Jalkanen