create new tag
, view all tags
OK, this took more time than I expected. I have numbered headers working, and I'm pecking at numbered lists right now.

The modified TWiki.pm is attached below (called TWiki.numbering.pm). I will update the code for numbered lists once I get it done, but it might be harder to do than numbered headings ( meaning more than half a day)

-- DavidWeller - 23 Feb 2002

OK, here's the summary of the changes and what things won't work:

  • Lists won't number correctly. I can fix that, but it means overhauling the way lists are handled, and I'm not up for that.
  • The TWiki.numbering.pm module will no longer recognize "three spaces(or tab) and a pound" as a legal header start. I did this so that List numbering would work in the future.
  • I've tested this in several ways. It seems to work for me. I invite others to try it
  • Header numbering should be more flexible. If you want to start at the H2 level, I don't see why not. It just means you have to track the original "low water mark" for headers.

Maybe I'll fix the rest of this one of these days, but probably not. Tinkering with TWiki is cutting into my time working on LunaWiki, which is (obviously) more important to me. I've promised myself this is my last weekend to hack at the TWiki code. smile

-- DavidWeller - 24 Feb 2002

Well I kinda needed this functionality in a hurry (so that I could produce nice printable documents with numbered headings) so I wrote a patch to TWiki20040320beta to suit my needs. It is based on code from DavidWeller but looks quite different since TWiki.pm has moved on after two years. Differences to the original patch are

  • Unnumbered headings are not output in the TOC if there are any numbered headings preceding it
  • Pre-request variables initialised to zero so this will work in mod_perl
  • I slipped in some style attributes so that I could have stylesheets for MsoToc1, MsoToc2 etc. so I can format them the way MS Word rather cleverly does by using stylesheets
  • Patched against 2004 code rather than 2002 code!
The code itself isn't great... there is some duplication but I didn't get round to tidying it up, it does work after all. The Core implementer may well want to look at doing a tidy or maybe even moving stuff out to some core plug-in?

I'm running this on Apache/mod_perl/perl 5.8/cygwin(rcs,bash) with some minor modifications to get around perl 5.8 issues.

-- KevinTam - 23 Jul 2004

(Please keep conversations above this line. I think the "rules" part should move if this is accepted into TWiki)

Here's the "rules" for headers

1. State of count is maintained throughout a single topic. INCLUDEd topics are considered part of the topic for numbered header rendering

2. Syntax is

  ---# <- one # for each header "depth"

3. Format is always: "Legal" Numbering, No indentation.


4. Maximum "Depth" is 6 Levels. Levels exceeding 6, (i.e., ---#######) will "clamp" to 6 (This is a non-modifiable limit set by TWiki)

5. Non-consecutive increasing levels will force a "skip" indicator

Will render as

6. Non-consecutive decreasing levels will render correctly


Will render as

7. Level Numbering always starts at level 1. A missing "first" level will force a "skip" indicator

Example, if the first numbered header is at level 2 (---##)

It will render as


8. Non-numbered headers will not affect the numbering or level depth sequencing:

  ---# Introduction
  ---+++ Obtuse Examples
  ---## Abstract Examples

Will render as
1.0 Introduction
Obtuse Examples (in <H3> "normal" format)
1.1 Abstract Examples

Here's "The Rules" For numbering Lists

1. State of count is maintained throughout a single series of list elements. INCLUDEd topics are considered part of the topic for numbered list rendering

2. Syntax is

   # <- three spaces for each level increase

3. Format is always: "ALR" (Arabic-Latin-Roman) Numbering, with indentation.

NOTE: This may be a contentious point for some folks, but since Numbered Headers is also locked into the equation, I need to use something different.

4. Maximum "Depth" is 9 Levels. Levels exceeding 9, will "clamp" to 9 (Cuz I dont want to do more than that! That's why! smile )

5. Non-consecutive increasing levels will be ignored, but indentation will be non-symmetrical because an "invisible level" will be rendered. (example can't be shown)

6. Non-consecutive decreasing levels will render correctly (example can't be shown)

7. Level Numbering always starts at level 1. (example can't be shown)

8. Non-numbered list elements will not affect the numbering or level depth sequencing of lists:

Wonderful!! I've been waiting for this. I probably won't try to test it (I'm not too good at things like ungrading TWiki, yet), but I want to start lobbying to get it included in the Beijing release.

-- RandyKramer - 24 Feb 2002

Note that the code attached above involves changes against an interim state of TWiki.pm. For your convenience, I am attaching the diff supporting this feature against the Athens release as NumberedHeadersAndLists.twiki.pm.diff

-- ThomasWeigert - 02 Jul 2002

I discovered that this also needs the changes to TOC from the Beijing modifications. Otherwise the numbering does not get reset after a TOC. I guess it is better to bring in all the changes in TWiki.numbering.pm, if you want to try this modification.

-- ThomasWeigert - 03 Jul 2002

Numbered lists should go into CairoRelease.

-- PeterThoeny - 18 Jan 2003

I like both of these ideas which use auto-formatting by depth. But I thought it would also be cool if the user could just create an outline the same way they would make bullets and sub-bullets. To that end I've made some very small changes to TWiki.pm posted them in ImprovedOutlines.

-- DanBoitnott - 30 Jan 2003

>Numbered lists should go into CairoRelease.

...but not numbered headers? or was that just shorthand for both?

-- MattWilkie - 03 Jan 2004

Is everyone aware that the ---# syntax already works as a heading. Is this documented anywhere?

Example Heading with Hash

-- SamHasler - 01 Apr 2004

defered until someone does the work

-- SvenDowideit - 20 Apr 2004

Implemented in ExplicitNumberingPlugin.

I am not sure if this is intended, but I have always experienced this as a bug: when I create a numbered list with:

   1 item 1
   2 item 2
   3 <s>item 3</s>
   4 item 4
   10 item 10

This gets rendered as:

  1. item 1
  2. item 2
  3. item 3
  4. item 4
  5. item 10

So my explicit numbering gets ignored. Very annoying when you are working at a TODO list with your team and the numbers get mixed up.

Don't we have the rule that automatic numbering is only done when number 1 is used?

-- ArthurClemens - 22 Nov 2006

Arthur, assuming you are talking about numbered lists using the twiki syntax (n * 3 spaces followed by a digit), it does not matter what digit it is, I think (I was trying to look through the code but could not find where this processing is done).

-- ThomasWeigert - 22 Nov 2006

Uyes, the current code lets you use any number to create a numbered list 1..n, but it is not documented that way. The document example on TextFormattingRules just used the '1'.

-- ArthurClemens - 22 Nov 2006

Topic attachments
I Attachment History Action Size Date Who Comment
Texttxt TWiki.KevinTam.pm.diff.txt r1 manage 11.1 K 2004-07-23 - 17:13 KevinTam Patch against TWiki20040320beta
Edit | Attach | Watch | Print version | History: r19 < r18 < r17 < r16 < r15 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r19 - 2008-01-24 - VickiBrown
  • 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.