Extension pack for Python Markdown that provides 20+ specialized extensions for enhanced text processing.
—
Extensions for organizing and structuring content including task lists with checkboxes, tabbed interfaces, collapsible details sections, visual progress bars, and enhanced list formatting.
GitHub-style task lists with interactive checkboxes, supporting both completed and pending tasks with customizable styling.
def makeExtension(**kwargs):
"""
Create TaskList extension for GitHub-style task lists.
Configuration:
- custom_checkbox: bool - Use custom checkbox HTML (False)
- clickable_checkbox: bool - Make checkboxes clickable (False)
- checkbox_text: str - Custom checkbox HTML text
Returns:
TasklistExtension instance
"""
class TasklistExtension(Extension):
"""GitHub-style task list extension."""
class TasklistTreeprocessor(Treeprocessor):
"""Task list processing and checkbox generation."""
def get_checkbox(checked=False, clickable=False):
"""
Generate checkbox HTML for task lists.
Parameters:
- checked: bool - Whether checkbox is checked
- clickable: bool - Whether checkbox is interactive
Returns:
str - Checkbox HTML
"""Usage Example:
import markdown
md = markdown.Markdown(extensions=['pymdownx.tasklist'])
text = """
## Todo List
- [x] Completed task
- [ ] Pending task
- [x] Another completed task
- [ ] Nested pending task
- [x] Nested completed task
"""
html = md.convert(text)Create tabbed interfaces and content blocks with support for nested tabs and customizable styling.
def makeExtension(**kwargs):
"""
Create Tabbed extension for tabbed content interfaces.
Configuration:
- alternate_style: bool - Use alternate tab styling (False)
- combine_header_slug: bool - Combine header with slug (False)
- slugify: callable - Custom slugify function
Returns:
TabbedExtension instance
"""
class TabbedExtension(Extension):
"""Tabbed content extension."""
class TabbedProcessor(BlockProcessor):
"""Tabbed content processor."""Usage Example:
import markdown
md = markdown.Markdown(extensions=['pymdownx.tabbed'])
text = """
=== "Tab 1"
Content for tab 1
=== "Tab 2"
Content for tab 2
=== "Tab 3"
Content for tab 3
"""
html = md.convert(text)HTML details/summary collapsible blocks for creating expandable content sections.
def makeExtension(**kwargs):
"""
Create Details extension for collapsible content blocks.
Configuration:
- open_details: bool - Open details by default (False)
Returns:
DetailsExtension instance
"""
class DetailsExtension(Extension):
"""Details/summary collapsible blocks extension."""
class DetailsProcessor(BlockProcessor):
"""Details block processor."""Usage Example:
import markdown
md = markdown.Markdown(extensions=['pymdownx.details'])
text = """
??? "Click to expand"
This content is initially hidden and can be expanded by clicking the summary.
??? note "Important Note"
This is an important note that starts collapsed.
???+ warning "Always Visible"
This details block starts expanded (+ modifier).
"""
html = md.convert(text)Visual progress bars with percentage indicators and customizable styling for showing completion status.
def makeExtension(**kwargs):
"""
Create ProgressBar extension for visual progress indicators.
Configuration:
- progress_increment: int - Progress bar increment value (5)
- add_classes: str - Additional CSS classes
- level_class: bool - Include class that defines progress level (True)
Returns:
ProgressBarExtension instance
"""
class ProgressBarExtension(Extension):
"""Progress bar extension."""
class ProgressBarPattern(InlineProcessor):
"""Progress bar pattern processor."""
class ProgressBarTreeProcessor(AttrListTreeprocessor):
"""Progress bar tree processor."""Usage Example:
import markdown
md = markdown.Markdown(extensions=['pymdownx.progressbar'])
text = """
Progress: [=75%] (75%)
Loading: [===60%] (60%)
Complete: [=100%] (100%)
"""
html = md.convert(text)Enhanced ordered lists with custom numbering styles including Roman numerals, letters, and custom start values.
def makeExtension(**kwargs):
"""
Create FancyLists extension for enhanced ordered lists.
Configuration:
- generic: bool - Generic list attribute support (True)
Returns:
FancyListsExtension instance
"""
class FancyListsExtension(Extension):
"""Enhanced ordered lists extension."""
class FancyListsTreeprocessor(Treeprocessor):
"""List processing with custom numbering support."""Usage Example:
import markdown
md = markdown.Markdown(extensions=['pymdownx.fancylists'])
text = """
1) First item (parenthesis style)
2) Second item
3) Third item
a. Letter numbering
b. Second letter
c. Third letter
i. Roman numerals
ii. Second roman
iii. Third roman
"""
html = md.convert(text)Improved header parsing and validation with better handling of header syntax and structure.
def makeExtension(**kwargs):
"""
Create SaneHeaders extension for improved header processing.
Returns:
SaneHeadersExtension instance
"""
class SaneHeadersExtension(Extension):
"""Sane header processing extension."""
class SaneHeadersProcessor(HashHeaderProcessor):
"""Header processor with improved validation."""Usage Example:
import markdown
md = markdown.Markdown(extensions=['pymdownx.saneheaders'])
# Better handling of edge cases in header syntax
text = """
# Valid Header
## Another Valid Header
### Third Level Header
"""
html = md.convert(text)text = """
=== "Outer Tab 1"
=== "Inner Tab A"
Content for inner tab A
=== "Inner Tab B"
Content for inner tab B
=== "Outer Tab 2"
Regular content without inner tabs
"""text = """
??? "Project Tasks"
- [x] Design phase complete
- [x] Development started
- [ ] Testing phase
- [x] Unit tests
- [ ] Integration tests
- [ ] User acceptance testing
- [ ] Deployment
"""extension_configs = {
'pymdownx.progressbar': {
'add_classes': 'custom-progress',
'progress_increment': 10
}
}
text = """
Project Completion: [===30%]{: .project-progress} (30%)
Feature Development: [=======70%]{: .feature-progress} (70%)
"""text = """
{: type="I" start="5"}
5. Fifth item in Roman numerals
6. Sixth item
7. Seventh item
{: type="a"}
1. First letter item
2. Second letter item
3. Third letter item
"""extension_configs = {
'pymdownx.tasklist': {
'custom_checkbox': True,
'clickable_checkbox': True,
'checkbox_text': '<input type="checkbox" %s>'
}
}extension_configs = {
'pymdownx.tabbed': {
'alternate_style': True,
'combine_header_slug': True
}
}extension_configs = {
'pymdownx.details': {
'open_details': True # Start with details expanded
}
}from typing import Callable, Optional, Union
from markdown import Extension, BlockProcessor, Treeprocessor, InlineProcessor
# Custom function types
SlugifyFunc = Callable[[str, str], str] # Custom slugify function
CheckboxGenerator = Callable[[bool, bool], str] # Checkbox HTML generator
# Configuration types
ProgressIncrement = int # Progress bar increment value
ListType = str # List numbering type ('1', 'a', 'A', 'i', 'I')
ListStart = int # List start numberInstall with Tessl CLI
npx tessl i tessl/pypi-pymdown-extensions