.
Unordered lists are great and all, but sometimes I need ordered lists to express a sequence of actions.
And ordered lists are also [[http://www.wikicreole.org/wiki/Creole1.0#section-Creole1.0-OrderedLists|covered]] in the Creole spec. --//Manuel//
----
If you look at [[Wiki Creole]] page, you will note that I listed a number of differences that I decided to introduce. This is because I need a working wiki that I can use -- practicality beats purity.
I have a number of problems with numbered lists:
* **1.** mixing numbered and bullet lists is not well defined, there are lots of corner cases and unexpected results,
* **2.** there is no way to affect automatic numbering -- make it start at different number or skip a number,
* **3.** there is no way to refer to an element of automatically numbered list -- the number one reason why you'd use a numbered list in the first place,
* **4.** there is no good way to display such a list in HTML -- the {{{<ol>}}} element is not for numbered lists, but for lists in which order matters,
* **5.** as soon as you introduce numbered lists, users start using them instead of headings and demand that they can have multiple paragraphs, tables, headings, etc. inside them, which in turn leads to context-free, hard to parse and hard to read markup,
* **6.** most of the time you want manual numbering or numbered headings anyways.
Having said that, if anybody comes up with a sane implementation of numbered lists, I might copy it. I haven't seen any so far.
Sorry for being so stubborn with all your feature requests. I hope you will
still find Hatta useful without them. -- Radomir Dopieralski
----
You have good points, but I have something to say on some of them:
* **1.** The Creole spec for numbered lists seems sufficiently clear to me: every list and sub-list starts from 1. But probably it's not that easy, and you are far more qualified than me to express opinions on this one.
* **3.** I generally use a numbered list for emphasize that a list is //ordered//, like a sequence of actions or for write, let's say, a top-10. With an automatic numbered list I can write the list and modify the order without worring about manually adjusting the numbers. This is the number one reason for me to use ordered lists, and when I have to refer to a specific item of the list I simply write the number down. The question is: it's more convenient to write down //every// number (and manually adjust them every time you modify the order of the list), or just let the wiki engine take care of that and only write down the "goto" where and when you need it? For me it's the latter.
* **4.** It's not necessary to implement a superset of Creole to express ordered lists with numbers, letters, roman numbers, etc. It would be OK just the numbers (see the point 3).
* **5.** Using numbered lists to write headings seems to me like using a chair to cut some bread... It would be sufficient to make numbered lists like bullet ones, and write down in the documentation: "don't use numered lists for write headings". Every tool can be used right or wrong: making it idiot-proof means making it usable //only// by idiots.
* **6.** I can live with manual numbering of list items, but for me it would be more convenient automatic numbering (see point 3). For the numbered headings, the wikipedia (mediawiki) approach could be the answer: normal headings with a TOC macro that creates a numbered table of contents. There is a [[http://hatta-wiki.org/Possibility%20to%20generate%20basic%20Table%20of%20Contents%20for%20pages|feature request]] about that.
BTW, how about making lists support multi-line items? It's not difficult I think, it's just a sequence of paragraphs inside a <li> item (I can be utterly wrong here, I don't know hatta's internals and design).
I don't want to start a flame war here, these are just my opinions and I believe hatta is a quite good piece of software. I like it, and with just a little enhancement it could become one of the indispensable tools in my toolbox :) -- Manuel
----
This patch has the same level of support for unordered list as for ordered list. Hope it can be integrated
{{{#!diff
diff -r 99095854b211 hatta.py
--- a/hatta.py Thu Nov 19 18:38:49 2009 +0100
+++ b/hatta.py Tue Nov 24 14:04:10 2009 +0100
@@ -646,10 +646,12 @@
"""
bullets_pat = ur"^\s*[*]+\s+"
+ list_pat = ur"^\s*[#]+\s+"
heading_pat = ur"^\s*=+"
quote_pat = ur"^[>]+\s+"
block = {
"bullets": bullets_pat,
+ "list": list_pat,
"code": ur"^[{][{][{]+\s*$",
"conflict": ur"^<<<<<<< local\s*$",
"empty": ur"^\s*$",
@@ -727,6 +729,7 @@
self.quote_re = re.compile(self.quote_pat, re.U)
self.heading_re = re.compile(self.heading_pat, re.U)
self.bullets_re = re.compile(self.bullets_pat, re.U)
+ self.list_re = re.compile(self.list_pat, re.U)
self.block_re = re.compile(ur"|".join("(?P<%s>%s)" % kv
for kv in sorted(self.block.iteritems())))
self.code_close_re = re.compile(ur"^\}\}\}\s*$", re.U)
@@ -1035,6 +1038,29 @@
in_ul = False
yield '</li></ul>'*level
+ def _block_list(self, block):
+ level = 0
+ in_ol = False
+ for self.line_no, line in block:
+ nest = len(self.list_re.match(line).group(0).strip())
+ while nest > level:
+ if in_ol:
+ yield '<ol>'
+ yield '<ol id="line_%d">' % self.line_no
+ in_ol = True
+ level += 1
+ while nest < level:
+ yield '</li></ol>'
+ in_ol = False
+ level -= 1
+ if nest == level and not in_ol:
+ yield '</li>'
+ content = line.lstrip().lstrip('#').strip()
+ yield '<li>%s%s' % (u"".join(self.parse_line(content)),
+ self.pop_to(""))
+ in_ol = False
+ yield '</li></ol>'*level
+
def _block_quote(self, block):
level = 0
in_p = False
}}}
-- //Ben//