example command creates a pre-populated markdown file that demonstrates all supported features including syntax highlighting, Mermaid diagrams, tables, and formatting options.
Usage
Arguments
Output path for the generated showcase markdown file.Behavior:
- If OUTPUT is a directory, the file is created as
OUTPUT/example.md - If OUTPUT is a file path, uses that exact path
- Parent directories are created automatically if they don’t exist
- Tilde (
~) expansion is supported
cli.py:273-276Options
Automatically open the generated example file in the Markdown-OS editor after creation.When enabled, this flag chains the Source:
example command with open, equivalent to:cli.py:277-281Overwrite existing files without prompting for confirmation.Aliases: Source:
-f, --forceWithout this flag, if the output file exists, you’ll be prompted:cli.py:282-287Examples
Terminal Output
Success
With —open Flag
Overwrite Prompt
With —force Flag
Template Source
The example content is loaded from a bundled template file:- Headings (H1-H6)
- Text formatting (bold, italic, code)
- Lists (ordered, unordered, nested)
- Code blocks with syntax highlighting
- Mermaid diagrams
- Tables
- Blockquotes
- Horizontal rules
- Links and images
cli.py:201-213
Behavior Details
Path Resolution
- Tilde expansion:
~/docs/example.md→/home/user/docs/example.md - Directory detection: If path exists and is a directory, appends
/example.md - Absolute path: All paths are resolved to absolute before writing
cli.py:184-198
File Writing Process
- Parent directory creation:
mkdir -pequivalent (parents=True, exist_ok=True) - Template loading: Read from package resources (UTF-8 encoding)
- Write operation: Save with UTF-8 encoding
- Success message: Print green confirmation with full resolved path
- Next step hint: Show suggested
opencommand - Optional open: If
--openflag, chain toopen_markdown_file()
cli.py:301-332
Overwrite Protection
When the output file exists:cli.py:303-310
Error Handling
cli.py:312-324
Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success (file created or user cancelled) |
| 1 | Error (template missing, write failure, etc.) |
Use Cases
Quick Start
Generate an example and immediately start editing to learn the features:
Documentation Template
Create a template for team documentation:
Testing Features
Generate a file to test syntax highlighting and Mermaid rendering:
CI/CD Integration
Generate examples in automated scripts:
The generated example file is a static snapshot of the template. It does not auto-update when the package is upgraded. To get the latest template, regenerate the file with
--force.