create new tag
, view all tags

Improved Outline Support in TWiki

I felt that TWiki could use better outline support rather than simple bullet & numbered list support. To that end I've slightly modified TWiki.pm's emitList() and getRenderedVersion() functions. I added a function parameter to emitList() but it's still backward compatible to anything that calles it without that option. When the extra parameter is given it is filled into the "type" parameter for the <ol> tag. Ex:

<ol type='a'>

The above will be created for a listing done like this:

   a This is a test

The following types are supported for ordered lists:

Type Value Generated Style Sample Sequence
1 Arabic numerals 1, 2, 3, 4...
A Uppercase letters A, B, C, D...
a Lowercase letters a, b, c, d...
I Uppercase Roman Numerals I, II, III, IV...
i Lowercase Roman Numerals i, ii, iii, iv...

Attached to this topic you will find a copy of my modified version of TWiki.pm. I've implemented it on my site so if you'd like to see it in action, visit my example or edit a test topic.

-- DanBoitnott - 27 Jan 2003

Looks good Dan. I would extend it so that a delimeter is required in order to avoid the problem of a paragraph starting with    A fine way to... doesn't inadvertantly become a list item. For example:

   a) this is a list item started with "a)"
   b. this is a list item started with "b."
   c] ...etc.
   A fine way to start a paragraph which is not a list item.

Also note the other efforts to extent TWiki's list handling (below).

-- MattWilkie - 27 Jan 2003

A delimeter requirement could easily be asserted but I didn't because I wanted it to be a natural extension of the way TWiki's other ordered and unordered lists are made. At the moment an optional period can follow the Type Value. Simply remove the question mark after the period in the regex to make it required. Also, in order for a paragraph starting with "A" to be highlighted as a list item it would have to have leading tabs (three spaces).

-- DanBoitnott - 28 Jan 2003

You can also escape the first letter of the sentence with a <nop> tag.

-- DanBoitnott - 29 Jan 2003

I hope you'll update this following the TWikiRelease01Feb2003.

-- AntonAylward - 29 Jan 2003

Dan, how hard would it be to implement this as a plugin?

-- GrantBow - 29 Jan 2003

I went with a mod to TWiki.pm for the performance but it would be pretty straight-forward to do this as a plugin. Your plugin would have a regex in it's commonTagsHandler which look something like this:

$_[0] =~ s/(\t)+([aAiI]) (.*)/&handleHeading(length($1), $2, $3)/geo;

Then implement handleHeading() based on TWiki::emitList() but with these parameters:

  1. The indent level
  2. The type value
  3. The contents of the list item

Also, I'll probably update if for the TWikiRelease01Feb2003 but since the implementation is so simple, I wonder if it might make it into the CairoRelease?

-- DanBoitnott - 30 Jan 2003

My point about plug-in vs core had to do with the fact that there are already many patches that have been applied to the "original" piece of Core code, and if you isues this wonderful feature as a plug-in we could benefit from it withough havign to know Perl and figure out what you've changed and apply it on top of exising patches.

As it is, you code overwrites exisitng pathces.

Even if you issued it as a "diff", many patched systems still couldn't make use of it.

And since Bejing is coming out in a few days (hopefully), all that would be lost when it was overwritten with the new TWiki.pm.

Wheras if you issued it as plug-in, we could all make use of it immediately, regardless of what patches we had applied.

I'm also disturbed by your implication that all Twiki admins need to be Perl gurus. I've commented before about the "programmer centric" attitudes in ths community. If Twiki is to become a useful tool in a wider and more business-oriented community, we have to take a "user-centric" appoach.

At one level I was very hopeful. The ImprovedOutlines is really like an ordinary user types. It handles the issues of blank likes and the user explicitly typing the list tag. Dead on. Wonderful.

But please don't make it a requirement that one has to be a perl programmer in order to deploy it.

-- AntonAylward - 31 Jan 2003

You make a good point which I hadn't considered. I'll port the code to a plugin soon. It may take a few days though because in it's present form it's just a tiny hack, in plugin form I'll have to re-implement some of the view script's functionality in a way that won't interfere.

-- DanBoitnott - 01 Feb 2003

Somehow I have just discovered this great looking outline enhancement. Any news on updating the patch for the 01Feb03 TWiki release? I'd love to start using this!

-- LynnwoodBrown - 15 Mar 2003

To everybody who's been waiting for me to update this for TWikiRelease01Feb2003 I'm sorry it's taken so long. I'd planned to buckle down and follow AntonAylward's suggestion to turn it into a plugin. That really is the right way to do it. I just haven't had the time lately. In it's present form it's less than ten lines inserted into TWiki.pm. Unfortunately a plugin version would be considerably more complicated. I will get around to this when I can but have other commitments at the moment.

-- DanBoitnott - 16 Mar 2003

Nothing stopping anyone else turning it into a plugin is there? Better that than wait to 2005 for it to get into the core of CairoRelease! stick out tongue

Dan - am I right in thinking that you would not mind if someone did this conversion for you?

-- TWikiGuest - 17 Mar 2003

That'd be great.

-- DanBoitnott - 18 Mar 2003

Does this patch still mean that someone with existing documents that have the following in:

    a dog jumped
Would actually break? Whilst I understand the idea of having something "natural", I would argue that Matt's suggestion is worth noting again - don't break other people's content. Also the single objection I saw "it's less natural" really doesn't hold water IMO:
    a) This
    b) That
    c. Other
    d. Another
Is precisely the sort of thing you see people typing. I've virtually never seen people just write bare letters. If the requirement for punctuation was made non-optional I think this is a nice addition, if it's kept optional I personally view it as dubious and should be moved into a plugin. </tuppenceworth>

On the flipside, if Dan thinks it should be a plugin now rather than in the core code, should this feature be removed from the nice to have section of CairoRelease ? </randomthought>

-- MichaelSparks - 04 Jul 2003

This is now in TWikiAlphaRelease, see CVS:lib/TWiki.pm

TextFormattingRules docs need to be updated. Same syntax as before for digits, e.g. with or without a dot, but a dot is required for "A", "a", "I" and "i" to reduce the risk of breaking existing content. The docs should state only the "with dot" rule.

-- PeterThoeny - 01 Aug 2003

Thanks Peter! I must have been asleep when this went in; I missed it. I note that TextFormattingRules has still not been updated. I'd do it myself but am not sure what delimeters are allowed for.

-- MattWilkie - 01 Jan 2004

Docs are now updated.

-- PeterThoeny - 25 Apr 2004

Edit | Attach | Watch | Print version | History: r23 < r22 < r21 < r20 < r19 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r23 - 2004-08-16 - 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-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.