Install & Compatibility
Where this runs
tested against v1.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.152s · 18.6MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.7s · import 0.144s · 19MB
17MB installed
● package 17MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
makeExtension
✓ from mdx_truly_sane_lists import makeExtension
✗ from markdown import markdown
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)
Debug
Known issues
breakingIncompatibility with Python-Markdown 3.4+ prior to mdx-truly-sane-lists v1.3. Older versions of this extension would fail to load with Python-Markdown versions 3.4 and newer, resulting in 'Failed loading extension' errors.fixUpgrade mdx-truly-sane-lists to version 1.3 or newer. If an upgrade is not possible, pin the 'Markdown' package dependency to a version less than 3.4 (e.g., `Markdown==3.3.7`).
affects: mdx-truly-sane-lists < 1.3 when used with Python-Markdown >= 3.4
breakingIncompatibility with Python-Markdown 3.0+ prior to mdx-truly-sane-lists v1.2. Earlier versions of this extension were not compatible with Python-Markdown 3.0 and above.fixUpgrade mdx-truly-sane-lists to version 1.2 or newer.
affects: mdx-truly-sane-lists < 1.2 when used with Python-Markdown >= 3.0
gotchaOrdered lists not starting at '1' may not render as expected. When used, especially with MkDocs Material, ordered lists that do not explicitly start with `1.` (e.g., `5. Item A`) might not be processed correctly by the extension, potentially overriding Python-Markdown's default `sane_lists` behavior for such cases.fixEnsure ordered lists start from `1.`. For MkDocs users, a workaround involves adding a hook to patch the `TrulySaneOListProcessor` to set `LAZY_OL = False` (refer to GitHub issue #21 for details).
affects: All versions (inherent behavior interacting with default Markdown parsing)
gotchaThe extension enforces 'sane lists' behavior, disallowing the mixing of ordered and unordered list items without proper separation. This is an intentional design choice but can be unexpected for users accustomed to more lenient Markdown parsers.fixAlways separate different list types (ordered vs. unordered) with a blank line if they are meant to be distinct lists, or maintain a consistent list type within a logical block to avoid unintended merging or rendering issues.
affects: All versions (inherent design feature)
Upgrade
Version history
1.3latest on PyPI · released Jul 19, 2022
Audit
Dependencies
MarkdownrequiredThis is a Python-Markdown extension and requires the core Markdown library to function.