### Setup Script for Extension
Source: https://github.com/python-markdown/markdown/wiki/Tutorial-1---Writing-Extensions-for-Python-Markdown
This `setup.py` script uses setuptools to define the extension's metadata and dependencies. It makes the extension available for development installation.
```python
from setuptools import setup
setup(
name='myextension',
version='1.0',
py_modules=['myextension'],
install_requires = ['markdown>=3.0'],
)
```
--------------------------------
### Download and Install Distribute and Pip
Source: https://github.com/python-markdown/markdown/wiki/Test-Environment-Setup
Installs the 'distribute' package and 'pip' using their respective setup scripts. These are prerequisites for installing other Python packages.
```bash
$ wget http://python-distribute.org/distribute_setup.py
$ sudo python distribute_setup.py
$ wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py
$ sudo python get-pip.py
```
--------------------------------
### Install Documentation Dependencies
Source: https://github.com/python-markdown/markdown/blob/master/docs/contributing.md
Install optional dependencies required for building the project's documentation.
```sh
pip install -e .[docs]
```
--------------------------------
### Reference Links Example
Source: https://github.com/python-markdown/markdown/blob/master/tests/extensions/toc.html
Provides a complete example of using reference-style links and their definitions.
```markdown
I get 10 times more traffic from [Google] [1] than from
[Yahoo] [2] or [MSN] [3].
[1]: http://google.com/ "Google"
```
--------------------------------
### Python List Continuation Example
Source: https://github.com/python-markdown/markdown/blob/master/docs/contributing.md
Demonstrates proper indentation and alignment for multi-line list constructs in Python, adhering to PEP8 style guides.
```python
my_list = [
1, 2, 3,
4, 5, 6,
]
result = some_function_that_takes_arguments(
'a', 'b', 'c',
'd', 'e', 'f',
)
```
--------------------------------
### Reference Links Example
Source: https://github.com/python-markdown/markdown/blob/master/tests/extensions/toc.txt
An example demonstrating the use of numbered labels for reference-style links.
```markdown
I get 10 times more traffic from [Google] [1] than from
[Yahoo] [2] or [MSN] [3].
[1]: http://google.com/ "Google"
[2]: http://search.yahoo.com/ "Yahoo Search"
[3]: http://search.msn.com/ "MSN Search"
```
--------------------------------
### Install Project in Development Mode
Source: https://github.com/python-markdown/markdown/blob/master/docs/contributing.md
Install the Python-Markdown library in editable mode after activating the virtual environment. This ensures that any saved changes are immediately reflected.
```sh
pip install -e .
```
--------------------------------
### Install Extension in Development Mode
Source: https://github.com/python-markdown/markdown/wiki/Tutorial-1---Writing-Extensions-for-Python-Markdown
Run this command to install the extension in development mode, allowing changes to take effect immediately without reinstallation.
```sh
python setup.py develop
```
--------------------------------
### Importing Stuff Example
Source: https://github.com/python-markdown/markdown/blob/master/tests/misc/some-test.html
A basic Python code snippet demonstrating an import statement. This is a standalone example.
```python
import stuff
```
--------------------------------
### Install Python-Markdown
Source: https://github.com/python-markdown/markdown/blob/master/README.md
Install the Python-Markdown library using pip. This is the first step before using the library in your Python projects.
```bash
pip install markdown
```
--------------------------------
### Install Testing Dependencies
Source: https://github.com/python-markdown/markdown/blob/master/docs/contributing.md
Install optional dependencies required for running the project's tests.
```sh
pip install -e .[testing]
```
--------------------------------
### HTML Template Example
Source: https://github.com/python-markdown/markdown/blob/master/tests/extensions/github_flavored.html
An example of an HTML template using Jinja2 syntax to display a list of users.
```html
{% block title %}{% endblock %}
```
--------------------------------
### Create and Configure Development Virtual Environment
Source: https://github.com/python-markdown/markdown/wiki/Test-Environment-Setup
Creates a virtual environment named 'md', installs 'nose' and 'PyTidyLib' from GitHub into it. PyTidyLib is installed from a specific fork for Python 3 compatibility.
```bash
$ mkvirtualenv md
(md)$ pip install nose
(md)$ pip install git+https://github.com/waylan/pytidylib.git#egg=PyTidyLib
```
--------------------------------
### Serve Documentation Locally
Source: https://github.com/python-markdown/markdown/blob/master/docs/contributing.md
Build the documentation and start a local development server to preview it in your browser. Point your browser to http://127.0.0.1:8000/.
```sh
mkdocs serve
```
--------------------------------
### DelInlineProcessor Example
Source: https://github.com/python-markdown/markdown/blob/master/docs/extensions/api.md
This example shows how to create a custom inline processor for strike-through text by subclassing InlineProcessor.
```APIDOC
## DelInlineProcessor
### Description
This custom inline processor handles strike-through text by creating a `` element.
### Method
`handleMatch(m, data)`
### Parameters
* `m` (Match object): The regular expression match object.
* `data` (string): The source text being processed.
### Returns
* `(Element, int, int)`: A tuple containing the created Element, the start index of the match, and the end index of the match.
### Code Example
```python
from markdown.inlinepatterns import InlineProcessor
from markdown.extensions import Extension
import xml.etree.ElementTree as etree
class DelInlineProcessor(InlineProcessor):
def handleMatch(self, m, data):
el = etree.Element('del')
el.text = m.group(1)
return el, m.start(0), m.end(0)
class DelExtension(Extension):
def extendMarkdown(self, md):
DEL_PATTERN = r'--(.*?)--'
md.inlinePatterns.register(DelInlineProcessor(DEL_PATTERN, md), 'del', 175)
```
### Usage Example
Input: `This is --strike--.`
Output: `This is strike.
`
### Notes
* The `handleMatch` method is called when the pattern is found.
* The match object `m` contains captured groups, where `m.group(1)` is the text within the `--`.
* The returned indices indicate the portion of the text to be replaced.
```
--------------------------------
### Basic Definition List Example
Source: https://github.com/python-markdown/markdown/blob/master/tests/extensions/extra/simple_def-lists.html
A straightforward example demonstrating a term and its definition.
```markdown
term 4
def4 line 2 of def 4
```
--------------------------------
### Markdown Input Example
Source: https://github.com/python-markdown/markdown/wiki/Tutorial-2---Altering-Markdown-Rendering
This is an example of Markdown input with both local and remote image links.
```markdown


```
--------------------------------
### Attribute List Syntax Example
Source: https://github.com/python-markdown/markdown/blob/master/docs/extensions/attr_list.md
Demonstrates the basic syntax for defining an attribute list, including IDs, classes, and key-value pairs.
```text
{: #someid .someclass somekey='some value' }
```
--------------------------------
### JSON Configuration Example
Source: https://github.com/python-markdown/markdown/blob/master/docs/cli.md
Example of a JSON configuration file for Python-Markdown extensions. This format is used with the `-c` option.
```json
{
"myext":
{
"option1": "value1",
"option2": "value2"
}
}
```
--------------------------------
### Install Virtualenvwrapper
Source: https://github.com/python-markdown/markdown/wiki/Test-Environment-Setup
Installs the 'virtualenvwrapper' package, which provides helpful utilities for managing virtual environments.
```bash
$ sudo pip install virtualenvwrapper
```
--------------------------------
### YAML Configuration Example
Source: https://github.com/python-markdown/markdown/blob/master/docs/cli.md
Example of a YAML configuration file for Python-Markdown extensions. This format is used with the `-c` option.
```yaml
myext:
option1: 'value1'
option2: True
```
--------------------------------
### Implicit Reference Links Example
Source: https://github.com/python-markdown/markdown/blob/master/tests/extensions/toc.txt
Demonstrates reference-style links using the implicit link name shortcut with custom labels.
```markdown
I get 10 times more traffic from [Google][] than from
[Yahoo][] or [MSN][].
[google]: http://google.com/ "Google"
[yahoo]: http://search.yahoo.com/ "Yahoo Search"
[msn]: http://search.msn.com/ "MSN Search"
```
--------------------------------
### DelExtension Example
Source: https://github.com/python-markdown/markdown/blob/master/docs/extensions/api.md
This example demonstrates how to create a custom Markdown extension to handle strike-through text using a SimpleTagInlineProcessor.
```APIDOC
## DelExtension
### Description
This extension allows for strike-through text to be rendered using `--text--`.
### Method
`extendMarkdown(md)`
### Parameters
* `md` (Markdown): The Markdown instance to which the extension is being added.
### Code Example
```python
from markdown.inlinepatterns import SimpleTagInlineProcessor
from markdown.extensions import Extension
class DelExtension(Extension):
def extendMarkdown(self, md):
md.inlinePatterns.register(SimpleTagInlineProcessor(r'()--(.*?)--', 'del'), 'del', 175)
```
### Usage Example
Input: `This is --strike--.`
Output: `This is strike.
`
```
--------------------------------
### Install Tidy C Library on Ubuntu
Source: https://github.com/python-markdown/markdown/wiki/Test-Environment-Setup
Installs the Tidy C library on Ubuntu systems, which is required by PyTidyLib for normalizing HTML whitespace during testing.
```bash
$ sudo apt-get install libtidy-0.99-0
```
--------------------------------
### Inline Link Example
Source: https://github.com/python-markdown/markdown/blob/master/tests/basic/markdown-syntax.txt
Demonstrates the syntax for creating an inline link with a URL and an optional title.
```markdown
This is [an example](http://example.com/ "Title") inline link.
[This link](http://example.net/) has no title attribute.
```
--------------------------------
### Verify Python Version Installation
Source: https://github.com/python-markdown/markdown/wiki/Test-Environment-Setup
Verifies that the installed Python versions are accessible and report their versions correctly from the command line.
```bash
$ python2.6 --version
Python 2.6.8
$ python3.2 --version
Python 3.2.3
```
--------------------------------
### Install Tox
Source: https://github.com/python-markdown/markdown/blob/master/docs/contributing.md
Install the tox testing tool, which is used to run tests across multiple Python versions and environments.
```sh
pip install tox
```
--------------------------------
### Use Keyword Arguments for Extensions
Source: https://github.com/python-markdown/markdown/blob/master/docs/change_log/release-2.5.md
This example demonstrates the recommended way to specify extensions using keyword arguments, replacing positional arguments for better clarity and future compatibility.
```python
html = markdown.markdown(text, extensions=['extra'])
```
--------------------------------
### Ordered List Syntax (Sequential Numbers)
Source: https://github.com/python-markdown/markdown/blob/master/tests/basic/markdown-syntax.txt
Example of a standard ordered list using sequential numbering.
```markdown
1. Bird
2. McHale
3. Parish
```
--------------------------------
### Verify Python Version Installation
Source: https://github.com/python-markdown/markdown/wiki/Test-Environment-Setup
Verifies that specific Python versions have been installed correctly by checking their version numbers from the command line.
```bash
python3.1 --version
python3.2 --version
```
--------------------------------
### Commit Message Example
Source: https://github.com/python-markdown/markdown/blob/master/tests/extensions/github_flavored.html
A sample commit message demonstrating a minor change.
```text
minor: just wanted to push something.
```
--------------------------------
### Pre-formatted Code Block Example
Source: https://github.com/python-markdown/markdown/blob/master/tests/basic/markdown-syntax.txt
Demonstrates the syntax for creating a pre-formatted code block by indenting lines with at least 4 spaces or 1 tab.
```markdown
This is a normal paragraph:
This is a code block.
```
--------------------------------
### Example Shell Command with Markdown Script
Source: https://github.com/python-markdown/markdown/blob/master/tests/basic/markdown-syntax.txt
Illustrates a shell command that pipes input to a Markdown script. This is an example of how Markdown might be used in a command-line context.
```shell
return shell_exec("echo $input | $markdown_script");
```
--------------------------------
### List Available Pygments Styles
Source: https://github.com/python-markdown/markdown/blob/master/docs/extensions/code_hilite.md
Lists all available style themes installed with Pygments. This command helps in choosing a theme for code highlighting.
```bash
pygmentize -L style
```
--------------------------------
### Install Python-Markdown from Git Repository
Source: https://github.com/python-markdown/markdown/blob/master/docs/install.md
Install the latest development version of Python-Markdown directly from its GitHub repository. This is useful for accessing the newest features or bug fixes before a release.
```bash
pip install git+https://github.com/Python-Markdown/markdown.git
```
--------------------------------
### Install Python 2.7 Build Dependencies
Source: https://github.com/python-markdown/markdown/wiki/Test-Environment-Setup
Installs the necessary development packages for Python 2.7. This command should be run once for the system's default Python version.
```bash
$ python --version
Python 2.7.2+
$ sudo apt-get build-dep python2.7
```
--------------------------------
### Basic Table Extension Usage
Source: https://github.com/python-markdown/markdown/blob/master/docs/extensions/tables.md
A simple example of how to enable the 'tables' extension when converting Markdown to HTML.
```python
import markdown
some_text = ""
html = markdown.markdown(some_text, extensions=['tables'])
```
--------------------------------
### Install Virtualenv and Tox using Pip
Source: https://github.com/python-markdown/markdown/wiki/Test-Environment-Setup
Installs the 'virtualenv' and 'tox' Python packages using pip. These tools are essential for managing test environments and running tests.
```bash
$ sudo pip install virtualenv
$ sudo pip install tox
```
--------------------------------
### Install Multiple Python Versions (Deadsnakes PPA)
Source: https://github.com/python-markdown/markdown/wiki/Test-Environment-Setup
Installs multiple Python versions from the Deadsnakes PPA on Ubuntu-based systems. Ensure to adjust the package list to include only the desired supported Python versions.
```bash
sudo add-apt-repository ppa:deadsnakes
sudo apt-get update
sudo apt-get install python3.1 python3.2 python3.3
```
--------------------------------
### Ampersand Escaping Example
Source: https://github.com/python-markdown/markdown/blob/master/tests/extensions/extra/markdown-syntax.html
Illustrates Markdown's automatic escaping of literal ampersands into '&' to prevent them from being interpreted as the start of an HTML entity.
```markdown
AT&T
```
```markdown
AT&T
```
--------------------------------
### Register Extension via Entry Point
Source: https://github.com/python-markdown/markdown/blob/master/docs/extensions/api.md
Define an entry point in your `setup.py` script under the `markdown.extensions` group to allow users to refer to your extension by a simple name.
```python
from setuptools import setup
setup(
# ...
entry_points={
'markdown.extensions': ['myextension = path.to.module:MyExtension']
}
)
```
--------------------------------
### Extension Usage with Configuration Options
Source: https://github.com/python-markdown/markdown/wiki/Tutorial:-Writing-Extensions-for-Python-Markdown
Demonstrates how to pass configuration options to an extension using the `extension_configs` keyword argument when using the shorter extension name.
```python
>>> markdown.markdown(
... txt,
... extensions=['myextension'],
... extension_configs = {
... 'myextension': {'ins_del': True}
... }
... )
"Some underline
Some strike
Some bold
Some italics"
```
--------------------------------
### Attribute List Overriding Example
Source: https://github.com/python-markdown/markdown/blob/master/docs/extensions/attr_list.md
Illustrates how attribute lists handle overriding of IDs and classes, showing the final resulting attributes.
```text
{: #id1 .class1 id=id2 class="class2 class3" .class4 }
```
--------------------------------
### Displaying Help Information
Source: https://github.com/python-markdown/markdown/blob/master/docs/cli.md
How to view all available options and arguments for the Python-Markdown command line script.
```bash
python -m markdown --help
```
--------------------------------
### Load Extension with Configuration File
Source: https://github.com/python-markdown/markdown/blob/master/docs/cli.md
Use the `-x` option to load an extension and the `-c` option to specify a configuration file. The configuration file can be in YAML or JSON format.
```bash
python -m markdown -x myext -c config.yml input.txt
```
--------------------------------
### Display Help for markdown_py
Source: https://github.com/python-markdown/markdown/blob/master/docs/cli.md
Run `markdown_py --help` to see all available command-line options and their usage.
```bash
markdown_py --help
```
--------------------------------
### Example List Item Indented with Spaces
Source: https://github.com/python-markdown/markdown/blob/master/tests/basic/tabs.html
An example list item within a block, indented with spaces.
```markdown
+ this is an example list item
indented with spaces
```
--------------------------------
### Example List Item Indented with Tabs
Source: https://github.com/python-markdown/markdown/blob/master/tests/basic/tabs.html
An example list item within a block, indented with tabs.
```markdown
+ this is an example list item
indented with tabs
```
--------------------------------
### Extension Configuration Dictionary
Source: https://github.com/python-markdown/markdown/blob/master/docs/change_log/release-2.5.md
The `extension_configs` keyword now accepts a dictionary for configuration settings, simplifying setup for extension authors and new users. Existing list of tuples format is still supported.
```python
md = markdown.Markdown(
extensions=["my_extension"],
extension_configs={
"my_extension": {
"key1": "value1",
"key2": "value2",
}
},
)
```
--------------------------------
### Loading Extensions with Class Instances and Strings
Source: https://github.com/python-markdown/markdown/blob/master/docs/reference.md
Illustrates various ways to specify extensions for the markdown.markdown function, including class instances, extension names as strings, and importable paths.
```python
extensions=[MyExtClass(), 'myext', 'path.to.my.ext:MyExtClass']
```
```python
from markdown.extensions import Extension
class MyExtClass(Extension):
# define your extension here...
markdown.markdown(text, extensions=[MyExtClass(option='value')])
```
```python
markdown.markdown(text, extensions=['myext'])
```
```python
markdown.markdown(text, extensions=['path.to.module:MyExtClass'])
```
```python
extensions=['path.to.module']
```
--------------------------------
### Recommended full path for built-in extensions
Source: https://github.com/python-markdown/markdown/blob/master/docs/change_log/release-2.6.md
Shows the recommended way to specify built-in extensions using their full path.
```python
markdown.markdown(text, extensions=['markdown.extensions.extra'])
```
--------------------------------
### View MkDocs Help
Source: https://github.com/python-markdown/markdown/blob/master/docs/contributing.md
Display the help information for MkDocs to see available options and commands.
```sh
mkdocs --help
```
--------------------------------
### Load Extension by Entry Point Name
Source: https://github.com/python-markdown/markdown/blob/master/docs/cli.md
Use the `-x` option to load an extension by its assigned entry point name. The extension module must be on your PYTHONPATH.
```bash
python -m markdown -x myext input.txt
```
--------------------------------
### Horizontal Rule Examples
Source: https://github.com/python-markdown/markdown/blob/master/tests/basic/markdown-syntax.txt
Provides examples of Markdown syntax for creating horizontal rules using hyphens, asterisks, or underscores.
```markdown
* * *
```
```markdown
***
```
```markdown
*****
```
```markdown
- - -
```
```markdown
---------------------------------------
```
```markdown
_ _ _
```
--------------------------------
### Piping Input and Output
Source: https://github.com/python-markdown/markdown/blob/master/docs/cli.md
Demonstrates piping Markdown text from STDIN to the command line script and redirecting the HTML output to a file.
```bash
echo "Some **Markdown** text." | python -m markdown > output.html
```
--------------------------------
### AppleScript Code Block Example
Source: https://github.com/python-markdown/markdown/blob/master/tests/basic/markdown-syntax.html
Shows an example of an indented code block containing AppleScript. Indentation is removed from each line when converted to HTML.
```applescript
tell application "Foo"
beep
end tell
```
--------------------------------
### Horizontal Rule Examples
Source: https://github.com/python-markdown/markdown/blob/master/tests/basic/markdown-syntax.html
Provides examples of creating horizontal rules using three or more hyphens, asterisks, or underscores on a line. Spaces can be used between characters.
```markdown
* * *
```
```markdown
***
```
```markdown
*****
```
```markdown
- - -
```
```markdown
---------------------------------------
```
```markdown
_ _ _
```
--------------------------------
### Sane Lists HTML Output with Starting Number
Source: https://github.com/python-markdown/markdown/blob/master/docs/extensions/sane_lists.md
Displays the HTML output for an ordered list that starts with a number other than 1, as handled by Sane Lists.
```html
- Apples
- Oranges
- Pears
```
--------------------------------
### Activating Extensions from the Command Line
Source: https://github.com/python-markdown/markdown/blob/master/docs/extensions/index.md
Specify extensions to be used when processing files from the command line using the -x option. Multiple extensions can be specified.
```bash
python -m markdown -x myext -x path.to.module:MyExtClass input.txt > output.html
```
--------------------------------
### Sane Lists Ordered List Starting Number
Source: https://github.com/python-markdown/markdown/blob/master/docs/extensions/sane_lists.md
Illustrates how Sane Lists respects the starting number of an ordered list, unlike default Markdown behavior.
```markdown
4. Apples
5. Oranges
6. Pears
```
--------------------------------
### Download, Extract, and Configure Python Source
Source: https://github.com/python-markdown/markdown/wiki/Test-Environment-Setup
Steps to download, extract, and configure a specific Python version from source. Replace X.X.X with the desired version number. This process needs to be repeated for each Python version.
```bash
$ wget http://python.org/ftp/python/X.X.X/Python-X.X.X.tgz
$ tar xvfz Python-X.X.X.tgz
$ cd Python-X.X.X
$ ./configure --prefix=/opt/pythonX.X
$ make
$ sudo make install
```
--------------------------------
### Simple Definition List
Source: https://github.com/python-markdown/markdown/blob/master/tests/extensions/extra/simple_def-lists.txt
A straightforward example of a definition list with a term and its definition.
```markdown
term 4
: def4
line 2 of def 4
```
--------------------------------
### Activate Virtual Environment (Posix)
Source: https://github.com/python-markdown/markdown/blob/master/docs/contributing.md
Activate the created virtual environment on Linux, BSD, or macOS systems.
```sh
source venv/bin/activate
```
--------------------------------
### Updated Extension Configuration
Source: https://github.com/python-markdown/markdown/blob/master/docs/change_log/release-2.6.md
The recommended way to configure extensions is by passing options directly as keyword arguments to the extension class.
```python
ext = SomeExtension(somekey='somevalue')
```
--------------------------------
### Basic Command Line Structure
Source: https://github.com/python-markdown/markdown/blob/master/docs/cli.md
The general format for running Python-Markdown from the command line using the -m flag. Assumes python executable is on the system path.
```bash
python -m markdown [options] [args]
```
--------------------------------
### Basic Admonition Example
Source: https://github.com/python-markdown/markdown/blob/master/tests/extensions/admonition.txt
A basic admonition block with a 'note' type. It can contain paragraphs, lists, and blockquotes.
```markdown
!!! note
A normal paragraph here
1. first
2. second
> Some important quote
> another paragraph in the quote
int main() {
// insert some code
}
```
--------------------------------
### Registry Item Registration and Access
Source: https://github.com/python-markdown/markdown/blob/master/docs/extensions/api.md
Demonstrates how to register an item with a name and priority in a `Registry` instance and how to access it by index or name. The registry sorts items by priority.
```python
from markdown.util import Registry
class SomeItem:
pass
registry = Registry()
registry.register(SomeItem(), 'itemname', 20)
# Get the item by index
item_by_index = registry[0]
# Get the item by name
item_by_name = registry['itemname']
```
--------------------------------
### HTML with Jinja Templating Example
Source: https://github.com/python-markdown/markdown/blob/master/tests/extensions/github_flavored.txt
This snippet shows a basic HTML structure using Jinja templating syntax for dynamic content. It's useful for web development where server-side rendering is needed.
```html+jinja
{% block title %}{% endblock %}
```
--------------------------------
### Define ID Attribute in Image
Source: https://github.com/python-markdown/markdown/blob/master/docs/extensions/legacy_attrs.md
Example of defining an ID attribute for an image using the legacy syntax.
```markdown

```
--------------------------------
### Define Class Attribute in Paragraph
Source: https://github.com/python-markdown/markdown/blob/master/docs/extensions/legacy_attrs.md
Example of defining a class attribute for a paragraph using the legacy syntax.
```markdown
A paragraph with the attribute defined {@class=foo}anywhere within.
```
--------------------------------
### Basic WikiLink Syntax
Source: https://github.com/python-markdown/markdown/blob/master/docs/extensions/wikilinks.md
Demonstrates the basic syntax for a WikiLink and its resulting HTML output.
```markdown
[[Bracketed]]
```
--------------------------------
### Load Multiple Extensions
Source: https://github.com/python-markdown/markdown/blob/master/docs/cli.md
Specify multiple `-x` options to load several extensions simultaneously. Ensure each extension module is on your PYTHONPATH.
```bash
python -m markdown -x myext -x path.to.module:MyExtClass input.txt
```
--------------------------------
### Get Compiled Regular Expression
Source: https://github.com/python-markdown/markdown/blob/master/tests/extensions/codehilite.txt
Retrieves the compiled regular expression object used internally by the extension.
```python
def getCompiledRegExp (self) :
return self.compiled_re
```
--------------------------------
### Add support for foo+bar lexer names
Source: https://github.com/python-markdown/markdown/blob/master/tests/extensions/github_flavored.txt
This example demonstrates testing support for custom lexer names, specifically 'foo+bar'. It's useful for ensuring custom lexer integrations work correctly.
```diff
--- /dev/null
+++ b/test/data/stripped_text/mike-30-lili
@@ -0,0 +1,27 @@
+Summary:
+ drift_mod.py | 1 +
+ 1 files changed, 1 insertions(+), 0 deletions(-)
+
+commit da4bfb04debdd994683740878d09988b2641513d
+Author: Mike Dirolf
+Date: Tue Jan 17 13:42:28 2012 -0500
+
+```
+minor: just wanted to push something.
+```
+
+diff --git a/drift_mod.py b/drift_mod.py
+index 34dfba6..8a88a69 100644
+
+```
+--- a/drift_mod.py
++++ b/drift_mod.py
@@ -281,6 +281,7 @@ CONTEXT_DIFF_LINE_PATTERN = re.compile(r'^('
+ '|" + ".*'
+ '|- .*'
+ ')$')
+
+ def wrap_context_diffs(message_text):
+ return _wrap_diff(CONTEXT_DIFF_HEADER_PATTERN,
+ CONTEXT_DIFF_LINE_PATTERN,
+```
```
--------------------------------
### Attribute Lists with Newlines
Source: https://github.com/python-markdown/markdown/blob/master/tests/extensions/attr_list.html
Attribute lists do not support newlines within their definition. This example demonstrates invalid syntax.
```markdown
Attr_lists do not contain _newlines_{ foo=bar key=value }
```
--------------------------------
### Horizontal Rule Syntax
Source: https://github.com/python-markdown/markdown/blob/master/tests/extensions/extra/markdown-syntax.txt
Provides examples of different ways to create horizontal rules using hyphens, asterisks, or underscores.
```markdown
* * *
***
*****
- - -
---------------------------------------
```
```markdown
_ _ _
```
--------------------------------
### Create Extension Directory
Source: https://github.com/python-markdown/markdown/wiki/Tutorial-1---Writing-Extensions-for-Python-Markdown
Use these shell commands to create a new directory for your extension and navigate into it.
```sh
mkdir myextension
cd myextension
```
--------------------------------
### Less Than Operator Example
Source: https://github.com/python-markdown/markdown/blob/master/tests/extensions/extra/markdown-syntax.html
Demonstrates Markdown's automatic escaping of the less than symbol '<' into '<' when it is not part of an HTML tag.
```markdown
4 < 5
```
```markdown
4 < 5
```
--------------------------------
### Basic Admonition Example
Source: https://github.com/python-markdown/markdown/blob/master/tests/extensions/admonition.html
A simple admonition block with a default title derived from the type. Used for notes or important information.
```markdown
Note
A normal paragraph here
1. first
2. second
> Some important quote
>
> another paragraph in the quote
```
--------------------------------
### Python Usage of Admonition Extension
Source: https://github.com/python-markdown/markdown/blob/master/docs/extensions/admonition.md
Example of how to enable the 'admonition' extension when converting Markdown to HTML using the Python-Markdown library.
```python
import markdown
some_text = ""
markdown.markdown(some_text, extensions=['admonition'])
```
--------------------------------
### Desired HTML Output Example
Source: https://github.com/python-markdown/markdown/wiki/Tutorial-2---Altering-Markdown-Rendering
This is the desired HTML output after rendering the Markdown input, with remote images converted to links.
```html

a remote image
```
--------------------------------
### Use Named Extension
Source: https://github.com/python-markdown/markdown/blob/master/docs/extensions/api.md
Refer to an installed extension by its registered name string when calling `markdown.markdown`. Python-Markdown will find and load the extension.
```python
markdown.markdown(text, extensions=['myextension'])
```
--------------------------------
### Basic Usage with Footnotes Extension
Source: https://github.com/python-markdown/markdown/blob/master/docs/extensions/footnotes.md
Demonstrates the minimal configuration required to enable the Footnotes extension when converting Markdown text to HTML.
```python
import markdown
markdown.markdown(some_text, extensions=['footnotes'])
```
--------------------------------
### List Item with Lazy Paragraph Indentation
Source: https://github.com/python-markdown/markdown/blob/master/tests/basic/markdown-syntax.txt
Example of a multi-paragraph list item where only the first line of the second paragraph needs indentation.
```markdown
* This is a list item with two paragraphs.
This is the second paragraph in the list item. You're
only required to indent the first line. Lorem ipsum dolor
sit amet, consectetuer adipiscing elit.
```
--------------------------------
### Recommended keyword arguments for markdown.markdown()
Source: https://github.com/python-markdown/markdown/blob/master/docs/change_log/release-2.6.md
Shows the recommended way to pass extensions using keyword arguments to the `markdown.markdown()` function.
```python
html = markdown.markdown(text, extensions=[SomeExtension()])
```
--------------------------------
### List Item without Hanging Indent
Source: https://github.com/python-markdown/markdown/blob/master/tests/basic/markdown-syntax.txt
Example of a list item where subsequent lines are not indented, demonstrating Markdown's flexibility.
```markdown
* Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
viverra nec, fringilla in, laoreet vitae, risus.
```
--------------------------------
### URL Escaping Example
Source: https://github.com/python-markdown/markdown/blob/master/tests/extensions/extra/markdown-syntax.html
Demonstrates how to properly escape ampersands in URLs when used within Markdown to ensure correct HTML rendering.
```markdown
http://images.google.com/images?num=30&q=larry+bird
```
```markdown
http://images.google.com/images?num=30&q=larry+bird
```
--------------------------------
### Test Custom Extension
Source: https://github.com/python-markdown/markdown/wiki/Tutorial-1---Writing-Extensions-for-Python-Markdown
Demonstrates how to use the custom extension by passing an instance of `MyExtension` to the `markdown.markdown` function.
```python
>>> import markdown
>>> from myextension import MyExtension
>>> markdown.markdown('foo --deleted-- bar', extensions=[MyExtension()])
'foo deleted bar
'
```
--------------------------------
### Enable Sane Lists Extension in Python-Markdown
Source: https://github.com/python-markdown/markdown/blob/master/docs/extensions/sane_lists.md
A basic Python example showing how to enable the 'sane_lists' extension when converting Markdown text.
```python
import markdown
some_text = "..."
html = markdown.markdown(some_text, extensions=['sane_lists'])
```
--------------------------------
### Activate Virtual Environment (Windows)
Source: https://github.com/python-markdown/markdown/blob/master/docs/contributing.md
Activate the created virtual environment on Windows systems.
```sh
venv/Scripts/activate
```
--------------------------------
### Test Custom Markdown Extension
Source: https://github.com/python-markdown/markdown/wiki/Tutorial-1---Writing-Extensions-for-Python-Markdown
Demonstrates how to use the custom extension by passing an instance of it to the markdown.markdown function and shows the resulting HTML.
```python
>>> import markdown
>>> from myextension import MultiExtension
>>> txt = """
... Some __underline__
... Some --strike--
... Some **bold**
... Some //italics//
... """
...
>>> markdown.markdown(txt, extensions=[MultiExtension()])
'Some underline\nSome strike\nSome bold\nSome italics'
```
--------------------------------
### Define ID Attribute in Emphasized Text
Source: https://github.com/python-markdown/markdown/blob/master/docs/extensions/legacy_attrs.md
Example of defining an ID attribute for inline emphasized text using the legacy syntax.
```markdown
Some *emphasized{@id=bar}* text.
```
--------------------------------
### Run Unit Tests
Source: https://github.com/python-markdown/markdown/blob/master/docs/contributing.md
Discover and run all unit tests for the Python-Markdown project.
```sh
python -m unittest discover tests
```