Skip to main content

Markdown extension for interactive regulations

Project description

Regdown

Build Status Coverage 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 cfgov-refresh.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

regdown-1.0.1.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

regdown-1.0.1-py2.py3-none-any.whl (11.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file regdown-1.0.1.tar.gz.

File metadata

  • Download URL: regdown-1.0.1.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for regdown-1.0.1.tar.gz
Algorithm Hash digest
SHA256 1e32ca9251b79088a30d22601f61be2bffd56342854691402e72b73095a846fc
MD5 7e07e7c73e42b9e1ff2079097dc2187d
BLAKE2b-256 70b4722d65aa121186c1144dc8f59adb10ba476679d3793545f570d9d9c4f10a

See more details on using hashes here.

Provenance

File details

Details for the file regdown-1.0.1-py2.py3-none-any.whl.

File metadata

  • Download URL: regdown-1.0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for regdown-1.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 90a59718a35c795e59834f9b37305cf09104b984332362c4e700292450c8426c
MD5 2f44ca747f7a74e3294fa6c3e7805703
BLAKE2b-256 1a04bb40a410d0a8fa9b78d02968e81bee10445f925e5b30158445af1ecf9a09

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page