mdx-truly-sane-lists

1.3 · active · verified Fri Apr 10

mdx-truly-sane-lists is an extension for Python-Markdown that aims to make lists behave more predictably. It provides features like custom indents for nested lists and fixes for messy linebreaks and paragraphs within lists. The current version is 1.3, released in 2022, with previous major updates in 2018 and 2016, indicating an infrequent release cadence.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to apply the `mdx-truly-sane-lists` extension to Markdown text using the `markdown` function. It shows both basic usage with default settings and how to provide custom configurations for `nested_indent` and `truly_sane` options.

from markdown import markdown

# Basic usage with default config (nested_indent: 2, truly_sane: True)
text_basic = """
- Item 1
  - Nested Item 1
    - Double Nested
- Item 2
"""
html_basic = markdown(text_basic, extensions=['mdx_truly_sane_lists'])
print("Basic Render:\n", html_basic)

# With explicit config for customization
text_config = """
1. Ordered Item 1
   1. Nested Ordered Item 1
2. Ordered Item 2
"""
html_config = markdown(
    text_config,
    extensions=['mdx_truly_sane_lists'],
    extension_configs={
        'mdx_truly_sane_lists': {
            'nested_indent': 4, # Custom indent, default is 2
            'truly_sane': True # Fixes linebreaks/paragraphs, default is True
        }
    }
)
print("\nConfigured Render:\n", html_config)

view raw JSON →