Skip to content
A Python-Markdown extension for interactive regulation text
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Update main.workflow May 7, 2019
regdown Update May 17, 2019
.gitattributes Specify merge driver for changelog to avoid text conflicts Mar 25, 2016
.gitignore Initial commit independent of cfgov-refresh May 6, 2019
.travis.yml Update and for release May 20, 2019 Fix typo in Jul 6, 2017
LICENSE Initial commit independent of cfgov-refresh May 6, 2019 Add documentation and examples to README May 6, 2019 Update and for release May 20, 2019
tox.ini Update for Markdown 3.0 API, drop 2.6 support May 6, 2019


Build Status Coverage Status

Regdown is a Python-Markdown extension for interactive regulation text.



First, install Regdown:

pip install regdown

Then you can either:

  • Specify Regdown as an extension in calls to markdown:

    import markdown
    from regdown import RegulationsExtension
    markdown.markdown(text, extensions=[RegulationsExtension()],)
  • Use convenience regdown function to render Markdown with the RegulationsExtension:

    from regdown import regdown


Regdown adds three major features to Markdown to support making federal regulations easier to navigate and read.

Labeled Paragraphs

{label} Paragraph text

Each paragraph can have a defined label, using {label} syntax at the start of the paragraph. This is translated into an id attribute on the resulting HTML paragraph element. If no label is given, the contents of the paragraph are hashed to generate a unique id for that paragraph. This makes any paragraph in the text directly linkable.

Pseudo Forms

  • Form field: __
  • __Form Field
  • inline__fields__

Example print forms, where the \_\_ indicate a space for hand-written input. Can be any number of underscores between 2 and 50.

Section symbols

§ 1024.5(d) §1024.5(d)

Section symbols will always have a non-breaking space ( ) inserted between them and whatever follows to avoid hanging a symbol at the end of a line.

Block references


Insert the contents of labeled paragraphs in other Regdown documents inline into the current document.

References can be placed before or after paragraphs. These references are to labeled paragraphs in other Markdown documents. When a contents_resolver callback and url_resolver callback are provided, the text of those other paragraphs can be looked up and inserted inline into the document making the reference. If render_block_reference callback is provided, custom rendering of the referenced text to HTML can be performed.


  • contents_resolver(label): resolve the paragraph label and return the Markdown contents of that paragraph if the paragraph exists.
  • url_resolver(label): resolve the paragraph label and return a URL to that paragraph if the paragraph exists.
  • render_block_reference(contents, url=None): render the contents of a block reference to HTML. The url to the reference may be give as a keyword argument if url_resolver is provided.
from regdown import regdown

def my_contents_resolver(label):
    # Lookup the document that contains the given label …
    return corresponding_markdown_text

def my_block_renderer(block_markdown_contents, url=None):
    # Render the block to HTML
    return block_html


Getting help

Please add issues to the issue tracker.

Getting involved

General instructions on how to contribute can be found in CONTRIBUTING.


  1. TERMS
  3. CFPB Source Code Policy

Credits and references

regdown was forked from Wagtail-Flags, which was itself forked from cfgov-refresh.

You can’t perform that action at this time.