There is a problem with the indentation of unnumbered lists:
* first item ** subitem *** subsubitem * last item
Hatta renders this as
That is, "last item" is at the same indentation as "subitem" but it should be at the same indentation as "first item".
Thank you very much for catching that one. It's a little embarrassing to make such a basic mistake, and to leave it unnoticed for so long. Fixed in the development version, will be fixed in the next release. – Radomir Dopieralski
Thanks, this is obviously fixed since the markup is displaying correctly here now. Really cool to see Hatta progressing so well, so don't feel embarrassed! I have a few more minor issues to post here if you'll indulge me. – julian
Of course, all feedback is accepted, although I reserve the right to refuse or postpone indefinitely implementing of some features
– Radomir Dopieralski
Radomir, looks like there is still a minor problem with the
HTML markup not balancing correctly. If you look at the source,
you can see that there is a missing </li> before last item:
<ul>
<li>first item
<ul>
<li>subitem
<ul>
<li>subsubitem
</li>
</ul>
</li>
</ul>
<li>last item
</li>
</ul>
Here is a patch for the problem. Note: I can now see why this is tricky to get correct. It took me several tries before it would pass all my tests, and those are only the ones I could think of. There may be more tests which still don't work. – julian
# HG changeset patch
# User Julian Cowley <julian@lava.net>
# Date 1238278595 36000
# Node ID 8ee16844ab3a9fb95cf53c9ee573c35c876fa5a7
# Parent e45021fe19b51758ff3e892f26cc959d5ec6d8ad
Fix the handling of bullet lists with different levels
diff --git a/hatta.py b/hatta.py
--- a/hatta.py
+++ b/hatta.py
@@ -870,17 +870,25 @@
level = 0
for self.line_no, line in block:
nest = len(self.bullets_re.match(line).group(0).strip())
+ assert level == 0 or level >= 1
+ assert nest >= 1
if nest == level:
yield '</li>'
- while nest > level:
+ elif nest > level:
+ level += 1
+ while nest > level:
+ yield '<ul><li>'
+ level += 1
yield '<ul id="line_%d">' % self.line_no
- level += 1
- while nest < level:
- yield '</li></ul>'
- level -= 1
+ else:
+ while nest < level:
+ yield '</li></ul>'
+ level -= 1
+ yield '</li>'
content = line.lstrip().lstrip('*').strip()
yield '<li>%s%s' % (u"".join(self.parse_line(content)),
self.pop_to(""))
+ assert level >= 1
yield '</li></ul>'*level
def _block_quote(self, block):
I see nothing wrong with the HTML that is generated now, and neither can the W3C validator at http://validator.w3.org/ (apart from a problem with the <style> tag), see validation page. In your example you skipped the last two closing tags, </li></ul> – you probably didn't notice that inner <ul> blocks have to be inside the outer <li> blocks. Can you show me an example input that makes current code produce wrong output, and your code right? – Radomir Dopieralski
Hmm… looks like the validator is wrong after all… I think it's good now…
<ul id="line_8">
<li>
first item
<ul id="line_9">
<li>subitem
<ul id="line_10">
<li>subsubitem</li>
</ul>
</li>
</ul>
</li>
<li>
last item
</li>
</ul>
thank you for pointing this out, I wonder why the automated validator didn't catch that. Probably some bug. I will have to invest in a real test suite. – Radomir Dopieralski