textile / python-textile

A Python port of Textile, A humane web text generator
Other
68 stars 23 forks source link

Key error u'##' #46

Closed tynopet closed 7 years ago

tynopet commented 7 years ago

I try to transform this text:

# test
### test
## test

and get exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/dmitry/.local/lib/python2.7/site-packages/textile/core.py", line 1368, in textile
    return Textile(html_type=html_type).parse(text)
  File "/home/dmitry/.local/lib/python2.7/site-packages/textile/core.py", line 250, in parse
    text = self.block(text)
  File "/home/dmitry/.local/lib/python2.7/site-packages/textile/core.py", line 471, in block
    block = Block(self, tag, atts, ext, cite, line)
  File "/home/dmitry/.local/lib/python2.7/site-packages/textile/objects/block.py", line 32, in __init__
    self.process()
  File "/home/dmitry/.local/lib/python2.7/site-packages/textile/objects/block.py", line 124, in process
    self.content = self.textile.graf(self.content)
  File "/home/dmitry/.local/lib/python2.7/site-packages/textile/core.py", line 607, in graf
    text = self.textileLists(text)
  File "/home/dmitry/.local/lib/python2.7/site-packages/textile/core.py", line 297, in textileLists
    return pattern.sub(self.fTextileList, text)
  File "/home/dmitry/.local/lib/python2.7/site-packages/textile/core.py", line 349, in fTextileList
    self.olstarts[tl] = self.olstarts[tl] + 1
KeyError: u'##'

Can you fix this?

ikirudennis commented 7 years ago

Man, that packs a lot of ugly textile into a tiny test. I'm doing a massive rewrite of list handling, so I can't guarantee there will be a quick fix. I don't suppose there's any way to format that list correctly?

txstyle.org produces the following:

<ol>
    <li>test
        <ol>
            <li>test</li>
        </ol></li>
    <ol>
        <li>test</li>
    </ol></li>
    </ol>

That seems pretty messy and not exactly what I'd expect given the input, but if you can't can't format the textile input better, is that what you're looking for? Can you provide an example of what you think the output should look like?

tynopet commented 7 years ago

Yes, this output is satisfactory. The main thing doesn't throw an error. Thank you.

ikirudennis commented 7 years ago

Hi, @tynopet. I think I've fixed both this issue and #47. Would you mind testing this to confirm it's fixed and not causing any other issues? pip install git+https://github.com/textile/python-textile.git@develop#egg=textile will have the fixes for both issues. Thanks, again.

tynopet commented 7 years ago

Thank you for fixes.