or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

advanced-blocks.mdcode-and-math.mdcontent-structure.mdindex.mdlinking-and-media.mdtext-enhancement.mdutilities-specialized.md
tile.json

tessl/pypi-pymdown-extensions

Extension pack for Python Markdown that provides 20+ specialized extensions for enhanced text processing.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/pymdown-extensions@10.16.x

To install, run

npx @tessl/cli install tessl/pypi-pymdown-extensions@10.16.0

index.mddocs/

PyMdown Extensions

A comprehensive collection of extensions for Python Markdown that significantly enhances its functionality beyond the standard library. Provides 20+ specialized extensions covering syntax highlighting, mathematical expressions, enhanced emphasis formatting, code fencing with custom formatters, emoji support, task lists, tabbed content, progress bars, smart symbols, and advanced linking capabilities.

Package Information

  • Package Name: pymdown-extensions
  • Language: Python
  • Installation: pip install pymdown-extensions
  • Optional Dependencies: pip install pymdown-extensions[extra] (includes Pygments for syntax highlighting)

Core Imports

import markdown

Typical usage pattern:

import markdown

# Use extensions by name
md = markdown.Markdown(extensions=['pymdownx.betterem', 'pymdownx.superfences'])

Direct extension import:

from pymdownx import betterem, superfences

# Create extension instances
md = markdown.Markdown(extensions=[
    betterem.makeExtension(),
    superfences.makeExtension()
])

Basic Usage

import markdown

# Basic markdown with pymdown extensions
md = markdown.Markdown(extensions=[
    'pymdownx.betterem',      # Better emphasis handling
    'pymdownx.superfences',   # Enhanced code blocks
    'pymdownx.tasklist',      # Task lists with checkboxes
    'pymdownx.emoji',         # Emoji support
    'pymdownx.magiclink'      # Auto-linking
])

# Convert markdown to HTML
text = """
# Example Document

This is **bold** and *italic* text.

- [x] Completed task
- [ ] Pending task

:smile: :heart: :+1:

https://github.com/facelessuser/pymdown-extensions
"""

html = md.convert(text)
print(html)

Architecture

PyMdown Extensions follows the standard Python-Markdown extension pattern:

  • Extension Classes: Each extension inherits from markdown.Extension
  • Processors: Handle specific markdown patterns (preprocessors, inline processors, block processors, tree processors, postprocessors)
  • Factory Functions: makeExtension() functions provide standard instantiation interface
  • Configuration: Extensions accept configuration via standard markdown extension config pattern
  • Utility Framework: Common utilities in pymdownx.util for extension development

The package provides a consistent API across all extensions while offering extensive customization options for each specific markdown enhancement.

Capabilities

Text Enhancement Extensions

Extensions that enhance text formatting including better emphasis handling, insert/delete markup, superscript/subscript, highlighting, and smart symbol replacement.

# Better emphasis with configurable asterisk/underscore handling
def makeExtension(**kwargs): ...  # pymdownx.betterem

# Insert tags and superscript using caret syntax
def makeExtension(**kwargs): ...  # pymdownx.caret

# Delete strikethrough and subscript using tilde syntax  
def makeExtension(**kwargs): ...  # pymdownx.tilde

# Text highlighting using mark tags
def makeExtension(**kwargs): ...  # pymdownx.mark

# Smart replacement of ASCII with Unicode symbols
def makeExtension(**kwargs): ...  # pymdownx.smartsymbols

Text Enhancement

Code and Math Extensions

Extensions for syntax highlighting, mathematical expressions, inline code highlighting, and enhanced fenced code blocks with custom formatters.

# Advanced code syntax highlighting
def makeExtension(**kwargs): ...  # pymdownx.highlight

# Inline code syntax highlighting
def makeExtension(**kwargs): ...  # pymdownx.inlinehilite

# Enhanced fenced code blocks with custom formatters
def makeExtension(**kwargs): ...  # pymdownx.superfences

# LaTeX math rendering support
def makeExtension(**kwargs): ...  # pymdownx.arithmatex

# Base64 image embedding for offline documents
def makeExtension(**kwargs): ...  # pymdownx.b64

Code and Math

Content Structure Extensions

Extensions for organizing content including task lists, tabbed interfaces, collapsible details, progress bars, and enhanced lists.

# GitHub-style task lists with checkboxes
def makeExtension(**kwargs): ...  # pymdownx.tasklist

# Tabbed content blocks and interfaces
def makeExtension(**kwargs): ...  # pymdownx.tabbed

# HTML details/summary collapsible blocks
def makeExtension(**kwargs): ...  # pymdownx.details

# Visual progress bars with percentage indicators
def makeExtension(**kwargs): ...  # pymdownx.progressbar

# Enhanced ordered lists with custom numbering
def makeExtension(**kwargs): ...  # pymdownx.fancylists

Content Structure

Linking and Media Extensions

Extensions for automatic linking, emoji support, keyboard key formatting, and link processing enhancements.

# Comprehensive emoji support with multiple providers
def makeExtension(**kwargs): ...  # pymdownx.emoji

# Automatic linking for URLs, emails, repositories
def makeExtension(**kwargs): ...  # pymdownx.magiclink

# Keyboard key styling and formatting
def makeExtension(**kwargs): ...  # pymdownx.keys

# Convert and normalize file paths in links
def makeExtension(**kwargs): ...  # pymdownx.pathconverter

Linking and Media

Advanced Block Extensions

Extensions using the generic blocks framework for admonitions, captions, definitions, HTML blocks, and other structured content.

# Generic block processing framework
def makeExtension(**kwargs): ...  # pymdownx.blocks

# Individual block implementations
class Admonition: ...     # pymdownx.blocks.admonition
class Details: ...        # pymdownx.blocks.details  
class Tab: ...           # pymdownx.blocks.tab
class Caption: ...       # pymdownx.blocks.caption
class Definition: ...    # pymdownx.blocks.definition
class HTML: ...          # pymdownx.blocks.html

Advanced Blocks

Utility and Specialized Extensions

Utility extensions, content processing tools, and specialized functionality including snippet inclusion, HTML processing, and development utilities.

# Include external file content and code snippets
def makeExtension(**kwargs): ...  # pymdownx.snippets

# Remove or escape HTML tags
def makeExtension(**kwargs): ...  # pymdownx.striphtml

# Escape any character with backslash
def makeExtension(**kwargs): ...  # pymdownx.escapeall

# CriticMarkup support for tracked changes
def makeExtension(**kwargs): ...  # pymdownx.critic

# Enhanced version of Python-Markdown Extra
def makeExtension(**kwargs): ...  # pymdownx.extra

Utilities and Specialized

Extension Configuration Pattern

All PyMdown Extensions follow the standard Python-Markdown configuration pattern:

def makeExtension(*args, **kwargs):
    """
    Standard extension factory function.
    
    Parameters:
    - *args: Positional arguments (usually config tuples)
    - **kwargs: Configuration options as keyword arguments
    
    Returns:
    Extension instance configured with provided options
    """

Common Utilities

# Common utilities for extension development
class PatternSequenceProcessor: ...
def clamp(value, min_val, max_val): ...
def escape_chars(md, chars): ...
def deprecated(message): ...

Types

# Standard Python-Markdown types
from markdown import Extension, Preprocessor, InlineProcessor, BlockProcessor, Treeprocessor, Postprocessor

# Extension configuration
ConfigOption = Any  # Configuration option value
ExtensionConfig = Dict[str, ConfigOption]  # Extension configuration dictionary