Skip to main content

Regdown

Build StatusCoverage Status

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

Dependencies

Installation

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(text)
    

Documentation

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

see(label)

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.

Callbacks:

  • 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

regdown(
    text,
    contents_resolver=my_contents_resolver,
    render_block_reference=my_block_renderer
)

Getting help

Please add issues to the issue tracker.

Getting involved

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

Licensing

  1. TERMS
  2. LICENSE
  3. CFPB Source Code Policy

Credits and references

regdown was forked from Wagtail-Flags, which was itself forked from consumerfinance.gov.

Release files for regdown 1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for regdown 1.1
File Size Uploaded
regdown-1.1.tar.gz 17.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for regdown 1.1
File Interpreter ABI Platform
regdown-1.1-py3-none-any.whl Python 3 none any Details

Total release size: 28.2 kB

Release files / regdown-1.1.tar.gz

Download URL regdown-1.1.tar.gz
Size 17.0 kB
Tags Source
SHA-256 checksum
How to use checksums
fbaa266a9f105dde4f153209ca9ca78bee017863a52f88d2b5b38b509113476c
BLAKE2b-256 checksum
How to use checksums
0b5c371f86763e1dbd08d5b97d60499ca907fb01ec4af6819fe53282d151632c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2025.

Transparency log

Release files / regdown-1.1-py3-none-any.whl

Download URL regdown-1.1-py3-none-any.whl
Size 11.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
635df53ba7ba330435bb469dca2649bb9975fabbfdb7598e839479ed6e5d655f
BLAKE2b-256 checksum
How to use checksums
ab1e1f0ced47b76eb92c70eecfb017454ec7167b8ac30e71c4bb242ced16bb1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

1.1 This release

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

1 release file

1.0.2

1 release file

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page