Edgewall Software
Modify

Opened 19 years ago

Closed 10 years ago

#2446 closed enhancement (fixed)

ordered lists that don't start at 1

Reported by: marius@… Owned by: Christian Boos
Priority: normal Milestone: 1.0.3
Component: wiki system Version: 0.9.2
Severity: normal Keywords: orderedlist
Cc: ryano@…, Jun Omae Branch:
Release Notes:

Ordered lists can be "restarted" at any given value, including 0.

API Changes:
Internal Changes:

Description

If I try to split a numbered list and insert an explanation in the middle, like this:

  1. Item
  2. Item
  3. Item

some comment

  4. Item
  5. Item

then Trac shows the list with numbers 1, 2, 3, 1, 2 instead of 1, 2, 3, 4, 5.

Wish: Trac should specify the starting value of a numbered list explicitly (<ol start="4">), if that list didn't start from 1.

Attachments (1)

wiki_list_enhancements_r3014.diff (4.4 KB ) - added by Christian Boos 19 years ago.
Patch adding the start attribute when needed, plus allow for other types of lists.

Download all attachments as: .zip

Change History (21)

comment:1 by Christopher Lenz, 19 years ago

Priority: normallow

The only problem I can see with this is that unfortunately, the start attribute of the <ol> has been deprecated in HTML, which means it is not valid XHTML Strict.

Personally, I'd say that doesn't matter, though.

comment:2 by markus, 19 years ago

I agree with cmlenz. IMHO there're no other ways than either just use the deprecated start attribute in XHTML Strict or switch to XHTML Transitional. According to the W3C you should use counters instead of the start and value attributes, but this is currently only supported by Opera.

by Christian Boos, 19 years ago

Patch adding the start attribute when needed, plus allow for other types of lists.

comment:3 by Christian Boos, 19 years ago

Milestone: 0.10
Owner: changed from Jonas Borgström to Christian Boos
Status: newassigned

I've added a patch for this feature. I took this opportunity to add support for alpha and roman numbered lists.

I wonder if while I'm at it, I should add support for unnumbered lists started by a "-" character, which are pretty common in changeset log messages…

comment:4 by Christian Boos, 19 years ago

Resolution: fixed
Status: assignedclosed

Patch applied in r3162.

comment:5 by mieses, 17 years ago

Resolution: fixed
Status: closedreopened

The number sequence is still reset after a break:

 1. Item 1
 1. Item 2
 1. Item 3
some comment
 1. Item 4
 1. Item 5

renders as:

  1. Item 1
  2. Item 2
  3. Item 3

some comment

  1. Item 4
  2. Item 5

Also, the start attribute of <ol> is not rendered for numbers whose leading digit is a '1'.

 1. Item 1
 2. Item 2

 10. Item 10
 1. Item 11

 20. Item 20
 1. Item 21

 100. Item 100

 200. Item 200

renders as:

  1. Item 1
  2. Item 2
  1. Item 10
  2. Item 11
  1. Item 20
  2. Item 21
  1. Item 100
  1. Item 200

comment:6 by Christian Boos, 17 years ago

Milestone: 0.100.12

The number sequence is reset after a break by design. If this is not what you want, then you can explicitly set the restart number (like in the example in the description), except for 2-digits numbers, as you've found out.

I'll look into changing that for 0.12.

comment:7 by mieses, 17 years ago

Thank you. This is the first time i'm tempted to learn python to fix it myself.

Any number starting with a '1', not just 2 digit numbers, fails to explicitly set the restart value. 20-99 are OK. The problem is with 10-19, 100-199, 1000-1999, etc.

Also, it's not possible to explicitly set the restart value in the case of a,b,c,d and i,ii,iii etc.

(Maybe I over-use the list formatting feature and this issue is not very critical.)

comment:8 by clm100, 17 years ago

I'd like to bump up resets of non-numeric ordered lists:

Renders as:

 A. Something
 B. Something
Comment
 C. Something

Renders as:

  1. Something
  2. Something

Comment

  1. Something

comment:9 by mpotter@…, 15 years ago

Note: In supporting continuation of non-numeric order lists there is a potential syntax conflict:

Is "I. " the continuation of an A. B. C. D. list or the start of an I. II. III. IV. list?

comment:10 by Ryan Ollos <ryano@…>, 15 years ago

Cc: ryano@… added

in reply to:  8 comment:11 by Christian Boos, 15 years ago

Keywords: orderedlist added
Milestone: next-major-0.1X0.12
Priority: lownormal

I was about to close this one as another duplicate of #8892, but it looks like this is still wrong (as seen in comment:8).

The corresponding HTML is now:

<ol class="upperalpha"><li>Something
</li><li>Something
</li></ol><p>
Comment
</p>
<ol class="upperalpha" start="C"><li>Something
</li></ol>

But this renders as:

  1. Something
  2. Something

Comment

  1. Something

Follow-up needed to r9208, as the restart value must be a numerical one, even for loweralpha or upperalpha ordered list.

comment:12 by Christian Boos, 15 years ago

Resolution: fixed
Status: reopenedclosed

Fixed in r9314.

comment:13 by Jun Omae, 10 years ago

I noticed that ordered list with zero starts at 1. Trac Wiki generates <ol class="arabiczero"> but ol.arabiczero rule isn't defined in trac.css. Instead, ol.arabic is defined. Is that behavior a defect?

See also demo-0.12/ticket/6330.

comment:14 by anonymous, 10 years ago

ol.arabic seems to be used with RST (#721)

in reply to:  13 ; comment:15 by Christian Boos, 10 years ago

Milestone: 0.120.12.7
Resolution: fixed
Status: closedreopened

Replying to jomae:

I noticed that ordered list with zero starts at 1. Trac Wiki generates <ol class="arabiczero"> but ol.arabiczero rule isn't defined in trac.css. Instead, ol.arabic is defined. Is that behavior a defect?

Right, now r3162 looks also wrong to me in that respect.

Proposed fix:

  • trac/wiki/formatter.py

    diff --git a/trac/wiki/formatter.py b/trac/wiki/formatter.py
    index 6c6eb80..0cb1e18 100644
    a b class Formatter(object):  
    814814        else:
    815815            type_ = 'ol'
    816816            lstart = fullmatch.group('lstart')
    817             start = None
    818             idx = '0iI'.find(listid)
    819             if idx > -1:
    820                 class_ = ('arabiczero', 'lowerroman', 'upperroman')[idx]
    821             elif listid.isdigit():
    822                 start = lstart != '1' and int(lstart)
     817            if listid == 'i':
     818                class_ = 'lowerroman'
     819            elif listid == 'I':
     820                class_ = 'upperroman'
     821            elif listid.isdigit() and lstart != '1':
     822                start = int(lstart)
    823823            elif listid.islower():
    824824                class_ = 'loweralpha'
    825825                if len(lstart) == 1 and lstart != 'a':
    class Formatter(object):  
    845845            self._list_stack.append((new_type, depth))
    846846            self._set_tab(depth)
    847847            class_attr = (lclass and ' class="%s"' % lclass) or ''
    848             start_attr = (start and ' start="%s"' % start) or ''
     848            start_attr = (start is not None and ' start="%s"' % start) or ''
    849849            self.out.write('<'+new_type+class_attr+start_attr+'><li>')
    850850        def close_item():
    851851            self.flush_tags()
  • trac/wiki/tests/wiki-tests.txt

    diff --git a/trac/wiki/tests/wiki-tests.txt b/trac/wiki/tests/wiki-tests.txt
    index f198406..492ac02 100644
    a b Paragraph  
    13521352 1. item 1
    13531353   a. item 1.a
    13541354   a. item 1.b
     1355     0. start at 0
    13551356
    13561357Some paragraph
    13571358
    Paragraph  
    13631364<ol><li>item 1
    13641365<ol class="loweralpha"><li>item 1.a
    13651366</li><li>item 1.b
    1366 </li></ol></li></ol><p>
     1367<ol start="0"><li>start at 0
     1368</li></ol></li></ol></li></ol><p>
    13671369Some paragraph
    13681370</p>
    13691371<ol start="2"><li>continue with item 2
    Paragraph  
    137613781. item 1
    13771379   a. item 1.a
    13781380   a. item 1.b
     1381     0. start at 0
    13791382
    13801383Some paragraph                                                                                                                             

Targeting the 0.12.7 milestone, but if you think this won't disrupt the beta1 release, I can also commit the fix earlier.

in reply to:  15 comment:16 by Ryan J Ollos, 10 years ago

Replying to cboos:

Targeting the 0.12.7 milestone, but if you think this won't disrupt the beta1 release, I can also commit the fix earlier.

If you commit in the next 12 hours it shouldn't disrupt the release. I'm going to do another documentation sync tonight, and then continue with the release in the morning.

comment:17 by Jun Omae, 10 years ago

Cc: Jun Omae added

Thanks for the patch. I agree targeting the 0.12.7 milestone. Because that is a minor issue.

comment:18 by Christian Boos, 10 years ago

Status: reopenedassigned

Fine by me, let's get that in after the release.

comment:19 by Christian Boos, 10 years ago

Milestone: 0.12.71.0.3

comment:20 by Christian Boos, 10 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Patch applied on 1.0-stable in [13417] and merged on trunk in [13418].

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.