readthedocs/commonmark.py

Nested list in markdown cannot convert to rst correctly

flynxea opened this issue · 1 comments

* abc
    - 123
    - 456
* def

should show as:

  • abc
    • 123
    • 456
  • def

But with the code:

def md2rst(lines):
    m = '\n'.join(lines)

    parser = commonmark.Parser()
    ast = parser.parse(m)

    renderer = commonmark.ReStructuredTextRenderer()
    rst = renderer.render(ast)

    lines[:] = rst.splitlines()

it cannot output the correct rst string.

The same issue.
Sometimes node.list_data['marker_offset'] contains invalid offset number, so, that's parsing to AST issue.

Example:
image