### Manual Installation of PyMdown Extensions Source: https://facelessuser.github.io/pymdown-extensions/installation These commands guide through a manual installation process for PyMdown Extensions, involving building and then installing the package. This method is typically used when modifying the source code. ```bash $ python setup.py build $ python setup.py install ``` -------------------------------- ### Install Documentation Dependencies with Pip Source: https://facelessuser.github.io/pymdown-extensions/about/development Installs the necessary Python packages for building and previewing documentation, including Zensical, Python-Markdown, and pymdown-extensions. This command should be run from the project root. ```bash pip install -r requirements/docs.txt ``` -------------------------------- ### Arithmatex Block Math Examples Source: https://facelessuser.github.io/pymdown-extensions/extensions/arithmatex This section provides examples of block math syntax supported by Arithmatex, including '$$...$$', '\[...]', and '\begin{}...\end{}'. It highlights the requirement for surrounding empty lines and the specific closing tokens for each block type. ```markdown $$ E(\mathbf{v}, \mathbf{h}) = -\sum_{i,j}w_{ij}v_i h_j - \sum_i b_i v_i - \sum_j c_j h_j $$ ``` ```markdown \[3 < 4\] ``` ```markdown \begin{align} p(v_i=1|\mathbf{h}) & = \sigma\left(\sum_j w_{ij}h_j + b_i\right) \\ p(h_j=1|\mathbf{v}) & = \sigma\left(\sum_i w_{ij}v_i + c_j\right) \end{align} ``` -------------------------------- ### Arithmatex Inline Math Examples Source: https://facelessuser.github.io/pymdown-extensions/extensions/arithmatex These examples showcase the inline math patterns recognized by Arithmatex. It includes the default '$...$' and '(...)' formats, with a note on the 'smart_dollar' mode to avoid conflicts with currency values. The output demonstrates how these are rendered. ```markdown $p(x|y) = \frac{p(y|x)p(x)}{p(y)}$, \(p(x|y) = \frac{p(y|x)p(x)}{p(y)}\). ``` -------------------------------- ### Configure Extended Pygments Lexer Options for PHP Source: https://facelessuser.github.io/pymdown-extensions/extensions/highlight Illustrates how to extend Pygments lexer options using the `extend_pygments_lang` configuration. This example creates a 'php-inline' alias to enable the 'startinline' option for PHP code blocks that may not start with ''. ```python extend_pygments_lang = [ {"name": "php-inline", "lang": "php", "options": {"startinline": True}} ] ``` -------------------------------- ### Install Node.js Development Dependencies Source: https://facelessuser.github.io/pymdown-extensions/about/development Installs JavaScript dependencies required for editing document themes, including SCSS and JavaScript compilation. This command should be run from the project root after ensuring Node.js version >= 10 is installed. ```bash npm install ``` -------------------------------- ### Development Installation of PyMdown Extensions Source: https://facelessuser.github.io/pymdown-extensions/installation This command installs PyMdown Extensions in an editable mode using pip. This is useful for developers who want to make changes to the source code and see them reflected immediately without reinstallation. ```bash $ pip install --editable . ``` -------------------------------- ### Install PyMdown Extensions with Pip Source: https://facelessuser.github.io/pymdown-extensions/installation This command installs the PyMdown Extensions package using pip, the standard Python package installer. Ensure you have Python and pip installed. ```bash $ pip install pymdown-extensions ``` -------------------------------- ### PEP440 Versioning Example Source: https://facelessuser.github.io/pymdown-extensions/about/security Demonstrates versioning according to PEP440 standards, which follows a major.minor.patch format. This format is used to indicate the nature of changes in a release. ```text 8.0 8.1 8.1.3 ``` -------------------------------- ### Diagram Fence Example with Mermaid Source: https://facelessuser.github.io/pymdown-extensions/extensions/superfences This example demonstrates how to set up a custom 'diagram' fence to process Mermaid charts. The content within the fence is preserved and sent to an element for Mermaid to convert when the document loads. This allows for the integration of various Mermaid diagrams directly within Markdown. ```markdown ```diagram graph TD A[Hard] -->|Text| B(Round) B --> C{Decision} C -->|One| D[Result 1] C -->|Two| E[Result 2] ``` ``` -------------------------------- ### Serve Documentation Locally with Zensical Source: https://facelessuser.github.io/pymdown-extensions/about/development Builds and serves the project documentation locally using Zensical, making it accessible at 'localhost:8000'. This command enables live previewing of documentation changes. ```bash python3 -m zensical serve -f zensical.yml ``` -------------------------------- ### Install Requests Dependency Source: https://facelessuser.github.io/pymdown-extensions/about/development Installs the 'requests' library, a necessary dependency for the emoji index generation scripts. This is a standard Python package installation command. ```bash pip install requests ``` -------------------------------- ### Critic Markup Syntax Examples Source: https://facelessuser.github.io/pymdown-extensions/extensions/critic Illustrates the various Critic Markup syntaxes for representing edits, including insertion, deletion, substitution, highlighting, and commenting. These examples show how to format text for different types of changes. ```markdown To insert or remove text you can use {++insert me++} and {--remove me--} respectively. You can also denote a substitution with {::~remove this~>with this~~}. You can also highlight specific text with {==highlight me==}. Or even comment, which is generally done by highlighting text and following it with a comment: {==highlight me==}{>>Add a comment<<}. ``` ```markdown Here is some {--*incorrect*--} Markdown. I am adding this{++ here++}. Here is some more {--text that I am removing--}text. And here is even more {++text that I am ++}adding.{~~ ~> ~~}Paragraph was deleted and replaced with some spaces.{~~ ~> ~~}Spaces were removed and a paragraph was added. And here is a comment on {==some text==}{>>This works quite well. I just wanted to comment on it.<<}. Substitutions {~~is~>are~~} great! General block handling. {-- * test remove * test remove * test remove * test remove * test remove --} {++ * test add * test add * test add * test add * test add ++} ``` -------------------------------- ### Generic List with Start Attribute (Markdown) Source: https://facelessuser.github.io/pymdown-extensions/extensions/fancylists Illustrates how to anchor a generic list's first value by adding a 'start' attribute within the special block, ensuring correct numbering even for non-standard list types. ```markdown /// fancylists | type=a start=9 #. item i #. item j /// ``` -------------------------------- ### Build Documentation for Spell Checking Source: https://facelessuser.github.io/pymdown-extensions/about/development Builds the project documentation, including cleaning previous builds, in preparation for running the spell checker. This command uses Zensical to generate the static site. ```bash python3 -m zensical build-f zensical.yml --clean ``` -------------------------------- ### FancyLists Ordered List Examples Source: https://facelessuser.github.io/pymdown-extensions/extensions/fancylists Demonstrates various ordered list formats supported by FancyLists, including trailing dots, parentheses, Roman numerals, alphabetical, and generic markers. ```markdown 1) Item 1 2) Item 2 i. Item 1 ii. Item 2 a. Item a b. Item b #. Item 1 #. Item 2 ``` ```markdown 1. Item 1 2. Item 2 1. Item 1 2. Item 2 1. Item a 2. Item b 1. Item 1 2. Item 2 ``` ```markdown - Item 1 - Item 2 1. Item 1 2. Item 2 ``` ```markdown 1. Item 1 1. Item 2 1) Item 1 2) Item 2 ``` ```markdown a. Item a b. Item a A. Item A B. Item B ``` ```markdown #. Item 1 #. Item 2 a. Item a b. Item b 1. Item 1 2. Item 2 ``` ```markdown i. item i #. item ii #. item iii iv. item iv ``` ```markdown B. Russell was an English philosopher. A. This is a list. ``` ```markdown iii. Item 3 iv. Item 4 v. Item 5 --- v. Item v w. Item w x. Item x ``` ```markdown h. Item h i. Item i j. Item j --- i. Item 1 ii. Item 2 iii. Item 3 ``` -------------------------------- ### Initialize Markdown with Details Blocks Extension (Python) Source: https://facelessuser.github.io/pymdown-extensions/extensions/blocks/plugins/details Demonstrates how to initialize the Python Markdown library with the `pymdownx.blocks.details` extension. This is the basic setup required to enable the details block functionality. ```python import markdown md = markdown.Markdown(extensions=['pymdownx.blocks.details']) ``` -------------------------------- ### Install Spell Checking Requirements and Aspell Source: https://facelessuser.github.io/pymdown-extensions/about/development Installs Python requirements for spell checking and the Aspell spell checker utility. This is a prerequisite for running the spell checker locally on Linux systems. ```bash pip install -r requirements/docs.txt sudo apt-get install aspell aspell-en ``` -------------------------------- ### Initialize Highlight Extension in Python Markdown Source: https://facelessuser.github.io/pymdown-extensions/extensions/highlight Demonstrates how to include the Highlight extension when initializing the Python Markdown parser. This is the basic setup required to enable code highlighting functionality. ```python import markdown md = markdown.Markdown(extensions=['pymdownx.highlight']) ``` -------------------------------- ### Build Final Documentation Output with NPM Source: https://facelessuser.github.io/pymdown-extensions/about/development Builds the final documentation output by packaging, minimizing, and revisioning scripts and stylesheets. It also updates the 'zensical.yml' file with new revisioned file names. ```bash npm run build ``` -------------------------------- ### Example HTML Structure for ProgressBar Source: https://facelessuser.github.io/pymdown-extensions/extensions/progressbar Provides the typical HTML output generated by the ProgressBar extension for a 100% complete progress bar, including CSS classes for styling. ```html
' tag. This is useful for compatibility with plugins like mkdocs-minify-plugin.
```yaml
markdown_extensions:
- pymdownx.superfences:
custom_fences:
- name: math
class: arithmatex
format: !!python/object/apply:pymdownx.arithmatex.arithmatex_fenced_format {kwds: {mode: generic, tag: pre}}
```
```yaml
markdown_extensions:
- pymdownx.superfences:
custom_fences:
- name: math
class: arithmatex
format: !!python/object/apply:pymdownx.arithmatex.arithmatex_fenced_format
kwds:
mode: generic
tag: pre
```
--------------------------------
### Basic ProgressBar Syntax
Source: https://facelessuser.github.io/pymdown-extensions/extensions/progressbar
Demonstrates the fundamental syntax for creating progress bars using the ProgressBar extension. It shows how to specify percentages and optional titles.
```markdown
[=0% "0%"]
[=5% "5%"]
[=25% "25%"]
[=45% "45%"]
[=65% "65%"]
[=85% "85%"]
[=100% "100%"]
```
--------------------------------
### Stripping HTML Comments Example
Source: https://facelessuser.github.io/pymdown-extensions/extensions/striphtml
Shows an example of how HTML comments are handled by the StripHTML extension. Comments are stripped during the post-processing phase.
```html
Here is a test.
```
```html
Here is a test.
```
--------------------------------
### Show Custom Start Line Number (Python)
Source: https://facelessuser.github.io/pymdown-extensions/extensions/superfences
Illustrates how to set a custom starting line number for a code block, other than the default 1. The `linenums` attribute is used with the desired starting number, e.g., `linenums="2"`. This is useful for aligning code with external documentation or specific requirements.
```python
```python {linenums="2"}
import foo.bar
```
```
--------------------------------
### Include Named Sections from a Snippet File
Source: https://facelessuser.github.io/pymdown-extensions/extensions/snippets
Explains how to define and include named sections within a file, providing a more robust way to include content than line numbers. Sections are defined using start and end markers (e.g., `[start:name]` and `[end:name]`) and are included by referencing the section name. The lines containing the start and end markers are omitted in the final output.
```markdown
--8<-- "include.md:name"
--8<--
include.md:name
--8<--
```
```python
# --8<-- [start:func]
def my_function(var):
pass
# --8<-- [end:func]
```
```markdown
--8<-- "example.py:func"
```
--------------------------------
### Shorthand Link Syntax for Repositories and Social Media
Source: https://facelessuser.github.io/pymdown-extensions/extensions/magiclink
This shows examples of shorthand syntax for referencing GitHub, GitLab, and Bitbucket items like issues (#1), pull requests (!13), commits (7d1b190), and repositories (facelessuser/pymdown-extensions). It also includes social media mentions (@facelessuser).
```markdown
#1
!13
?1173
7d1b190
e2ed7e0...90b6fb8
facelessuser/pymdown-extensions
@facelessuser
```
--------------------------------
### Mermaid Configuration Initialization - JavaScript
Source: https://facelessuser.github.io/pymdown-extensions/extras/mermaid
Sets up the global configuration for Mermaid diagrams. This configuration includes options like disabling automatic loading, setting a default theme, and adjusting maximum width behavior for various diagram types to ensure consistent rendering and overflow handling.
```javascript
window.mermaidConfig = {
startOnLoad: false,
theme: "default",
flowchart: {
useMaxWidth: false
},
er: {
useMaxWidth: false
},
sequence: {
useMaxWidth: false,
noteFontWeight: "14px",
actorFontSize: "14px",
messageFontSize: "16px"
},
journey: {
useMaxWidth: false
},
gitGraph: {
useMaxWidth: false
}
}
```
--------------------------------
### Show Line Numbers Per Code Block (Python)
Source: https://facelessuser.github.io/pymdown-extensions/extensions/superfences
Demonstrates how to enable line numbers for a specific code block starting from line 1. This is achieved by adding the `linenums="1"` attribute directly after the opening tokens. If global line numbering is enabled, this setting will override the start line for that block.
```python
```python {linenums="1"}
import foo.bar
```
```
--------------------------------
### Run Pyspelling Spell Checker
Source: https://facelessuser.github.io/pymdown-extensions/about/development
Executes the Pyspelling spell checker on the built documentation. This command identifies and reports any misspelled words found in the documentation files.
```bash
pyspelling
```
--------------------------------
### Configure GitHub-Flavored Markdown Extensions in Python
Source: https://facelessuser.github.io/pymdown-extensions/faq
Provides a Python configuration for Pymdown Extensions to emulate GitHub Flavored Markdown. It includes settings for MagicLink, Tilde, Emoji, Tasklist, SuperFences, SaneHeaders, and Quotes, with specific options for MagicLink's shorthand syntax and Emoji's image path.
```python
from pymdownx import emoji
extensions = [
'markdown.extensions.tables',
'pymdownx.magiclink',
'pymdownx.betterem',
'pymdownx.tilde',
'pymdownx.emoji',
'pymdownx.tasklist',
'pymdownx.superfences',
'pymdownx.saneheaders',
'pymdownx.quotes'
]
extension_configs = {
"pymdownx.magiclink": {
"repo_url_shortener": True,
"repo_url_shorthand": True,
"provider": "github",
"user": "facelessuser",
"repo": "pymdown-extensions"
},
"pymdownx.tilde": {
"subscript": False
},
"pymdownx.emoji": {
"emoji_index": emoji.gemoji,
"emoji_generator": emoji.to_png,
"alt": "short",
"options": {
"attributes": {
"align": "absmiddle",
"height": "20px",
"width": "20px"
},
"image_path": "https://github.githubassets.com/images/icons/emoji/unicode/",
"non_standard_image_path": "https://github.githubassets.com/images/icons/emoji/"
}
},
"pymdownx.quotes": {
"callouts": True
}
}
```
--------------------------------
### CSS for ProgressBar Styling
Source: https://facelessuser.github.io/pymdown-extensions/extensions/progressbar
A comprehensive CSS setup for styling the generated progress bars, including styles for labels, bars, containers, and different percentage-based level classes.
```css
.progress-label {
position: absolute;
text-align: center;
font-weight: 700;
width: 100%;
margin: 0;
line-height: 1.2rem;
white-space: nowrap;
overflow: hidden;
}
.progress-bar {
height: 1.2rem;
float: left;
background-color: #2979ff;
}
.progress {
display: block;
width: 100%;
margin: 0.5rem 0;
height: 1.2rem;
background-color: #eeeeee;
position: relative;
}
.progress.thin {
margin-top: 0.9rem;
height: 0.4rem;
}
.progress.thin .progress-label {
margin-top: -0.4rem;
}
.progress.thin .progress-bar {
height: 0.4rem;
}
.progress-100plus .progress-bar {
background-color: #00e676;
}
.progress-80plus .progress-bar {
background-color: #fbc02d;
}
.progress-60plus .progress-bar {
background-color: #ff9100;
}
.progress-40plus .progress-bar {
background-color: #ff5252;
}
.progress-20plus .progress-bar {
background-color: #ff1744;
}
.progress-0plus .progress-bar {
background-color: #f50057;
}
```
--------------------------------
### Initialize Tab Blocks Extension
Source: https://facelessuser.github.io/pymdown-extensions/extensions/blocks/plugins/tab
Demonstrates how to initialize the `pymdownx.blocks.tab` extension when using the Markdown library. This is a prerequisite for using tab blocks.
```python
import markdown
md = markdown.Markdown(extensions=['pymdownx.blocks.tab'])
```
--------------------------------
### Dedent Subsections (Markdown)
Source: https://facelessuser.github.io/pymdown-extensions/extensions/snippets
Example of using the `dedent_subsections` option to remove common leading whitespace from extracted subsection content. This is useful when dealing with indented code blocks or text.
```markdown
```python
# This is a comment
def my_function():
pass
```
--8<-- "path/to/file.md" sections=my_section dedent_subsections
```
--------------------------------
### Update Tests
Source: https://facelessuser.github.io/pymdown-extensions/about/development
Updates the project's tests, specifically focusing on the emoji-related tests. This command ensures that the test suite reflects the latest changes after index generation.
```bash
python run_tests.py --update
```
--------------------------------
### Basic Definition Block Syntax (Markdown)
Source: https://facelessuser.github.io/pymdown-extensions/extensions/blocks/plugins/definition
Illustrates the fundamental syntax for creating a definition block using the `/// define` marker. It shows how to specify a term and its corresponding definition using a list.
```markdown
/// define
Apple
- Pomaceous fruit of plants of the genus Malus in
the family Rosaceae.
///
```
--------------------------------
### Python Markdown Initialization with FancyLists
Source: https://facelessuser.github.io/pymdown-extensions/extensions/fancylists
Initializes the Python Markdown parser with the 'pymdownx.fancylists' extension and 'pymdownx.saneheaders' for enhanced list and header handling.
```python
import markdown
# SaneHeaders required for generic ordered styles `#.` and `#)`
md = markdown.Markdown(extensions=['pymdownx.fancylists', 'pymdownx.saneheaders'])
```
--------------------------------
### Customizing Pull Request Label
Source: https://facelessuser.github.io/pymdown-extensions/extensions/magiclink
An example demonstrating how to override a specific label for repository links. In this case, it changes the 'pull' request label to 'Merge Request' to align with GitLab terminology.
```python
{
'pull': 'Merge Request'
}
```
--------------------------------
### Get Gemoji Version in Pymdown-Extensions
Source: https://facelessuser.github.io/pymdown-extensions/extensions/emoji
This Python snippet demonstrates how to retrieve the version of the Gemoji database used by Pymdown-Extensions. This is helpful for ensuring compatibility and understanding which specific release of Gemoji is being utilized.
```python
>>> import pymdownx.gemoji_db as gmdb
>>> gmdb.version
'v3.0.1'
```
--------------------------------
### Get Emojione Version in Pymdown-Extensions
Source: https://facelessuser.github.io/pymdown-extensions/extensions/emoji
This Python snippet demonstrates how to retrieve the version of the Emojione database used by Pymdown-Extensions. This is useful for tracking compatibility and understanding which specific release of Emojione is being utilized.
```python
>>> import pymdownx.emoji1_db as e1db
>>> e1db.version
'v2.2.7'
```
--------------------------------
### Python Markdown Initialization with ProgressBar
Source: https://facelessuser.github.io/pymdown-extensions/extensions/progressbar
Shows the Python code required to initialize the Python Markdown parser with the ProgressBar extension enabled.
```python
import markdown
md = markdown.Markdown(extensions=['pymdownx.progressbar'])
```
--------------------------------
### Initialize Caption Extension - Python
Source: https://facelessuser.github.io/pymdown-extensions/extensions/blocks/plugins/caption
Demonstrates how to initialize the Python Markdown parser with the Caption extension. This is the first step to enable caption functionality.
```python
import markdown
md = markdown.Markdown(extensions=['pymdownx.blocks.caption'])
```
--------------------------------
### Lint JavaScript and CSS Files with NPM
Source: https://facelessuser.github.io/pymdown-extensions/about/development
Runs linting checks on the project's JavaScript and CSS files. This command is used to ensure code quality and consistency in theme assets.
```bash
npm run lint
```
--------------------------------
### Handling Raw Content in HTML Blocks (Pre Tag Example)
Source: https://facelessuser.github.io/pymdown-extensions/extensions/blocks/plugins/html
Shows how to force specific HTML tags like 'pre' to handle content as raw text, preventing Markdown parsing within the block. This is crucial for code blocks or preformatted text that should not be altered.
```markdown
/// html | pre
some *markdown* content
///
/// html | pre
markdown: block
some *markdown* content
///
```
--------------------------------
### HTML Output for Highlighted Code (Pygments Disabled)
Source: https://facelessuser.github.io/pymdown-extensions/extensions/highlight
Shows the default HTML structure generated for code blocks when Pygments is either not installed or explicitly disabled. This structure is designed for JavaScript-based highlighting.
```html
```
--------------------------------
### Roman Numeral List Workarounds (Markdown)
Source: https://facelessuser.github.io/pymdown-extensions/extensions/fancylists
Demonstrates how to bypass conflicts when starting or restarting Roman numeral lists with specific characters by using non-standard numeral representations. Browsers will render these in a strict format.
```markdown
IIIII. Roman numeral V
---
VIIIII. Roman numeral X
---
XXXXX. Roman numeral L
---
LXXXXX. Roman numeral C
---
CCCCC. Roman numeral D
---
DCCCCC. Roman numeral M
```