{"id":400,"date":"2015-02-15T00:34:36","date_gmt":"2015-02-15T00:34:36","guid":{"rendered":"http:\/\/blogs.gentoo.org\/lu_zero\/?p=400"},"modified":"2015-04-19T12:24:27","modified_gmt":"2015-04-19T12:24:27","slug":"bridging-markdown-to-sphinx","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/lu_zero\/2015\/02\/15\/bridging-markdown-to-sphinx\/","title":{"rendered":"Bridging Markdown to sphinx"},"content":{"rendered":"<p>One of my annoying itch is documentation.<\/p>\n<p>I like a lot <a href=\"http:\/\/sphinx-doc.org\">sphinx<\/a> as toolchain but the underlying <a href=\"http:\/\/docutils.sourceforge.net\/docs\/ref\/rst\/restructuredtext.html\">rst<\/a> has a quite steep learning curve and it is outright ugly to write in many common situation.<\/p>\n<p>I like a lot <a href=\"http:\/\/kramdown.gettalong.org\/\">kramdown<\/a> as syntax but sadly it is ruby-only and overall the Markdown implementation for python usually have a good number of shortcomings, including the quite annoying part of not having a full AST for the extensions, making quite a pain to proper translations (e.g. moin-2 markdown can&#8217;t use the extension supported by the original since they get mangled badly during the process of node matching)&#8230;<\/p>\n<h2>Enters CommonMark<\/h2>\n<p><a href=\"http:\/\/commonmark.org]\">CommonMark<\/a> is a cooperative effort to build actually a proper specification of the ubiquitous markdown syntax. The implementations usually provide a full AST and the python one (derived from the javascript one) is quite easy to understand, fast enough and easy to extend.<\/p>\n<p>I know that somebody else already tried to <a href=\"https:\/\/github.com\/sgenoud\/remarkdown\">bridge<\/a> docutils and markdown, sadly <code>parsley<\/code> is a tad slow for the purpose. I gutted away the original markdown parser and wired in <a href=\"https:\/\/github.com\/lu-zero\/remarkdown\/\">commonmark-py<\/a> the result is a decently fast implementation that maps most of the core syntax to the docutils AST and thus makes possible to write in markdown and get it converted using the docutils output formats.<\/p>\n<h2>What&#8217;s left<\/h2>\n<p>ReStructuredText is much richer than CommonMark core, at least I should complete my work to support <a href=\"http:\/\/talk.commonmark.org\/t\/consistent-attribute-syntax\/272\">attributes<\/a> so the manpage output would work mostly as intended.<\/p>\n<p>The <a href=\"http:\/\/docutils.sourceforge.net\/docs\/ref\/rst\/restructuredtext.html#directives\">directive<\/a> system is quite different from the one <a href=\"http:\/\/talk.commonmark.org\/t\/generic-directives-plugins-syntax\/444\/113\">currently discussed<\/a> and that will cause a good deal of headache to map the sphinx extension to document the function parameters.<\/p>\n<p>As usual help welcome!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of my annoying itch is documentation. I like a lot sphinx as toolchain but the underlying rst has a quite steep learning curve and it is outright ugly to write in many common situation. I like a lot kramdown as syntax but sadly it is ruby-only and overall the Markdown implementation for python usually &hellip; <a href=\"https:\/\/blogs.gentoo.org\/lu_zero\/2015\/02\/15\/bridging-markdown-to-sphinx\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Bridging Markdown to sphinx<\/span><\/a><\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[1],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p1aGWH-6s","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/lu_zero\/wp-json\/wp\/v2\/posts\/400"}],"collection":[{"href":"https:\/\/blogs.gentoo.org\/lu_zero\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.gentoo.org\/lu_zero\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/lu_zero\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/lu_zero\/wp-json\/wp\/v2\/comments?post=400"}],"version-history":[{"count":2,"href":"https:\/\/blogs.gentoo.org\/lu_zero\/wp-json\/wp\/v2\/posts\/400\/revisions"}],"predecessor-version":[{"id":451,"href":"https:\/\/blogs.gentoo.org\/lu_zero\/wp-json\/wp\/v2\/posts\/400\/revisions\/451"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/lu_zero\/wp-json\/wp\/v2\/media?parent=400"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/lu_zero\/wp-json\/wp\/v2\/categories?post=400"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/lu_zero\/wp-json\/wp\/v2\/tags?post=400"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}