PyMdown Extensions Showcase¶
This page demonstrates all PyMdown Extensions features in action. Use it as a reference for syntax and capabilities.
Code Features¶
Syntax Highlighting with Line Numbers¶
Inline Code Highlighting¶
The range()
function returns a sequence of numbers. In JavaScript, use Array.from()
instead.
Code Annotations¶
def calculate_area(radius):
"""Calculate the area of a circle."""
return 3.14159 * radius ** 2 # (1)!
- Using an approximation of π. For more precision, use
math.pi
.
Content Organization¶
Tabbed Content Examples¶
Grouped Tabs¶
Collapsible Sections¶
Database Connection Details
Host: localhost
Port: 5432
Database: myapp_db
Username: app_user
Important Security Note
Always use environment variables for sensitive configuration:
Deprecated Feature
This feature will be removed in version 3.0. Please migrate to the new API.
Text Formatting¶
Basic Formatting¶
- Highlighted text for emphasis
- Superscript for exponents: x^2^ + y^2^ = z^2^
Subscriptfor chemical formulas: H~2~O- Added text for additions
Deleted textfor deletionsOld textNew text for replacements- Important textWith a comment
Smart Symbols¶
- Copyright: © 2024
- Trademark: MkDocs™
- Registered: Material®
- Arrows: → ← > <
- Ellipsis: ...
- Fractions: ½, ¼, ¾
Lists and Tasks¶
Task Lists¶
Project Setup: - [x] Install MkDocs - [x] Configure Material theme - [x] Add PyMdown Extensions - [ ] Write documentation - [x] Create structure - [ ] Add content - [ ] Review and edit
Features to Implement: - [ ] Search functionality - [ ] Dark mode toggle - [ ] PDF export - [ ] Multi-language support
Definition Lists¶
- MkDocs
- A fast, simple static site generator for building documentation
- Material for MkDocs
- A Material Design theme for MkDocs with many built-in features
- PyMdown Extensions
- A collection of extensions for Python Markdown
- Adds many useful features for technical documentation
Special Features¶
Emoji Support¶
- Standard emoji:
- Material icons:
- FontAwesome:
- Octicons:
Keyboard Keys¶
Common shortcuts:
- Save: Ctrl+S (Windows/Linux) or Cmd+S (macOS)
- Copy: Ctrl+C or Cmd+C
- Paste: Ctrl+V or Cmd+V
- Undo: Ctrl+Z or Cmd+Z
- Select all: Ctrl+A or Cmd+A
- Find: Ctrl+F or Cmd+F
Special keys: Esc, Tab, Caps Lock, Shift, Ctrl, Alt, Cmd, Fn
Mathematical Notation¶
Inline math: The quadratic formula is \(x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}\)
Block equations:
Tables with Alignment¶
Feature | Description | Status |
---|---|---|
Tabs | Organize content | ✅ |
Highlighting | Emphasize code | ✅ |
Task lists | Track progress | ✅ |
Math | LaTeX support | ✅ |
Footnotes¶
MkDocs1 uses Python-Markdown2 with various extensions to process content. PyMdown Extensions3 adds even more features.
Advanced Examples¶
Nested Admonitions¶
Configuration Options
You can nest different types of content:
Complex Code Examples¶
def create_documentation():
"""Generate documentation with nested code blocks."""
markdown_content = '''
## Example Section
```python
# This is a code block within a code block
def nested_function():
return "Hello from nested code!"
```
More content here...
'''
return markdown_content
MagicLink Examples¶
- Repository: facelessuser/pymdown-extensions
- Issue: facelessuser/pymdown-extensions#123
- Pull Request: squidfunk/mkdocs-material#456
- User mention: @squidfunk
- Commit: 5d3e1f6a
Mermaid Diagrams¶
graph TD
A[Start] --> B{Choose Extension}
B -->|Code| C[Highlight/SuperFences]
B -->|Content| D[Tabbed/Details]
B -->|Text| E[Caret/Mark/Tilde]
B -->|Special| F[Emoji/Keys/Math]
C --> G[Enhanced Documentation]
D --> G
E --> G
F --> G
Best Practices Summary¶
Do's
- ✅ Use appropriate extensions for your content type
- ✅ Configure extensions consistently
- ✅ Test all features before deployment
- ✅ Document custom configurations
Don'ts
- ❌ Enable all extensions unnecessarily
- ❌ Nest content too deeply
- ❌ Overuse formatting features
- ❌ Ignore performance impacts
Remember: With great power comes great responsibility. Use these extensions to enhance readability, not to show off!