Opened 19 years ago
Closed 10 years ago
#2446 closed enhancement (fixed)
ordered lists that don't start at 1
Reported by: | 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)
Change History (21)
comment:1 by , 19 years ago
Priority: | normal → low |
---|
comment:2 by , 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 , 19 years ago
Attachment: | wiki_list_enhancements_r3014.diff added |
---|
Patch adding the start attribute when needed, plus allow for other types of lists.
comment:3 by , 19 years ago
Milestone: | → 0.10 |
---|---|
Owner: | changed from | to
Status: | new → assigned |
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:5 by , 17 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
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:
- Item 1
- Item 2
- Item 3
some comment
- Item 4
- 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:
- Item 1
- Item 2
- Item 10
- Item 11
- Item 20
- Item 21
- Item 100
- Item 200
comment:6 by , 17 years ago
Milestone: | 0.10 → 0.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 , 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.)
follow-up: 11 comment:8 by , 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:
- Something
- Something
Comment
- Something
comment:9 by , 15 years ago
Note: In supporting continuation of non-numeric order lists there is a potential syntax conflict:
Is "
I.
" the continuation of anA. B. C. D.
list or the start of anI. II. III. IV.
list?
comment:10 by , 15 years ago
Cc: | added |
---|
comment:11 by , 15 years ago
Keywords: | orderedlist added |
---|---|
Milestone: | next-major-0.1X → 0.12 |
Priority: | low → normal |
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:
- Something
- Something
Comment
- Something
Follow-up needed to r9208, as the restart value must be a numerical one, even for loweralpha or upperalpha ordered list.
follow-up: 15 comment:13 by , 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.
follow-up: 16 comment:15 by , 10 years ago
Milestone: | 0.12 → 0.12.7 |
---|---|
Resolution: | fixed |
Status: | closed → reopened |
Replying to jomae:
I noticed that ordered list with zero starts at 1. Trac Wiki generates
<ol class="arabiczero">
butol.arabiczero
rule isn't defined intrac.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): 814 814 else: 815 815 type_ = 'ol' 816 816 lstart = fullmatch.group('lstart') 817 start = None818 idx = '0iI'.find(listid)819 if idx > -1:820 class_ = ('arabiczero', 'lowerroman', 'upperroman')[idx]821 elif listid.isdigit() :822 start = lstart != '1' andint(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) 823 823 elif listid.islower(): 824 824 class_ = 'loweralpha' 825 825 if len(lstart) == 1 and lstart != 'a': … … class Formatter(object): 845 845 self._list_stack.append((new_type, depth)) 846 846 self._set_tab(depth) 847 847 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 '' 849 849 self.out.write('<'+new_type+class_attr+start_attr+'><li>') 850 850 def close_item(): 851 851 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 1352 1352 1. item 1 1353 1353 a. item 1.a 1354 1354 a. item 1.b 1355 0. start at 0 1355 1356 1356 1357 Some paragraph 1357 1358 … … Paragraph 1363 1364 <ol><li>item 1 1364 1365 <ol class="loweralpha"><li>item 1.a 1365 1366 </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> 1367 1369 Some paragraph 1368 1370 </p> 1369 1371 <ol start="2"><li>continue with item 2 … … Paragraph 1376 1378 1. item 1 1377 1379 a. item 1.a 1378 1380 a. item 1.b 1381 0. start at 0 1379 1382 1380 1383 Some 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.
comment:16 by , 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 , 10 years ago
Cc: | added |
---|
Thanks for the patch. I agree targeting the 0.12.7 milestone. Because that is a minor issue.
comment:18 by , 10 years ago
Status: | reopened → assigned |
---|
Fine by me, let's get that in after the release.
comment:19 by , 10 years ago
Milestone: | 0.12.7 → 1.0.3 |
---|
comment:20 by , 10 years ago
Release Notes: | modified (diff) |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
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.