• This repository has been archived on 25/Mar/2022
  • Stars
    star
    339
  • Rank 121,987 (Top 3 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 9 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A markdown parser for docutils

recommonmark

No Maintenance Intended

Warning: recommonmark is now deprecated. We recommend using MyST for a docutils bridge going forward. See this issue for background and discussion.

A docutils-compatibility bridge to CommonMark.

This allows you to write CommonMark inside of Docutils & Sphinx projects.

Documentation is available on Read the Docs: http://recommonmark.readthedocs.org

Contents

Getting Started

To use recommonmark inside of Sphinx only takes 2 steps. First you install it:

pip install recommonmark 

Then add this to your Sphinx conf.py:

# for Sphinx-1.4 or newer
extensions = ['recommonmark']

# for Sphinx-1.3
from recommonmark.parser import CommonMarkParser

source_parsers = {
    '.md': CommonMarkParser,
}

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

This allows you to write both .md and .rst files inside of the same project.

Links

For all links in commonmark that aren't explicit URLs, they are treated as cross references with the :any: role. This allows referencing a lot of things including files, labels, and even objects in the loaded domain.

Linking to headings in other files

For linking to headings in other files you can use the autosectionlabel sphinx feature, e.g.

# conf.py

extensions = [
    # Auto-generate section labels.
    'sphinx.ext.autosectionlabel',
]

# Prefix document path to section labels, otherwise autogenerated labels would look like 'heading'
# rather than 'path/to/file:heading'
autosectionlabel_prefix_document = True

You would use it like:

<!-- path/to/file_1.md -->

# Title

## My Subtitle
<!-- file_2.md -->

[My Subtitle][]

[My Subtitle]: <path/to/file_1:My Subtitle>

AutoStructify

AutoStructify makes it possible to write your documentation in Markdown, and automatically convert this into rST at build time. See the AutoStructify Documentation for more information about configuration and usage.

To use the advanced markdown to rst transformations you must add AutoStructify to your Sphinx conf.py.

# At top on conf.py (with other import statements)
import recommonmark
from recommonmark.transform import AutoStructify

# At the bottom of conf.py
def setup(app):
    app.add_config_value('recommonmark_config', {
            'url_resolver': lambda url: github_doc_root + url,
            'auto_toc_tree_section': 'Contents',
            }, True)
    app.add_transform(AutoStructify)

See https://github.com/rtfd/recommonmark/blob/master/docs/conf.py for a full example.

AutoStructify comes with the following options. See http://recommonmark.readthedocs.org/en/latest/auto_structify.html for more information about the specific features.

  • enable_auto_toc_tree: enable the Auto Toc Tree feature.
  • auto_toc_maxdepth: The max depth of the Auto Toc. Defaults to 1.
  • auto_toc_tree_section: when True, Auto Toc Tree will only be enabled on section that matches the title.
  • enable_auto_doc_ref: enable the Auto Doc Ref feature. Deprecated
  • enable_math: enable the Math Formula feature.
  • enable_inline_math: enable the Inline Math feature.
  • enable_eval_rst: enable the evaluate embedded reStructuredText feature.
  • url_resolver: a function that maps a existing relative position in the document to a http link
  • known_url_schemes: a list of url schemes to treat as URLs, schemes not in this list will be assumed to be Sphinx cross-references. Defaults to None, which means treat all URL schemes as URLs. Example: ['http', 'https', 'mailto']

Development

You can run the tests by running tox in the top-level of the project.

We are working to expand test coverage, but this will at least test basic Python 2 and 3 compatability.

Why a bridge?

Many python tools (mostly for documentation creation) rely on docutils. But docutils only supports a ReStructuredText syntax.

For instance this issue and this StackOverflow question show that there is an interest in allowing docutils to use markdown as an alternative syntax.

Why another bridge to docutils?

recommonmark uses the python implementation of CommonMark while remarkdown implements a stand-alone parser leveraging parsley.

Both output a docutils document tree and provide scripts that leverage docutils for generation of different types of documents.

Acknowledgement

recommonmark is mainly derived from remarkdown by Steve Genoud and leverages the python CommonMark implementation.

It was originally created by Luca Barbato, and is now maintained in the Read the Docs (rtfd) GitHub organization.

More Repositories

1

readthedocs.org

The source code that powers readthedocs.org
Python
7,860
star
2

sphinx_rtd_theme

Sphinx theme for readthedocs.org
Sass
4,658
star
3

sphinx-autoapi

A new approach to API documentation in Sphinx.
Python
411
star
4

tutorial-template

Template for the Read the Docs tutorial
Python
303
star
5

commonmark.py

DEPRECATED: Python CommonMark parser
Python
241
star
6

ethical-ad-server

The ethical ad server - ads for developers without all the tracking
Python
180
star
7

template

A template Sphinx repo
116
star
8

readthedocs-docker-images

Docker image definitions used by Read the Docs
Dockerfile
113
star
9

sphinx-hoverxref

Sphinx extension to show tooltips with content embedded when hover a reference.
Python
93
star
10

ethical-ad-client

Ethical Ads JavaScript client
JavaScript
60
star
11

sphinx-notfound-page

Create a custom 404 page with absolute URLs hardcoded
Python
42
star
12

tutorial-sphinx-markdown

Jupyter Notebook
33
star
13

ethicalads.io

This repository contains the public marketing website for EthicalAds. The ad server is in the ethical-ad-server repository.
CSS
33
star
14

readthedocs-sphinx-search

Enable search-as-you-type feature for docs hosted by RTD.
Python
32
star
15

actions

GitHub Actions for Read the Docs
JavaScript
31
star
16

pydoc.io

A browser for Python project documentation
Python
25
star
17

ads-for-opensource

An Adblock/AdblockPlus/uBlock compatible filter list for allowing advertising that benefits open source
Python
21
star
18

readthedocs-build

Work in Progress builder
Python
19
star
19

common

Shared bits around multiple repositories
Python
19
star
20

blog

Read the Docs blog
CSS
18
star
21

readthedocs-sphinx-ext

[RTD Internal] This is an extension that we install on all Sphinx builds on Read the Docs
Python
17
star
22

sphinxcontrib-dotnetdomain

A Sphinx domain for .NET languages
Python
15
star
23

website

The Read the Docs community website
HTML
14
star
24

addons

JavaScript client to integrate with Read the Docs nicely
JavaScript
14
star
25

guidelines

Style, brand, and development guidelines
Makefile
13
star
26

livesphinx

A fork of rst.ninjs.org to support Sphinx
CSS
13
star
27

godocjson

Generate json from go.
Go
9
star
28

rtd-sphinx-themes-examples

A project illustrating different Sphinx themes locally and on Read the Docs
Python
7
star
29

tutorial-sphinx-markdown-library

Python
7
star
30

web

Different scenarios (one per branch) to test different build configs on production
7
star
31

apitheme

Sphinx API documentation theme
JavaScript
6
star
32

bot

Bot for Read the Docs monitoring
JavaScript
5
star
33

sphinx-multiproject

Share a single conf.py file between several Sphinx projects
Python
4
star
34

sphinxcontrib-multisrc

Sphinx multiple source path support
Python
2
star
35

time-test

A test repo for Read the Docs
Python
2
star
36

readthedocs-assistant

Python
2
star
37

site-community-images

Source images for our website graphics
Makefile
1
star
38

rtd-mkdocs-test

A Project for testing versions of MkDocs on Read the Docs
1
star
39

analytical

Analytics done server side
Python
1
star
40

validatehttp

HTTP response validation application
Python
1
star
41

test-sphinx-theme

JavaScript
1
star
42

rtd-git-stresstest

A stress test for git on Read the Docs
Python
1
star
43

sui-common-theme

Shared base SUI theme for our website and application
1
star
44

abandoned-project

A repo to build docs for abandoned projects
1
star
45

ext-theme

Read the Docs drop in replacement site templates
HTML
1
star