### Full Reference Link Example (Markdown) Source: https://github.com/trentm/python-markdown2/blob/master/test/markdowntest-cases/Markdown Documentation - Syntax.html Provides a complete example using numbered reference links to demonstrate how they are used within a paragraph and defined separately. ```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" ``` -------------------------------- ### HTML Output for Reference Link Examples Source: https://github.com/trentm/python-markdown2/blob/master/test/markdowntest-cases/Markdown Documentation - Syntax.html Displays the HTML output generated by the full reference link examples (both explicit and implicit), showing how the links and titles are rendered. ```HTML
I get 10 times more traffic from Google than from Yahoo or MSN.
``` -------------------------------- ### Full Implicit Reference Link Example (Markdown) Source: https://github.com/trentm/python-markdown2/blob/master/test/markdowntest-cases/Markdown Documentation - Syntax.html Shows the same paragraph as the previous example, but using the implicit link name shortcut for reference links. ```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" ``` -------------------------------- ### Full Inline Link Example for Comparison (Markdown) Source: https://github.com/trentm/python-markdown2/blob/master/test/markdowntest-cases/Markdown Documentation - Syntax.html Presents the same paragraph as the reference link examples, but written entirely using Markdown's inline link style for comparison purposes. ```Markdown I get 10 times more traffic from [Google](http://google.com/ "Google") than from [Yahoo](http://search.yahoo.com/ "Yahoo Search") or [MSN](http://search.msn.com/ "MSN Search"). ``` -------------------------------- ### HTML Output for Inline Links Source: https://github.com/trentm/python-markdown2/blob/master/test/markdowntest-cases/Markdown Documentation - Syntax.html Shows the resulting HTML generated by the Markdown inline link syntax examples, illustrating how the URL and title attributes are rendered. ```HTMLThis is an example inline link.
This link has no title attribute.
``` -------------------------------- ### Markdown Atx-style Headers Source: https://github.com/trentm/python-markdown2/blob/master/test/markdowntest-cases/Markdown Documentation - Syntax.html Examples of basic Atx-style headers using '#' characters for levels H1, H2, and H6. ```Markdown # This is an H1 ## This is an H2 ###### This is an H6 ``` -------------------------------- ### Markdown Setext-style Headers Source: https://github.com/trentm/python-markdown2/blob/master/test/markdowntest-cases/Markdown Documentation - Syntax.html Examples of Setext-style headers using '=' for H1 and '-' for H2. ```Markdown This is an H1 ============= This is an H2 ------------- ``` -------------------------------- ### Generated HTML for AppleScript Code Block Source: https://github.com/trentm/python-markdown2/blob/master/test/markdowntest-cases/Markdown Documentation - Syntax.html Displays the HTML output generated by Markdown for the AppleScript code block example, preserving the original indentation within the tag.
```HTML
Here is an example of AppleScript:
tell application "Foo"
beep
end tell
```
--------------------------------
### Valid Markdown Bold and Link Nesting
Source: https://github.com/trentm/python-markdown2/blob/master/test/php-markdown-cases/Nesting.html
Examples demonstrating valid combinations of bold text and links in Markdown.
```Markdown
**[Link](url)**
```
```Markdown
[**Link**](url)
```
```Markdown
**[**Link**](url)**
```
--------------------------------
### Example Python Fenced Code Block
Source: https://github.com/trentm/python-markdown2/blob/master/test/tm-cases/fenced_code_blocks_syntax_highlighting.html
A simple Python print statement used to demonstrate a fenced code block with syntax highlighting, assuming 'pygments' is installed.
```Python
if True: print "hi"
```
--------------------------------
### Performing Simple Arithmetic in Python
Source: https://github.com/trentm/python-markdown2/blob/master/test/tm-cases/pyshell_and_fenced_code_blocks.html
Illustrates basic arithmetic operations within a Python interactive session, showing simple addition examples.
```python
>>> 1 + 1
```
```python
>>> 2 + 2
```
--------------------------------
### Creating Reference-Style Links (Markdown)
Source: https://github.com/trentm/python-markdown2/blob/master/test/markdowntest-cases/Markdown Documentation - Syntax.html
Shows the syntax for creating reference-style links in Markdown, which use a separate label to refer to a link definition elsewhere in the document. Includes examples with and without a space between brackets.
```Markdown
This is [an example][id] reference-style link.
This is [an example] [id] reference-style link.
```
--------------------------------
### Markdown Closed Atx-style Headers
Source: https://github.com/trentm/python-markdown2/blob/master/test/markdowntest-cases/Markdown Documentation - Syntax.html
Examples of Atx-style headers with optional closing '#' characters.
```Markdown
# This is an H1 #
## This is an H2 ##
### This is an H3 ######
```
--------------------------------
### Basic Addition (Doctest)
Source: https://github.com/trentm/python-markdown2/blob/master/test/tm-cases/pyshell.html
A simple example of integer addition demonstrated in a Python doctest format, showing the input expression and the resulting output.
```Python
>>> 1 + 1
2
```
--------------------------------
### Markdown HTML Entity Example
Source: https://github.com/trentm/python-markdown2/blob/master/test/markdowntest-cases/Markdown Documentation - Syntax.html
Demonstrates how Markdown leaves explicit HTML entities like © unchanged.
```Markdown
©
```
--------------------------------
### Escaped Ampersand in URL Example
Source: https://github.com/trentm/python-markdown2/blob/master/test/markdowntest-cases/Markdown Documentation - Syntax.html
Example of the same URL with the ampersand correctly escaped for use in an HTML attribute.
```Text
http://images.google.com/images?num=30&q=larry+bird
```
--------------------------------
### Using Implicit Reference Links (Markdown)
Source: https://github.com/trentm/python-markdown2/blob/master/test/markdowntest-cases/Markdown Documentation - Syntax.html
Introduces the implicit link name shortcut for reference links, where the link text itself is used as the label by using empty square brackets. Shows examples for single and multiple words.
```Markdown
[Google][]
[Google]: http://google.com/
Visit [Daring Fireball][] for more information.
[Daring Fireball]: http://daringfireball.net/
```
--------------------------------
### Basic Code Example (Text)
Source: https://github.com/trentm/python-markdown2/blob/master/test/tm-cases/fenced_code_blocks_simple.html
A simple example demonstrating a basic code block, potentially using the fenced-code-blocks extra.
```text
here is some code
```
--------------------------------
### Including Elements in Blockquotes Markdown
Source: https://github.com/trentm/python-markdown2/blob/master/test/markdowntest-cases/Markdown Documentation - Syntax.html
Provides an example of a Markdown blockquote that contains other Markdown elements, such as headers, ordered lists, and code blocks. This demonstrates the flexibility of blockquotes as containers.
```Markdown
> ## This is a header.
>
> 1. This is the first list item.
> 2. This is the second list item.
>
> Here's some example code:
>
> return shell_exec("echo $input | $markdown_script");
```
--------------------------------
### Another Basic Addition (Doctest)
Source: https://github.com/trentm/python-markdown2/blob/master/test/tm-cases/pyshell.html
Another simple example of integer addition in doctest format, illustrating how separate doctest blocks can appear within the text.
```Python
>>> 2 + 2
4
```
--------------------------------
### Simple Single-Line Block - Text
Source: https://github.com/trentm/python-markdown2/blob/master/test/markdowntest-cases/Inline HTML (Advanced).html
A basic example showing a single line treated as a block.
```text
foo
```
--------------------------------
### Unescaped Ampersand in URL Example
Source: https://github.com/trentm/python-markdown2/blob/master/test/markdowntest-cases/Markdown Documentation - Syntax.html
Example of a URL containing an unescaped ampersand, which needs to be escaped in HTML attributes.
```Text
http://images.google.com/images?num=30&q=larry+bird
```
--------------------------------
### Basic Inline Link - Markdown
Source: https://github.com/trentm/python-markdown2/blob/master/test/tm-cases/inline_links.html
Demonstrates the basic syntax for an inline link with just the link text and URL.
```Markdown
[link](/url/)
```
--------------------------------
### Example Text in Markdown Blockquote Pre-block
Source: https://github.com/trentm/python-markdown2/blob/master/test/tm-cases/blockquote_with_pre.html
This snippet shows example text content that would appear within a pre-formatted block inside a Markdown blockquote, demonstrating the indentation context.
```Plaintext
here is a check
for that
```
--------------------------------
### Markdown Text with Escaped Open Bracket and Nested Link
Source: https://github.com/trentm/python-markdown2/blob/master/test/tm-cases/tricky_anchors.html
Demonstrates text that starts with an escaped open bracket (`\[`) followed immediately by a standard Markdown link with a title.
```Markdown
\[only open [bracket(/in/) text](/url/ "a title")
```
--------------------------------
### Markdown Simple Table with Leading and Tailing Pipes
Source: https://github.com/trentm/python-markdown2/blob/master/test/php-markdown-extra-cases/Tables.html
Basic Markdown table syntax with both leading and tailing pipes.
```markdown
| Header 1 | Header 2 |
| -------- | -------- |
| Cell 1 | Cell 2 |
| Cell 3 | Cell 4 |
```
--------------------------------
### Printing Hello World in Python
Source: https://github.com/trentm/python-markdown2/blob/master/test/tm-cases/footnotes_markup.html
This snippet shows a basic Python 2 statement used to print the string 'Hello, World!' to the standard output. It is presented as an example of code that can be included within the body of a Markdown footnote.
```python
print "Hello, World!"
```
--------------------------------
### Configure and Setup Shadowbox for Images (JavaScript)
Source: https://github.com/trentm/python-markdown2/blob/master/test/tm-cases/fenced_code_blocks_issue113.html
Initializes the Shadowbox library with specific options and sets up image elements within the '.entry-content' class to open in a Shadowbox gallery when the window finishes loading. Requires the Shadowbox library to be loaded.
```javascript
Shadowbox.init({ handleOversize: "drag" });
window.onload = function() {
Shadowbox.setup(".entry-content img", { gallery: "{{post.title}}", counterType: "skip" });
};
```
--------------------------------
### XML Processing Instructions and One-Liner Tags Example
Source: https://github.com/trentm/python-markdown2/blob/master/CHANGES.md
Example of XML processing instructions and one-liner tags that were passed through without wrapping in a paragraph tag in version 1.0.1.6.
```xml
```
--------------------------------
### Basic Inline Image - Markdown
Source: https://github.com/trentm/python-markdown2/blob/master/test/tm-cases/inline_links.html
Demonstrates the basic syntax for an inline image with alt text and URL, prefixed by an exclamation mark.
```Markdown

```
--------------------------------
### Markdown Simple Table with Leading Pipes
Source: https://github.com/trentm/python-markdown2/blob/master/test/php-markdown-extra-cases/Tables.html
Basic Markdown table syntax with leading pipes before each row.
```markdown
| Header 1 | Header 2
| -------- | --------
| Cell 1 | Cell 2
| Cell 3 | Cell 4
```
--------------------------------
### Basic Usage as Command Line Script
Source: https://github.com/trentm/python-markdown2/blob/master/README.md
Shows different ways to use markdown2 from the command line to convert a Markdown file to HTML, either directly via the script, using the -m flag, or after installation.
```shell
$ python markdown2.py foo.md > foo.html
```
```shell
$ python -m markdown2 foo.md > foo.html
```
```shell
$ markdown2 foo.md > foo.html
```
--------------------------------
### Example Ruby Fenced Code Block
Source: https://github.com/trentm/python-markdown2/blob/master/test/tm-cases/fenced_code_blocks_syntax_highlighting.html
A basic Ruby method definition with a print statement, shown as an example of a fenced code block in markdown.
```Ruby
def foo
puts "hi"
end
```
--------------------------------
### Using nprint Function in Python
Source: https://github.com/trentm/python-markdown2/blob/master/test/tm-cases/pyshell_and_fenced_code_blocks.html
Demonstrates the usage of a hypothetical 'nprint' function to format numbers with delimiters and periods. Shows two examples with different parameters to illustrate formatting variations.
```python
>>> nprint(9876543210)
```
```python
>>> nprint(987654321, period=1, delimiter=",")
```
--------------------------------
### Basic Markdown Link
Source: https://github.com/trentm/python-markdown2/blob/master/test/markdowntest-cases/Links, inline style.html
Defines a standard Markdown link with just the link text and URL.
```Markdown
[URL](/url/)
```
--------------------------------
### Markdown Simple Table with Tailing Pipes
Source: https://github.com/trentm/python-markdown2/blob/master/test/php-markdown-extra-cases/Tables.html
Basic Markdown table syntax with tailing pipes after each row.
```markdown
Header 1 | Header 2 |
-------- | -------- |
Cell 1 | Cell 2 |
Cell 3 | Cell 4 |
```
--------------------------------
### Defining Horizontal Rules in Markdown
Source: https://github.com/trentm/python-markdown2/blob/master/test/markdowntest-cases/Markdown Documentation - Syntax.html
Provides various examples of character patterns (three or more hyphens, asterisks, or underscores) used on a line by themselves in Markdown to create a horizontal rule (
).
```Markdown
* * *
***
*****
- - -
---------------------------------------
_ _ _
```
--------------------------------
### Defining Link Patterns with Regex (Configuration)
Source: https://github.com/trentm/python-markdown2/blob/master/CHANGES.md
Example configuration for the 'link-patterns' extra, showing how to define a regular expression and a corresponding href template to automatically create links from matching text.
```Configuration
regex: mozilla\s+bug\s+(\d+)
href: http://bugzilla.mozilla.org/show_bug.cgi?id=\1
```
--------------------------------
### Printing 'hello' in Python
Source: https://github.com/trentm/python-markdown2/blob/master/test/tm-cases/fenced_code_blocks_leading_paragraph.html
This snippet uses the built-in print function to output the string 'hello' to the standard console.
```python
print 'hello'
```
--------------------------------
### Markdown Code Span with Multiple Backticks
Source: https://github.com/trentm/python-markdown2/blob/master/test/markdowntest-cases/Markdown Documentation - Syntax.html
Demonstrates using multiple backticks as delimiters for Markdown code spans, allowing literal backticks at the start or end of the span.
```Markdown
`` ` ``
```
```Markdown
`` `foo` ``
```
```HTML
A single backtick in a code span: `
```
```HTML
A backtick-delimited string in a code span: `foo`
```
--------------------------------
### Example Markdown Table Syntax
Source: https://github.com/trentm/python-markdown2/blob/master/CHANGES.md
Demonstrates the new 'tables' extra syntax matching GFM and PHP-Markdown Extra. Shows basic header and cell formatting for creating tables in Markdown.
```Markdown
| Header 1 | *Header* 2 |
| -------- | -------- |
| `Cell 1` | [Cell 2](http://example.com) link |
| Cell 3 | **Cell 4** |
```
--------------------------------
### HTML Block Example: Paragraph Tag
Source: https://github.com/trentm/python-markdown2/blob/master/test/php-markdown-cases/MD5 Hashes.html
Shows an example of an HTML paragraph block (`test
`) and its corresponding MD5 hash value.
```html
test
```
--------------------------------
### Markdown One-Column Table with Leading and Tailing Pipes
Source: https://github.com/trentm/python-markdown2/blob/master/test/php-markdown-extra-cases/Tables.html
Markdown syntax for a one-column table with both leading and tailing pipes.
```markdown
| Header |
| ------ |
| Cell |
```
--------------------------------
### Creating Relative Inline Links (Markdown)
Source: https://github.com/trentm/python-markdown2/blob/master/test/markdowntest-cases/Markdown Documentation - Syntax.html
Illustrates how to use relative paths in inline Markdown links when linking to resources on the same server.
```Markdown
See my [About](/about/) page for details.
```
--------------------------------
### Running Tox Tests
Source: https://github.com/trentm/python-markdown2/blob/master/CHANGES.md
Provides commands to install and run 'tox' for testing `python-markdown2` against different Python environments, confirming compatibility with interpreters like Jython and PyPy.
```Shell
[sudo] pip install tox
tox
```
--------------------------------
### Markdown Unordered List with Asterisks
Source: https://github.com/trentm/python-markdown2/blob/master/test/markdowntest-cases/Markdown Documentation - Syntax.html
Demonstrates the basic syntax for creating an unordered list using asterisk (*) markers. Each item is on a new line, prefixed by the marker and a space.
```Markdown
* Red
* Green
* Blue
```
--------------------------------
### Markdown Potential Accidental Ordered List
Source: https://github.com/trentm/python-markdown2/blob/master/test/markdowntest-cases/Markdown Documentation - Syntax.html
Highlights a common pitfall where a line starting with a number, period, and space can be misinterpreted as an ordered list marker, even if not intended as a list.
```Markdown
1986. What a great season.
```
--------------------------------
### Example Inline Code Block
Source: https://github.com/trentm/python-markdown2/blob/master/test/tm-cases/issue276_fenced_code_blocks_in_lists.html
This snippet demonstrates an inline code block using backticks.
```plaintext
test with language set
```
--------------------------------
### Markdown Ordered List with Lazy Numbering (Arbitrary Numbers)
Source: https://github.com/trentm/python-markdown2/blob/master/test/markdowntest-cases/Markdown Documentation - Syntax.html
Further illustrates Markdown's lazy numbering for ordered lists. Arbitrary numbers followed by a period and space will still result in a sequentially numbered HTML list starting from 1.
```Markdown
3. Bird
1. McHale
8. Parish
```
--------------------------------
### Markdown One-Column Table with Tailing Pipes
Source: https://github.com/trentm/python-markdown2/blob/master/test/php-markdown-extra-cases/Tables.html
Markdown syntax for a one-column table with tailing pipes.
```markdown
Header |
------ |
Cell |
```
--------------------------------
### Indented Code Block Example (Text)
Source: https://github.com/trentm/python-markdown2/blob/master/test/tm-cases/fenced_code_blocks_simple.html
Demonstrates an indented code block, used to check if indentation is preserved within the block.
```text
is indentation maintained?
```
--------------------------------
### Invalid Markdown Link Nesting
Source: https://github.com/trentm/python-markdown2/blob/master/test/php-markdown-cases/Nesting.html
An example showing invalid nesting where a link is placed within the text of another link.
```Markdown
[[Link](url)](url)
```
--------------------------------
### JavaScript Alert for HTML Removal Example 1
Source: https://github.com/trentm/python-markdown2/blob/master/test/tm-cases/issue2_safe_mode_borks_markup.html
A simple JavaScript alert call used as the first example of code intended to be removed or sanitized by the markdown processor.
```javascript
alert('this should be removed')
```
--------------------------------
### Markdown One-Column Table with Leading Pipes
Source: https://github.com/trentm/python-markdown2/blob/master/test/php-markdown-extra-cases/Tables.html
Markdown syntax for a one-column table with leading pipes.
```markdown
| Header
| ------
| Cell
```
--------------------------------
### Example Multiline Indented Code Block
Source: https://github.com/trentm/python-markdown2/blob/master/test/tm-cases/issue276_fenced_code_blocks_in_lists.html
This snippet illustrates a multiline code block created using indentation.
```plaintext
This is a regular code block
Multiline
```
--------------------------------
### List Items with Mixed Indentation - Plaintext
Source: https://github.com/trentm/python-markdown2/blob/master/test/markdowntest-cases/Tabs.html
Examples of list items using four-space indentation for the marker and eight-space indentation for continuation lines, illustrating how different indentation methods can be used within lists.
```plaintext
+ this is an example list item
indented with tabs
+ this is an example list item
indented with spaces
```
--------------------------------
### Example Fenced Code Block (Text)
Source: https://github.com/trentm/python-markdown2/blob/master/test/tm-cases/fenced_code_blocks_issue161.html
Demonstrates a simple fenced code block using Markdown syntax. The text within the block is treated as code.
```text
here is some code
```
--------------------------------
### Inline Code Block (Text)
Source: https://github.com/trentm/python-markdown2/blob/master/test/tm-cases/fenced_code_blocks_issue355.html
A simple example of an inline code block, typically used for short code snippets or commands within a sentence.
```text
some code block
```
--------------------------------
### Code Block Demonstrating Nested Syntax
Source: https://github.com/trentm/python-markdown2/blob/master/test/tm-cases/fenced_code_blocks_issue327.html
Example of a Markdown code block using quadruple backticks, containing the syntax for a triple-backtick code block. This demonstrates how nested code block markers are rendered.
```plaintext
```cpp
int x = 10;
```
```
--------------------------------
### HTML iframe onload Event
Source: https://github.com/trentm/python-markdown2/blob/master/test/tm-cases/xss_issue_362.html
This snippet shows a basic HTML iframe element. It includes an `onload` attribute which executes a JavaScript `alert()` function when the iframe content finishes loading. This is a simple example, often used in security contexts to demonstrate XSS vulnerabilities.
```HTML