readthedocs / recommonmark

A markdown parser for docutils
https://recommonmark.readthedocs.io/
MIT License
340 stars 252 forks source link

Adds support for basic markdown tables using the Markdown parser #138

Closed clayrisser closed 5 years ago

clayrisser commented 5 years ago

This fixes issue #68 This fixes issue #3

This not only enables full markdown support using the Markdown python module but also opens the door for more features supported by the Markdown modules various extensions.

I have ensured this pull request is fully backward compatible with the CommonMark parser.

In order to use the Markdown parser this pull request implements, you have to explicitly set the parser property in the recommonmark_config to Markdown.

    app.add_config_value('recommonmark_config', {
        'parser': 'Markdown'
    }, True)

For Sphinx-1.3 you can add it by replacing CommonMarkParser with MarkdownParser

from recommonmark.parser import MarkdownParser

source_parsers = {
    '.md': MarkdownParser,
}

source_suffix = ['.rst', '.md']

You can see my code at the link below. https://github.com/codejamninja/recommonmark/tree/codejamninja/python-markdown

clayrisser commented 5 years ago

High-level architecture

Using Markdown I convert the markdown into html. https://github.com/rtfd/recommonmark/pull/138/files#diff-17a9bdc2700f60d92650717d0c63ff4aR25

Using HTMLParser I walk the html AST. https://github.com/rtfd/recommonmark/pull/138/files#diff-17a9bdc2700f60d92650717d0c63ff4aR47 https://github.com/rtfd/recommonmark/pull/138/files#diff-17a9bdc2700f60d92650717d0c63ff4aR60 https://github.com/rtfd/recommonmark/pull/138/files#diff-17a9bdc2700f60d92650717d0c63ff4aR61

ericholscher commented 5 years ago

This is a huge PR. Did you implement the full RST markdown parser, or did that come from somewhere else?

This also has no user-facing documentation around the differences between the parsers, so that would be the minimum required before merging. It's a lot of code to look at though, so I'm not sure when I'll have time to review it more heavily.

clayrisser commented 5 years ago

I ended up just forking recommonmark and publishing it with the markdown parser as sphinx-markdown-parser.