diff --git a/.gitignore b/.gitignore
index 6ac9fff47..96c6778e3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,7 @@ test-output.html
build/*
dist/*
tmp/*
+site/*
MANIFEST
.venv
*~
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
index e8679d623..10044e459 100644
--- a/CODE_OF_CONDUCT.md
+++ b/CODE_OF_CONDUCT.md
@@ -41,7 +41,6 @@ is deemed necessary and appropriate to the circumstances. Maintainers are
obligated to maintain confidentiality with regard to the reporter of an
incident.
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 1.3.0, available at
[http://contributor-covenant.org/version/1/3/0/][version]
diff --git a/INSTALL.md b/INSTALL.md
index 6e6ab8c74..a314fb6c7 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -5,5 +5,5 @@ As an Admin/Root user on your system do:
pip install markdown
-Or for more specific instructions, view the documentation in `docs/install.txt`
-or on the website at The HTML specification
+is maintained by the W3C. The HTML specification
- is maintained by the W3C. Note You should note that the title will be automatically capitalized. Note You should note that the title will be automatically capitalized. Don't try this at home ... Don't try this at home ... This is a admonition box without a title. This is a admonition box without a title.` tags in
-raw HTML input as block level tags. As they are actually inline level tags,
-this behavior has been changed. This may result in slightly different output.
-While in most cases, the new output is more correct, there may be a few edge
-cases where a document author has relied on the previous incorrect behavior.
-It is likely that a few adjustments may need to be made to those documents.
-
-* The behavior of the `enable_attributes` keyword has been slightly altered.
-If authors have been using attributes in documents with `safe_mode` on, those
-attributes will no longer be parsed unless `enable_attributes` is explicitly
-set to `True`. This change was made to prevent untrusted authors from injecting
-potentially harmful JavaScript in documents. This change had no effect when
-not in `safe_mode`.
-
-What's New in Python-Markdown 2.1
----------------------------------
-
-The docs were refactored and can now be found at
-` tags in raw
+ HTML input as block level tags. As they are actually inline level tags, this
+ behavior has been changed. This may result in slightly different output. While
+ in most cases, the new output is more correct, there may be a few edge cases
+ where a document author has relied on the previous incorrect behavior. It is
+ likely that a few adjustments may need to be made to those documents.
+
+* The behavior of the `enable_attributes` keyword has been slightly altered. If
+ authors have been using attributes in documents with `safe_mode` on, those
+ attributes will no longer be parsed unless `enable_attributes` is explicitly
+ set to `True`. This change was made to prevent untrusted authors from
+ injecting potentially harmful JavaScript in documents. This change had no
+ effect when not in `safe_mode`.
+
+What's New in Python-Markdown 2.2
+---------------------------------
+
+The docs were refactored and can now be found at
+The [Meta-Data] Extension now includes optional support for [YAML] style
+meta-data. By default, the YAML deliminators are recognized, however, the
+actual data is parsed as previously. This follows the syntax of [MultiMarkdown],
+which inspired this extension.
+
+Alternatively, if the `yaml` option is set, then the data is parsed as
+YAML. As the `yaml` option was buggy, it was removed in 2.6.1. It is
+suggested that a preprocessor (like [docdata]) or a third party extension be
+used if you want true YAML support. See [Issue #390][#390] for a full
+explanation.
+
+[MultiMarkdown]: http://fletcherpenney.net/MultiMarkdown_Syntax_Guide#metadata
+[Meta-Data]: ../extensions/meta_data.md
+[YAML]: http://yaml.org/
+[#390]: https://github.com/Python-Markdown/markdown/issues/390
+[docdata]: https://github.com/waylan/docdata
+
+### Table of Contents Extension Refactored
+
+The [Table of Contents][TOC] Extension has been refactored and some new features
+have been added. See the documentation for a full explanation of each feature
+listed below:
+
+* The extension now assigns the Table of Contents to the `toc` attribute of
+ the Markdown class regardless of whether a "marker" was found in the
+ document. Third party frameworks no longer need to insert a "marker," run
+ the document through Markdown, then extract the Table of Contents from the
+ document.
+
+* The Table of Contents Extension is now a "registered extension." Therefore,
+ when the `reset` method of the Markdown class is called, the `toc` attribute
+ on the Markdown class is cleared (set to an empty string).
+
+* When the `marker` configuration option is set to an empty string, the parser
+ completely skips the process of searching the document for markers. This
+ should save parsing time when the Table of Contents Extension is being used
+ only to assign ids to headers.
+
+* A `separator` configuration option has been added allowing users to override
+ the separator character used by the slugify function.
+
+* A `baselevel` configuration option has been added allowing users to set the
+ base level of headers in their documents (h1-h6). This allows the header
+ levels to be automatically adjusted to fit within the hierarchy of an HTML
+ template.
+
+[TOC]: ../extensions/toc.md
+
+### Pygments can now be disabled
+
+The [CodeHilite][ch] Extension has gained a new configuration option:
+`use_pygments`. The option is `True` by default, however, it allows one to turn
+off Pygments code highlighting (set to `False`) while preserving the language
+detection features of the extension. Note that Pygments language guessing is not
+used as that would 'use Pygments'. If a language is defined for a code block, it
+will be assigned to the `` tag as a class in the manner suggested by the
+[HTML5 spec][spec] (alternate output will not be entertained) and could
+potentially be used by a JavaScript library in the browser to highlight the code
+block.
+
+[ch]: ../extensions/code_hilite.md
+[spec]: http://www.w3.org/TR/html5/text-level-semantics.html#the-code-element
+
+### Miscellaneous
+
+Test coverage has been improved including running [flake8]. While those changes
+will not directly effect end users, the code is being better tested which will
+benefit everyone.
+
+[flake8]: https://flake8.readthedocs.io/en/latest/
+
+Various bug fixes have been made. See the
+[commit log](https://github.com/Python-Markdown/markdown/commits/master)
+for a complete history of the changes.
diff --git a/docs/cli.txt b/docs/cli.md
similarity index 57%
rename from docs/cli.txt
rename to docs/cli.md
index c2b37e4a9..dbac2c4fd 100644
--- a/docs/cli.txt
+++ b/docs/cli.md
@@ -1,44 +1,47 @@
title: Command Line
-prev_title: Library Reference
-prev_url: reference.html
-next_title: Extensions
-next_url: extensions/index.html
-
Using Python-Markdown on the Command Line
=========================================
-While Python-Markdown is primarily a python library, a command line script is
-included as well. While there are many other command line implementations
-of Markdown, you may not have them installed, or you may prefer to use
+While Python-Markdown is primarily a python library, a command line script is
+included as well. While there are many other command line implementations
+of Markdown, you may not have them installed, or you may prefer to use
Python-Markdown's various extensions.
Generally, you will want to have the Markdown library fully installed on your
-system to run the command line script. See the
-[Installation instructions](install.html) for details.
+system to run the command line script. See the
+[Installation instructions](install.md) for details.
Python-Markdown's command line script takes advantage of Python's `-m` flag.
-Therefore, assuming the python executable is on your system path, use the
+Therefore, assuming the python executable is on your system path, use the
following format:
- $ python -m markdown [options] [args]
+```bash
+python -m markdown [options] [args]
+```
-That will run the module as a script with the options and arguments provided.
+That will run the module as a script with the options and arguments provided.
At its most basic usage, one would simply pass in a file name as the only argument:
- $ python -m markdown input_file.txt
+```bash
+python -m markdown input_file.txt
+```
-Piping input and output (on `STDIN` and `STDOUT`) is fully supported as well.
+Piping input and output (on `STDIN` and `STDOUT`) is fully supported as well.
For example:
- $ echo "Some **Markdown** text." | python -m markdown > output.html
+```bash
+echo "Some **Markdown** text." | python -m markdown > output.html
+```
Use the `--help` option for a list all available options and arguments:
- $ python -m markdown --help
+```bash
+python -m markdown --help
+```
-If you don't want to call the python executable directly (using the `-m` flag),
+If you don't want to call the python executable directly (using the `-m` flag),
follow the instructions below to use a wrapper script:
Setup
@@ -46,27 +49,27 @@ Setup
Upon installation, the `markdown_py` script will have been copied to
your Python "Scripts" directory. Different systems require different methods to
-ensure that any files in the Python "Scripts" directory are on your system
+ensure that any files in the Python "Scripts" directory are on your system
path.
* **Windows**:
- Assuming a default install of Python on Windows, your "Scripts" directory
+ Assuming a default install of Python on Windows, your "Scripts" directory
is most likely something like `C:\\Python26\Scripts`. Verify the location
of your "Scripts" directory and add it to you system path.
- Calling `markdown_py` from the command line will call the wrapper batch
+ Calling `markdown_py` from the command line will call the wrapper batch
file `markdown_py.bat` in the `"Scripts"` directory created during install.
* __*nix__ (Linux, OSX, BSD, Unix, etc.):
- As each *nix distribution is different and we can't possibly document all
+ As each \*nix distribution is different and we can't possibly document all
of them here, we'll provide a few helpful pointers:
- * Some systems will automatically install the script on your path. Try it
+ * Some systems will automatically install the script on your path. Try it
and see if it works. Just run `markdown_py` from the command line.
- * Other systems may maintain a separate "Scripts" ("bin") directory which
+ * Other systems may maintain a separate "Scripts" ("bin") directory which
you need to add to your path. Find it (check with your distribution) and
either add it to your path or make a symbolic link to it from your path.
@@ -75,79 +78,94 @@ path.
As an alternative, you could just `cd` into the directory which contains
the source distribution, and run it from there. However, remember that your
- markdown text files will not likely be in that directory, so it is much
+ markdown text files will not likely be in that directory, so it is much
more convenient to have `markdown_py` on your path.
-!!!Note
- Python-Markdown uses `"markdown_py"` as a script name because
- the Perl implementation has already taken the more obvious name "markdown".
- Additionally, the default Python configuration on some systems would cause a
- script named `"markdown.py"` to fail by importing itself rather than the markdown
- library. Therefore, the script has been named `"markdown_py"` as a compromise. If
- you prefer a different name for the script on your system, it is suggested that
- you create a symbolic link to `markdown_py` with your preferred name.
+!!!Note
+ Python-Markdown uses `"markdown_py"` as a script name because the Perl
+ implementation has already taken the more obvious name "markdown".
+ Additionally, the default Python configuration on some systems would cause a
+ script named `"markdown.py"` to fail by importing itself rather than the
+ markdown library. Therefore, the script has been named `"markdown_py"` as a
+ compromise. If you prefer a different name for the script on your system, it
+ is suggested that you create a symbolic link to `markdown_py` with your
+ preferred name.
Usage
-----
-To use `markdown_py` from the command line, run it as
+To use `markdown_py` from the command line, run it as
- $ markdown_py input_file.txt
+```bash
+markdown_py input_file.txt
+```
-or
+or
- $ markdown_py input_file.txt > output_file.html
+```bash
+markdown_py input_file.txt > output_file.html
+```
For a complete list of options, run
- $ markdown_py --help
+```bash
+markdown_py --help
+```
Using Extensions
----------------
-To load a Python-Markdown extension from the command line use the `-x`
-(or `--extension`) option. The extension module must be on your `PYTHONPATH`
-(see the [Extension API](extensions/api.html) for details). The extension can
+To load a Python-Markdown extension from the command line use the `-x`
+(or `--extension`) option. The extension module must be on your `PYTHONPATH`
+(see the [Extension API](extensions/api.md) for details). The extension can
then be invoked by the name of that module using Python's dot syntax:
- $ python -m markdown -x path.to.module input.txt
+```bash
+python -m markdown -x path.to.module input.txt
+```
To load multiple extensions, specify an `-x` option for each extension:
- $ python -m markdown -x markdown.extensions.footnotes -x markdown.extensions.codehilite input.txt
+```bash
+python -m markdown -x markdown.extensions.footnotes -x markdown.extensions.codehilite input.txt
+```
-If the extension supports configuration options (see the documentation for the
-extension you are using to determine what settings it supports, if any), you
+If the extension supports configuration options (see the documentation for the
+extension you are using to determine what settings it supports, if any), you
can pass them in as well:
- $ python -m markdown -x markdown.extensions.footnotes -c config.yml input.txt
+```bash
+python -m markdown -x markdown.extensions.footnotes -c config.yml input.txt
+```
-The `-c` (or `--extension_configs`) option accepts a file name. The file must be in
-either the [YAML] or [JSON] format and contain YAML or JSON data that would map to
-a Python Dictionary in the format required by the [`extension_configs`][ec] keyword
-of the `markdown.Markdown` class. Therefore, the file `config.yaml` referenced in the
-above example might look like this:
+The `-c` (or `--extension_configs`) option accepts a file name. The file must be
+in either the [YAML] or [JSON] format and contain YAML or JSON data that would
+map to a Python Dictionary in the format required by the
+[`extension_configs`][ec] keyword of the `markdown.Markdown` class. Therefore,
+the file `config.yaml` referenced in the above example might look like this:
- markdown.extensions.footnotes:
- PLACE_MARKER: ~~~~~~~~
- UNIQUE_IDS: True
+```yaml
+markdown.extensions.footnotes:
+ PLACE_MARKER: ~~~~~~~~
+ UNIQUE_IDS: True
+```
-Note that while the `--extension_configs` option does specify the "markdown.extensions.footnotes"
-extension, you still need to load the extension with the `-x` option, or the configuration for that
-extension will be ignored.
+Note that while the `--extension_configs` option does specify the
+"markdown.extensions.footnotes" extension, you still need to load the extension
+with the `-x` option, or the configuration for that extension will be ignored.
-The `--extension_configs` option will only support YAML configuration files if [PyYAML] is
-installed on your system. JSON should work with no additional dependencies. The format
-of your configuration file is automatically detected.
+The `--extension_configs` option will only support YAML configuration files if
+[PyYAML] is installed on your system. JSON should work with no additional
+dependencies. The format of your configuration file is automatically detected.
!!!warning
- The previously documented method of appending the extension configuration options as a string to the
- extension name will be deprecated in Python-Markdown version 2.6. The `--extension_configs`
- option should be used instead. See the [2.5 release notes] for more information.
+ The previously documented method of appending the extension configuration
+ options as a string to the extension name will be deprecated in
+ Python-Markdown version 2.6. The `--extension_configs` option should be used
+ instead. See the [2.5 release notes] for more information.
[ec]: reference.html#extension_configs
[YAML]: http://yaml.org/
[JSON]: http://json.org/
[PyYAML]: http://pyyaml.org/
-[2.5 release notes]: release-2.5.txt
-
+[2.5 release notes]: change_log/release-2.5.md
diff --git a/docs/default.css b/docs/default.css
deleted file mode 100644
index 7833719c1..000000000
--- a/docs/default.css
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * default.css_t
- * ~~~~~~~~~~~~~
- *
- * Sphinx stylesheet -- default theme.
- *
- * :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
- * :license: BSD, see LICENSE for details.
- *
- */
-
-@import url("basic.css");
-
-/* -- page layout ----------------------------------------------------------- */
-
-body {
- font-family: sans-serif;
- font-size: 100%;
- background-color: #11303d;
- color: #000;
- margin: 0;
- padding: 0;
-}
-
-div.document {
- background-color: #1c4e63;
-}
-
-div.documentwrapper {
- float: left;
- width: 100%;
-}
-
-div.bodywrapper {
- margin: 0 0 0 230px;
-}
-
-div.body {
- background-color: #ffffff;
- color: #000000;
- padding: 0 20px 30px 20px;
-}
-
-div.footer {
- color: #ffffff;
- width: 100%;
- padding: 9px 0 9px 0;
- text-align: center;
- font-size: 75%;
-}
-
-div.footer a {
- color: #ffffff;
- text-decoration: underline;
-}
-
-div.related {
- background-color: #133f52;
- line-height: 30px;
- color: #ffffff;
-}
-
-div.related a {
- color: #ffffff;
-}
-
-div.sphinxsidebar {
-}
-
-div.sphinxsidebar h3 {
- font-family: 'Trebuchet MS', sans-serif;
- color: #ffffff;
- font-size: 1.4em;
- font-weight: normal;
- margin: 0;
- padding: 0;
-}
-
-div.sphinxsidebar h3 a {
- color: #ffffff;
-}
-
-div.sphinxsidebar h4 {
- font-family: 'Trebuchet MS', sans-serif;
- color: #ffffff;
- font-size: 1.3em;
- font-weight: normal;
- margin: 5px 0 0 0;
- padding: 0;
-}
-
-div.sphinxsidebar p {
- color: #ffffff;
-}
-
-div.sphinxsidebar p.topless {
- margin: 5px 10px 10px 10px;
-}
-
-div.sphinxsidebar ul {
- margin: 10px;
- padding: 0;
- color: #ffffff;
-}
-
-div.sphinxsidebar a {
- color: #98dbcc;
-}
-
-div.sphinxsidebar input {
- border: 1px solid #98dbcc;
- font-family: sans-serif;
- font-size: 1em;
-}
-
-
-/* for collapsible sidebar */
-div#sidebarbutton {
- background-color: #3c6e83;
-}
-
-
-/* -- hyperlink styles ------------------------------------------------------ */
-
-a {
- color: #355f7c;
- text-decoration: none;
-}
-
-a:visited {
- color: #355f7c;
- text-decoration: none;
-}
-
-a:hover {
- text-decoration: underline;
-}
-
-
-
-/* -- body styles ----------------------------------------------------------- */
-
-div.body h1,
-div.body h2,
-div.body h3,
-div.body h4,
-div.body h5,
-div.body h6 {
- font-family: 'Trebuchet MS', sans-serif;
- background-color: #f2f2f2;
- font-weight: normal;
- color: #20435c;
- border-bottom: 1px solid #ccc;
- margin: 20px -20px 10px -20px;
- padding: 3px 0 3px 10px;
-}
-
-div.body h1 { margin-top: 0; font-size: 200%; }
-div.body h2 { font-size: 160%; }
-div.body h3 { font-size: 140%; }
-div.body h4 { font-size: 120%; }
-div.body h5 { font-size: 110%; }
-div.body h6 { font-size: 100%; }
-
-a.headerlink {
- color: #c60f0f;
- font-size: 0.8em;
- padding: 0 4px 0 4px;
- text-decoration: none;
-}
-
-a.headerlink:hover {
- background-color: #c60f0f;
- color: white;
-}
-
-div.body p, div.body dd, div.body li {
- text-align: justify;
- line-height: 130%;
-}
-
-div.admonition p.admonition-title + p {
- display: inline;
-}
-
-div.admonition p {
- margin-bottom: 5px;
-}
-
-div.admonition pre {
- margin-bottom: 5px;
-}
-
-div.admonition ul, div.admonition ol {
- margin-bottom: 5px;
-}
-
-div.note {
- background-color: #eee;
- border: 1px solid #ccc;
-}
-
-div.seealso {
- background-color: #ffc;
- border: 1px solid #ff6;
-}
-
-div.topic {
- background-color: #eee;
-}
-
-div.warning {
- background-color: #ffe4e4;
- border: 1px solid #f66;
-}
-
-p.admonition-title {
- display: inline;
-}
-
-p.admonition-title:after {
- content: ":";
-}
-
-pre {
- padding: 5px;
- background-color: #eeffcc;
- color: #333333;
- line-height: 120%;
- border: 1px solid #ac9;
- border-left: none;
- border-right: none;
-}
-
-tt {
- background-color: #ecf0f3;
- padding: 0 1px 0 1px;
- font-size: 0.95em;
-}
-
-th {
- background-color: #ede;
-}
-
-.warning tt {
- background: #efc2c2;
-}
-
-.note tt {
- background: #d6d6d6;
-}
-
-.viewcode-back {
- font-family: sans-serif;
-}
-
-div.viewcode-block:target {
- background-color: #f4debf;
- border-top: 1px solid #ac9;
- border-bottom: 1px solid #ac9;
-}
\ No newline at end of file
diff --git a/docs/extensions/abbreviations.md b/docs/extensions/abbreviations.md
new file mode 100644
index 000000000..d580d5646
--- /dev/null
+++ b/docs/extensions/abbreviations.md
@@ -0,0 +1,45 @@
+title: Abbreviations Extension
+
+Abbreviations
+=============
+
+Summary
+-------
+
+The Abbreviations extension adds the ability to define abbreviations.
+Specifically, any defined abbreviation is wrapped in an `` tag.
+
+The Abbreviations extension is included in the standard Markdown library.
+
+Syntax
+------
+
+Abbreviations are defined using the syntax established in
+[PHP Markdown Extra][php].
+
+[php]: http://www.michelf.com/projects/php-markdown/extra/#abbr
+
+Thus, the following text (taken from the above referenced PHP documentation):
+
+```md
+The HTML specification
+is maintained by the W3C.
+
+*[HTML]: Hyper Text Markup Language
+*[W3C]: World Wide Web Consortium
+```
+
+will be rendered as:
+
+```html
+
`), then it
-appends that block to the previous code block rather than creating a new
+appends that block to the previous code block rather than creating a new
code block.
Each Blockprocessor has the following utility methods available:
-* **`lastChild(parent)`**:
+* **`lastChild(parent)`**:
Returns the last child of the given ElementTree Element or `None` if it
had no children.
-* **`detab(text)`**:
+* **`detab(text)`**:
Removes one level of indent (four spaces by default) from the front of each
line of the given text string.
-* **`looseDetab(text, level)`**:
+* **`looseDetab(text, level)`**:
- Removes "level" levels of indent (defaults to 1) from the front of each line
- of the given text string. However, this methods allows secondary lines to
+ Removes "level" levels of indent (defaults to 1) from the front of each line
+ of the given text string. However, this methods allows secondary lines to
not be indented as does some parts of the Markdown syntax.
Each Blockprocessor also has a pointer to the containing BlockParser instance at
@@ -268,19 +268,19 @@ stack is an instance of the `State` class.
**`State`** is a subclass of `list` and has the additional methods:
-* **`set(state)`**:
+* **`set(state)`**:
- Set a new state to string `state`. The new state is appended to the end
+ Set a new state to string `state`. The new state is appended to the end
of the stack.
-* **`reset()`**:
+* **`reset()`**:
- Step back one step in the stack. The last state at the end is removed from
+ Step back one step in the stack. The last state at the end is removed from
the stack.
-* **`isstate(state)`**:
+* **`isstate(state)`**:
- Test that the top (current) level of the stack is of the given string
+ Test that the top (current) level of the stack is of the given string
`state`.
Note that to ensure that the state stack does not become corrupted, each time a
@@ -290,24 +290,24 @@ parsing that block.
An instance of the **`BlockParser`** is found at `Markdown.parser`.
`BlockParser` has the following methods:
-* **`parseDocument(lines)`**:
+* **`parseDocument(lines)`**:
- Given a list of lines, an ElementTree object is returned. This should be
- passed an entire document and is the only method the `Markdown` class
+ Given a list of lines, an ElementTree object is returned. This should be
+ passed an entire document and is the only method the `Markdown` class
calls directly.
-* **`parseChunk(parent, text)`**:
+* **`parseChunk(parent, text)`**:
- Parses a chunk of markdown text composed of multiple blocks and attaches
- those blocks to the `parent` Element. The `parent` is altered in place
- and nothing is returned. Extensions would most likely use this method for
+ Parses a chunk of markdown text composed of multiple blocks and attaches
+ those blocks to the `parent` Element. The `parent` is altered in place
+ and nothing is returned. Extensions would most likely use this method for
block parsing.
-* **`parseBlocks(parent, blocks)`**:
+* **`parseBlocks(parent, blocks)`**:
Parses a list of blocks of text and attaches those blocks to the `parent`
- Element. The `parent` is altered in place and nothing is returned. This
- method will generally only be used internally to recursively parse nested
+ Element. The `parent` is altered in place and nothing is returned. This
+ method will generally only be used internally to recursively parse nested
blocks of text.
While is is not recommended, an extension could subclass or completely replace
@@ -315,91 +315,97 @@ the `BlockParser`. The new class would have to provide the same public API.
However, be aware that other extensions may expect the core parser provided
and will not work with such a drastically different parser.
-Working with the ElementTree {: #working_with_et }
---------------------------------------------------
+## Working with the ElementTree {: #working_with_et }
-As mentioned, the Markdown parser converts a source document to an
-[ElementTree][ElementTree] object before serializing that back to Unicode text.
-Markdown has provided some helpers to ease that manipulation within the context
+As mentioned, the Markdown parser converts a source document to an
+[ElementTree][ElementTree] object before serializing that back to Unicode text.
+Markdown has provided some helpers to ease that manipulation within the context
of the Markdown module.
-First, to get access to the ElementTree module import ElementTree from
-`markdown` rather than importing it directly. This will ensure you are using
-the same version of ElementTree as markdown. The module is found at
+First, to get access to the ElementTree module import ElementTree from
+`markdown` rather than importing it directly. This will ensure you are using
+the same version of ElementTree as markdown. The module is found at
`markdown.util.etree` within Markdown.
- from markdown.util import etree
-
-`markdown.util.etree` tries to import ElementTree from any known location,
-first as a standard library module (from `xml.etree` in Python 2.5), then as
-a third party package (ElementTree). In each instance, `cElementTree` is
-tried first, then ElementTree if the faster C implementation is not
+```python
+from markdown.util import etree
+```
+
+`markdown.util.etree` tries to import ElementTree from any known location,
+first as a standard library module (from `xml.etree` in Python 2.5), then as
+a third party package (ElementTree). In each instance, `cElementTree` is
+tried first, then ElementTree if the faster C implementation is not
available on your system.
-Sometimes you may want text inserted into an element to be parsed by
+Sometimes you may want text inserted into an element to be parsed by
[Inline Patterns][]. In such a situation, simply insert the text as you normally
-would and the text will be automatically run through the Inline Patterns.
+would and the text will be automatically run through the Inline Patterns.
However, if you do *not* want some text to be parsed by Inline Patterns,
then insert the text as an `AtomicString`.
- from markdown.util import AtomicString
- some_element.text = AtomicString(some_text)
+```python
+from markdown.util import AtomicString
+some_element.text = AtomicString(some_text)
+```
-Here's a basic example which creates an HTML table (note that the contents of
+Here's a basic example which creates an HTML table (note that the contents of
the second cell (`td2`) will be run through Inline Patterns latter):
- table = etree.Element("table")
- table.set("cellpadding", "2") # Set cellpadding to 2
- tr = etree.SubElement(table, "tr") # Add child tr to table
- td1 = etree.SubElement(tr, "td") # Add child td1 to tr
- td1.text = markdown.util.AtomicString("Cell content") # Add plain text content
- td2 = etree.SubElement(tr, "td") # Add second td to tr
- td2.text = "*text* with **inline** formatting." # Add markup text
- table.tail = "Text after table" # Add text after table
-
-You can also manipulate an existing tree. Consider the following example which
+```python
+table = etree.Element("table")
+table.set("cellpadding", "2") # Set cellpadding to 2
+tr = etree.SubElement(table, "tr") # Add child tr to table
+td1 = etree.SubElement(tr, "td") # Add child td1 to tr
+td1.text = markdown.util.AtomicString("Cell content") # Add plain text content
+td2 = etree.SubElement(tr, "td") # Add second td to tr
+td2.text = "*text* with **inline** formatting." # Add markup text
+table.tail = "Text after table" # Add text after table
+```
+
+You can also manipulate an existing tree. Consider the following example which
adds a `class` attribute to `` elements:
- def set_link_class(self, element):
- for child in element:
- if child.tag == "a":
- child.set("class", "myclass") #set the class attribute
- set_link_class(child) # run recursively on children
+```python
+def set_link_class(self, element):
+ for child in element:
+ if child.tag == "a":
+ child.set("class", "myclass") #set the class attribute
+ set_link_class(child) # run recursively on children
+```
For more information about working with ElementTree see the ElementTree
-[Documentation](http://effbot.org/zone/element-index.htm)
+[Documentation](http://effbot.org/zone/element-index.htm)
([Python Docs](http://docs.python.org/lib/module-xml.etree.ElementTree.html)).
-Integrating Your Code Into Markdown {: #integrating_into_markdown }
--------------------------------------------------------------------
+## Integrating Your Code Into Markdown {: #integrating_into_markdown }
-Once you have the various pieces of your extension built, you need to tell
-Markdown about them and ensure that they are run in the proper sequence.
+Once you have the various pieces of your extension built, you need to tell
+Markdown about them and ensure that they are run in the proper sequence.
Markdown accepts an `Extension` instance for each extension. Therefore, you
-will need to define a class that extends `markdown.extensions.Extension` and
-over-rides the `extendMarkdown` method. Within this class you will manage
-configuration options for your extension and attach the various processors and
-patterns to the Markdown instance.
-
-It is important to note that the order of the various processors and patterns
-matters. For example, if we replace `http://...` links with `` elements,
-and *then* try to deal with inline HTML, we will end up with a mess.
-Therefore, the various types of processors and patterns are stored within an
-instance of the Markdown class in [OrderedDict][]s. Your `Extension` class
-will need to manipulate those OrderedDicts appropriately. You may insert
-instances of your processors and patterns into the appropriate location in an
-OrderedDict, remove a built-in instance, or replace a built-in instance with
+will need to define a class that extends `markdown.extensions.Extension` and
+over-rides the `extendMarkdown` method. Within this class you will manage
+configuration options for your extension and attach the various processors and
+patterns to the Markdown instance.
+
+It is important to note that the order of the various processors and patterns
+matters. For example, if we replace `http://...` links with `` elements,
+and *then* try to deal with inline HTML, we will end up with a mess.
+Therefore, the various types of processors and patterns are stored within an
+instance of the Markdown class in [OrderedDict][]s. Your `Extension` class
+will need to manipulate those OrderedDicts appropriately. You may insert
+instances of your processors and patterns into the appropriate location in an
+OrderedDict, remove a built-in instance, or replace a built-in instance with
your own.
### `extendMarkdown` {: #extendmarkdown }
-The `extendMarkdown` method of a `markdown.extensions.Extension` class
+The `extendMarkdown` method of a `markdown.extensions.Extension` class
accepts two arguments:
* **`md`**:
- A pointer to the instance of the Markdown class. You should use this to
- access the [OrderedDict][]s of processors and patterns. They are found
+ A pointer to the instance of the Markdown class. You should use this to
+ access the [OrderedDict][]s of processors and patterns. They are found
under the following attributes:
* `md.preprocessors`
@@ -426,23 +432,25 @@ accepts two arguments:
Contains all the various global variables within the markdown module.
!!! Warning
- With access to the above items, theoretically you have the option to
- change anything through various [monkey_patching][] techniques. However,
- you should be aware that the various undocumented parts of markdown may
+ With access to the above items, theoretically you have the option to
+ change anything through various [monkey_patching][] techniques. However,
+ you should be aware that the various undocumented parts of markdown may
change without notice and your monkey_patches may break with a new release.
- Therefore, what you really should be doing is inserting processors and
+ Therefore, what you really should be doing is inserting processors and
patterns into the markdown pipeline. Consider yourself warned!
[monkey_patching]: http://en.wikipedia.org/wiki/Monkey_patch
A simple example:
- from markdown.extensions import Extension
+```python
+from markdown.extensions import Extension
- class MyExtension(Extension):
- def extendMarkdown(self, md, md_globals):
- # Insert instance of 'mypattern' before 'references' pattern
- md.inlinePatterns.add('mypattern', MyPattern(md), '...
This is a paragraph.
+``` The one exception is headers, as they are only ever allowed on one line. - A setext style header {: #setext} - ================================= +```text +A setext style header {: #setext} +================================= - ### A hash style header ### {: #hash } +### A hash style header ### {: #hash } +``` The above results in the following output: -` tags and output. - # Code goes here ... +```md + # Code goes here ... +``` Will result in: @@ -151,21 +156,22 @@ Will result in: Lets see the source for that: -+```html +# Code goes here ... -
+``` !!! Note When no language is defined, the Pygments highlighting engine will try to guess the language (unless `guess_lang` is set to `False`). Upon failure, the same behavior will happen as described above. -Usage ------ +## Usage -See [Extensions](index.html) for general extension usage, specify +See [Extensions](index.md) for general extension usage, specify `markdown.extensions.codehilite` as the name of the extension. -See the [Library Reference](../reference.html#extensions) for information about +See the [Library Reference](../reference.md#extensions) for information about configuring extensions. The following options are provided to configure the output: diff --git a/docs/extensions/definition_lists.md b/docs/extensions/definition_lists.md new file mode 100644 index 000000000..e9f898477 --- /dev/null +++ b/docs/extensions/definition_lists.md @@ -0,0 +1,52 @@ +title: Definition Lists Extension + +Definition Lists +================ + +Summary +------- + +The Definition Lists extension adds the ability to create definition lists in +Markdown documents. + +This extension is included in the standard Markdown library. + +Syntax +------ + +Definition lists are defined using the syntax established in +[PHP Markdown Extra][php]. + +[php]: http://www.michelf.com/projects/php-markdown/extra/#def-list + +Thus, the following text (taken from the above referenced PHP documentation): + +```md +Apple +: Pomaceous fruit of plants of the genus Malus in + the family Rosaceae. + +Orange +: The fruit of an evergreen tree of the genus Citrus. +``` + +will be rendered as: + +```html +# Code goes here ... +
This is true markdown text.
This is true markdown text.
@@ -76,6 +73,7 @@ This is *true* markdown text. ``` ### Nested Markdown Inside HTML Blocks + Nested elements are more sensitive and must be used cautiously. To avoid unexpected results: @@ -84,7 +82,8 @@ unexpected results: * Only have one level of nesting. #### Complex Example: -``` + +```mdThe text of the Example
element.
`` element in the output. Therefore, you should
-define the language as you would a CSS class - ``.language``. For consistency
-with other markdown syntax, the language can *optionally* be wrapped in curly
+In addition to PHP Extra's syntax, you can define the language of the code
+block for use by syntax highlighters etc. The language will be assigned as a
+class attribute of the ```` element in the output. Therefore, you should
+define the language as you would a CSS class - ``.language``. For consistency
+with other markdown syntax, the language can *optionally* be wrapped in curly
brackets:
- ~~~~{.python}
- # python code
- ~~~~
+```md
+~~~~{.python}
+# python code
+~~~~
- ~~~~.html
- HTML Document
- ~~~~
+~~~~.html
+HTML Document
+~~~~
+```
The above will output:
- # python code
-
-
- <p>HTML Document</p>
-
+```html
+# python code
+
+
+<p>HTML Document</p>
+
+```
[GitHub][]'s backtick (`\``) syntax is also supported:
- ```python
- # more python code
- ```
+````md
+```python
+# more python code
+```
+````
[GitHub]: http://github.github.com/github-flavored-markdown/
-### Emphasized Lines ###
+### Emphasized Lines
-If you would like to have your fenced code blocks highlighted with the
+If you would like to have your fenced code blocks highlighted with the
[CodeHilite][] extension, simply enable that extension (remember that
[Pygments][] is its dependency) and the language of your fenced code blocks
will be passed in and highlighted appropriately.
@@ -85,28 +86,31 @@ can also have emphasized certain lines of code.
The lines can be specified with PHP Extra's syntax:
- ~~~~{.python hl_lines="1 3"}
- # This line is emphasized
- # This line isn't
- # This line is emphasized
- ~~~~
+```md
+~~~~{.python hl_lines="1 3"}
+# This line is emphasized
+# This line isn't
+# This line is emphasized
+~~~~
+```
... or with GitHub's:
- ```python hl_lines="1 3"
- # This line is emphasized
- # This line isn't
- # This line is emphasized
- ```
+````md
+```python hl_lines="1 3"
+# This line is emphasized
+# This line isn't
+# This line is emphasized
+```
+````
[CodeHilite]: code_hilite.html
[Pygments]: http://pygments.org/
[colon]: code_hilite.html#colons
-Usage
------
+## Usage
-See [Extensions](index.html) for general extension usage, specify `markdown.extensions.fenced_code`
-as the name of the extension.
+See [Extensions](index.md) for general extension usage, specify
+`markdown.extensions.fenced_code` as the name of the extension.
This extension does not accept any special configuration options.
diff --git a/docs/extensions/footnotes.txt b/docs/extensions/footnotes.md
similarity index 68%
rename from docs/extensions/footnotes.txt
rename to docs/extensions/footnotes.md
index e9b0451f8..c94c2c454 100644
--- a/docs/extensions/footnotes.txt
+++ b/docs/extensions/footnotes.md
@@ -1,8 +1,4 @@
-title: Footnotes Extension
-prev_title: Fenced Code Blocks Extension
-prev_url: fenced_code_blocks.html
-next_title: Tables Extension
-next_url: tables.html
+title: Footnotes Extension
Footnotes
=========
@@ -18,56 +14,59 @@ This extension is included in the standard Markdown library.
Syntax
------
-Python-Markdown's Footnote syntax follows the generally accepted syntax of the
+Python-Markdown's Footnote syntax follows the generally accepted syntax of the
Markdown community at large and almost exactly matches [PHP Markdown Extra][]'s
-implementation of footnotes. The only differences involve a few subtleties in
+implementation of footnotes. The only differences involve a few subtleties in
the output.
[PHP Markdown Extra]: http://michelf.com/projects/php-markdown/extra/#footnotes
Example:
- Footnotes[^1] have a label[^@#$%] and the footnote's content.
+```md
+Footnotes[^1] have a label[^@#$%] and the footnote's content.
- [^1]: This is a footnote content.
- [^@#$%]: A footnote on the label: "@#$%".
+[^1]: This is a footnote content.
+[^@#$%]: A footnote on the label: "@#$%".
+```
-A footnote label must start with a caret `^` and may contain any inline text
+A footnote label must start with a caret `^` and may contain any inline text
(including spaces) between a set of square brackets `[]`. Only the first
caret has any special meaning.
-A footnote content must start with the label followed by a colon and at least
+A footnote content must start with the label followed by a colon and at least
one space. The label used to define the content must exactly match the label used
-in the body (including capitalization and white space). The content would then
-follow the label either on the same line or on the next line. The content may
-contain multiple lines, paragraphs, code blocks, blockquotes and most any other
-markdown syntax. The additional lines must be indented one level (four spaces or
-one tab).
-
-When working with multiple blocks, it may be helpful to start the content on a
-separate line from the label which defines the content. This way the entire block
+in the body (including capitalization and white space). The content would then
+follow the label either on the same line or on the next line. The content may
+contain multiple lines, paragraphs, code blocks, blockquotes and most any other
+markdown syntax. The additional lines must be indented one level (four spaces or
+one tab).
+
+When working with multiple blocks, it may be helpful to start the content on a
+separate line from the label which defines the content. This way the entire block
is indented consistently and any errors are more easily discernible by the author.
- [^1]:
- The first paragraph of the definition.
+```md
+[^1]:
+ The first paragraph of the definition.
- Paragraph two of the definition.
+ Paragraph two of the definition.
- > A blockquote with
- > multiple lines.
+ > A blockquote with
+ > multiple lines.
- a code block
-
- A final paragraph.
+ a code block
+ A final paragraph.
+```
Usage
-----
-See [Extensions](index.html) for general extension usage, specify `markdown.extensions.footnotes`
-as the name of the extension.
+See [Extensions](index.md) for general extension usage, specify
+`markdown.extensions.footnotes` as the name of the extension.
-See the [Library Reference](../reference.html#extensions) for information about
+See the [Library Reference](../reference.md#extensions) for information about
configuring extensions.
The following options are provided to configure the output:
@@ -82,7 +81,7 @@ The following options are provided to configure the output:
* **`UNIQUE_IDS`**:
Whether to avoid collisions across multiple calls to `reset()`. Defaults to
`False`.
-
+
* **`BACKLINK_TEXT`**:
The text string that links from the footnote definition back to the position
in the document. Defaults to `↩`.
diff --git a/docs/extensions/header_id.txt b/docs/extensions/header_id.md
similarity index 76%
rename from docs/extensions/header_id.txt
rename to docs/extensions/header_id.md
index 5557b1b0f..82e8e2cd1 100644
--- a/docs/extensions/header_id.txt
+++ b/docs/extensions/header_id.md
@@ -1,8 +1,4 @@
-title: HeaderId Extension
-prev_title: CodeHilite Extension
-prev_url: code_hilite.html
-next_title: Meta-Data Extension
-next_url: meta_data.html
+title: HeaderId Extension
HeaderId
========
@@ -19,33 +15,37 @@ This extension is included in the standard Markdown library.
This extension is **Pending Deprecation**. The [Table of Contents][toc]
Extension should be used instead, which offers most the features of this
extension and more.
-
-[toc]: toc.html
+
+[toc]: toc.md
Syntax
------
-By default, all headers will automatically have unique `id` attributes
-generated based upon the text of the header (see below to turn this off).
+By default, all headers will automatically have unique `id` attributes
+generated based upon the text of the header (see below to turn this off).
Note this example, in which all three headers would have the same `id`:
- #Header
- #Header
- #Header
+```md
+#Header
+#Header
+#Header
+```
Results in:
- Header
- Header
- Header
+```html
+Header
+Header
+Header
+```
Usage
-----
-See [Extensions](index.html) for general extension usage, specify `markdown.extensions.headerid`
-as the name of the extension.
+See [Extensions](index.md) for general extension usage, specify
+`markdown.extensions.headerid` as the name of the extension.
-See the [Library Reference](../reference.html#extensions) for information about
+See the [Library Reference](../reference.md#extensions) for information about
configuring extensions.
The following options are provided to configure the output:
@@ -55,10 +55,11 @@ The following options are provided to configure the output:
Default: `1`
The `level` setting allows you to automatically adjust the header levels to
- fit within the hierarchy of your HTML templates. For example, suppose the
+ fit within the hierarchy of your HTML templates. For example, suppose the
markdown text for a page should not contain any headers higher than level 3
(``). The following will accomplish that:
+ :::pycon
>>> text = '''
... #Some Header
... ## Next Level'''
@@ -72,10 +73,11 @@ The following options are provided to configure the output:
Default: `True`
- The `forceid` setting turns on or off the automatically generated ids for
+ The `forceid` setting turns on or off the automatically generated ids for
headers that do not have one explicitly defined (using the
- [Attribute List](attr_list.html) extension).
+ [Attribute List](attr_list.md) extension).
+ :::pycon
>>> text = '''
... # Some Header
... # Header with ID # { #foo }'''
@@ -103,24 +105,27 @@ The following options are provided to configure the output:
Using with Meta-Data
--------------------
-The HeaderId extension also supports the [Meta-Data](meta_data.html) extension.
-Please see the documentation for that extension for specifics. The supported
+The HeaderId extension also supports the [Meta-Data](meta_data.md) extension.
+Please see the documentation for that extension for specifics. The supported
meta-data keywords are:
* `header_level`
* `header_forceid`
-When used, the meta-data will override the settings provided through the
-`extension_configs` interface.
+When used, the meta-data will override the settings provided through the
+`extension_configs` interface.
This document:
- header_level: 2
- header_forceid: Off
-
- # A Header
+```md
+header_level: 2
+header_forceid: Off
+# A Header
+```
Will result in the following output:
- A Header
+```html
+A Header
+```
diff --git a/docs/extensions/index.txt b/docs/extensions/index.md
similarity index 70%
rename from docs/extensions/index.txt
rename to docs/extensions/index.md
index ba9527467..34f80848d 100644
--- a/docs/extensions/index.txt
+++ b/docs/extensions/index.md
@@ -1,9 +1,4 @@
-title: Extensions
-prev_title: Command Line
-prev_url: ../cli.html
-next_title: Extra Extension
-next_url: extra.html
-
+title: Extensions
Available Extensions
====================
@@ -14,19 +9,23 @@ actual source files.
To use an extension, pass it to markdown with the `extensions` keyword.
- markdown.markdown(some_text, extensions=[MyExtension(), 'path.to.my.ext', 'markdown.extensions.footnotes'])
+```python
+markdown.markdown(some_text, extensions=[MyExtension(), 'path.to.my.ext', 'markdown.extensions.footnotes'])
+```
-See the [Library Reference](../reference.html#extensions) for more details.
+See the [Library Reference](../reference.md#extensions) for more details.
-From the command line, specify an extension with the `-x` option.
+From the command line, specify an extension with the `-x` option.
- $ python -m markdown -x markdown.extensions.footnotes -x markdown.extensions.tables input.txt > output.html
+```bash
+python -m markdown -x markdown.extensions.footnotes -x markdown.extensions.tables input.txt > output.html
+```
-See the [Command Line docs](../cli.html) or use the `--help` option for more details.
+See the [Command Line docs](../cli.md) or use the `--help` option for more details.
!!! seealso "See Also"
If you would like to write your own extensions, see the
- [Extension API](api.html) for details.
+ [Extension API](api.md) for details.
Officially Supported Extensions
-------------------------------
@@ -57,23 +56,23 @@ Extension | "Name"
[Table of Contents] | `markdown.extensions.toc`
[WikiLinks] | `markdown.extensions.wikilinks`
-[Extra]: extra.html
-[Abbreviations]: abbreviations.html
-[Attribute Lists]: attr_list.html
-[Definition Lists]: definition_lists.html
-[Fenced Code Blocks]: fenced_code_blocks.html
-[Footnotes]: footnotes.html
-[Tables]: tables.html
-[Smart Strong]: smart_strong.html
-[Admonition]: admonition.html
-[CodeHilite]: code_hilite.html
-[HeaderId]: header_id.html
-[Meta-Data]: meta_data.html
-[New Line to Break]: nl2br.html
-[Sane Lists]: sane_lists.html
-[SmartyPants]: smarty.html
-[Table of Contents]: toc.html
-[WikiLinks]: wikilinks.html
+[Extra]: extra.md
+[Abbreviations]: abbreviations.md
+[Attribute Lists]: attr_list.md
+[Definition Lists]: definition_lists.md
+[Fenced Code Blocks]: fenced_code_blocks.md
+[Footnotes]: footnotes.md
+[Tables]: tables.md
+[Smart Strong]: smart_strong.md
+[Admonition]: admonition.md
+[CodeHilite]: code_hilite.md
+[HeaderId]: header_id.md
+[Meta-Data]: meta_data.md
+[New Line to Break]: nl2br.md
+[Sane Lists]: sane_lists.md
+[SmartyPants]: smarty.md
+[Table of Contents]: toc.md
+[WikiLinks]: wikilinks.md
Third Party Extensions
----------------------
diff --git a/docs/extensions/meta_data.txt b/docs/extensions/meta_data.md
similarity index 66%
rename from docs/extensions/meta_data.txt
rename to docs/extensions/meta_data.md
index 4a4fe62ac..36d5e7acb 100644
--- a/docs/extensions/meta_data.txt
+++ b/docs/extensions/meta_data.md
@@ -1,8 +1,4 @@
-title: Meta-Data Extension
-prev_title: HeaderId Extension
-prev_url: header_id.html
-next_title: New Line to Break Extension
-next_url: nl2br.html
+title: Meta-Data Extension
Meta-Data
=========
@@ -23,26 +19,28 @@ This extension is included in the standard Markdown library.
Syntax
------
-Meta-data consists of a series of keywords and values defined at the beginning
+Meta-data consists of a series of keywords and values defined at the beginning
of a markdown document like this:
- Title: My Document
- Summary: A brief description of my document.
- Authors: Waylan Limberg
- John Doe
- Date: October 2, 2007
- blank-value:
- base_url: http://example.com
+```md
+Title: My Document
+Summary: A brief description of my document.
+Authors: Waylan Limberg
+ John Doe
+Date: October 2, 2007
+blank-value:
+base_url: http://example.com
- This is the first paragraph of the document.
+This is the first paragraph of the document.
+```
-The keywords are case-insensitive and may consist of letters, numbers,
-underscores and dashes and must end with a colon. The values consist of
+The keywords are case-insensitive and may consist of letters, numbers,
+underscores and dashes and must end with a colon. The values consist of
anything following the colon on the line and may even be blank.
If a line is indented by 4 or more spaces, that line is assumed to be an
additional line of the value for the previous keyword. A keyword may have as
-many lines as desired.
+many lines as desired.
The first blank line ends all meta-data for the document. Therefore, the first
line of a document must not be blank.
@@ -59,36 +57,38 @@ by Markdown.
Usage
-----
-See [Extensions](index.html) for general extension usage, specify `markdown.extensions.meta`
-as the name of the extension.
+See [Extensions](index.md) for general extension usage, specify
+`markdown.extensions.meta` as the name of the extension.
Accessing the Meta-Data
-----------------------
-The meta-data is made available as a python Dict in the `Meta` attribute of an
+The meta-data is made available as a python Dict in the `Meta` attribute of an
instance of the Markdown class. For example, using the above document:
- >>> md = markdown.Markdown(extensions = ['markdown.extensions.meta'])
- >>> html = md.convert(text)
- >>> # Meta-data has been stripped from output
- >>> print html
-
This is the first paragraph of the document.
-
- >>> # View meta-data
- >>> print md.Meta
- {
- 'title' : ['My Document'],
- 'summary' : ['A brief description of my document.'],
- 'authors' : ['Waylan Limberg', 'John Doe'],
- 'date' : ['October 2, 2007'],
- 'blank-value' : [''],
- 'base_url' : ['http://example.com']
- }
-
-Note that the keys are all lowercase and the values consist of a list of
-strings where each item is one line for that key. This way, one could preserve
-line breaks if desired. Or the items could be joined where appropriate. No
-assumptions are made regarding the data. It is simply passed as found to the
+```pycon
+>>> md = markdown.Markdown(extensions = ['markdown.extensions.meta'])
+>>> html = md.convert(text)
+>>> # Meta-data has been stripped from output
+>>> print html
+This is the first paragraph of the document.
+
+>>> # View meta-data
+>>> print md.Meta
+{
+'title' : ['My Document'],
+'summary' : ['A brief description of my document.'],
+'authors' : ['Waylan Limberg', 'John Doe'],
+'date' : ['October 2, 2007'],
+'blank-value' : [''],
+'base_url' : ['http://example.com']
+}
+```
+
+Note that the keys are all lowercase and the values consist of a list of
+strings where each item is one line for that key. This way, one could preserve
+line breaks if desired. Or the items could be joined where appropriate. No
+assumptions are made regarding the data. It is simply passed as found to the
`Meta` attribute.
Perhaps the meta-data could be passed into a template system, or used by
@@ -98,14 +98,13 @@ the developer.
Compatible Extensions
---------------------
-The following extensions are currently known to work with the Meta-Data
+The following extensions are currently known to work with the Meta-Data
extension. The keywords they are known to support are also listed.
-* [HeaderId](header_id.html)
+* [HeaderId](header_id.md)
* `header_level`
* `header_forceid`
-* [WikiLinks](wikilinks.html)
+* [WikiLinks](wikilinks.md)
* `wiki_base_url`
* `wiki_end_url`
* `wiki_html_class`
-
diff --git a/docs/extensions/nl2br.md b/docs/extensions/nl2br.md
new file mode 100644
index 000000000..4f5e611d9
--- /dev/null
+++ b/docs/extensions/nl2br.md
@@ -0,0 +1,35 @@
+title: New Line to Break Extension
+
+New-Line-to-Break Extension
+===========================
+
+Summary
+-------
+
+The New-Line-to-Break (`nl2b`) Extension will cause newlines to be treated as
+hard breaks; like StackOverflow and [GitHub][] flavored Markdown do.
+
+[Github]: http://github.github.com/github-flavored-markdown/
+
+Example
+-------
+
+```pycon
+>>> import markdown
+>>> text = """
+... Line 1
+... Line 2
+... """
+>>> html = markdown.markdown(text, extensions=['markdown.extensions.nl2br'])
+>>> print html
+Line 1
+Line 2
+```
+
+Usage
+-----
+
+See [Extensions](index.md) for general extension usage, specify
+`markdown.extensions.nl2br` as the name of the extension.
+
+This extension does not accept any special configuration options.
diff --git a/docs/extensions/nl2br.txt b/docs/extensions/nl2br.txt
deleted file mode 100644
index 8ba27c8f9..000000000
--- a/docs/extensions/nl2br.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-title: New Line to Break Extension
-prev_title: Meta-Data Extension
-prev_url: meta_data.html
-next_title: Sane Lists Extension
-next_url: sane_lists.html
-
-New-Line-to-Break Extension
-===========================
-
-Summary
--------
-
-The New-Line-to-Break (`nl2b`) Extension will cause newlines to be treated as hard breaks; like
-StackOverflow and [GitHub][] flavored Markdown do.
-
-[Github]: http://github.github.com/github-flavored-markdown/
-
-Example
--------
-
- >>> import markdown
- >>> text = """
- ... Line 1
- ... Line 2
- ... """
- >>> html = markdown.markdown(text, extensions=['markdown.extensions.nl2br'])
- >>> print html
- Line 1
- Line 2
-
-Usage
------
-
-See [Extensions](index.html) for general extension usage, specify `markdown.extensions.nl2br`
-as the name of the extension.
-
-This extension does not accept any special configuration options.
diff --git a/docs/extensions/sane_lists.txt b/docs/extensions/sane_lists.md
similarity index 54%
rename from docs/extensions/sane_lists.txt
rename to docs/extensions/sane_lists.md
index 8f713d0a7..49a7a85bf 100644
--- a/docs/extensions/sane_lists.txt
+++ b/docs/extensions/sane_lists.md
@@ -1,8 +1,4 @@
-title: Sane Lists Extension
-prev_title: New Line to Break Extension
-prev_url: nl2br.html
-next_title: SmartyPants Extension
-next_url: smarty.html
+title: Sane Lists Extension
Sane Lists
==========
@@ -22,52 +18,60 @@ Sane Lists do not allow the mixing of list types. In other words, an ordered
list will not continue when an unordered list item is encountered and
vice versa. For example:
- 1. Ordered item 1
- 2. Ordered item 2
+```md
+1. Ordered item 1
+2. Ordered item 2
- * Unordered item 1
- * Unordered item 2
+* Unordered item 1
+* Unordered item 2
+```
will result in the following output:
-
- - Ordered item 1
- - Ordered item 2
-
+```html
+
+ - Ordered item 1
+ - Ordered item 2
+
-
- - Unordered item 1
- - Unordered item 2
-
+
+ - Unordered item 1
+ - Unordered item 2
+
+```
Whereas the default Markdown behavior would be to generate an unordered list.
Note that, unlike the default Markdown behavior, if a blank line is not
-included between list items, the different list type is ignored completely.
+included between list items, the different list type is ignored completely.
This corresponds to the behavior of paragraphs. For example:
- A Paragraph.
- * Not a list item.
+```md
+A Paragraph.
+* Not a list item.
- 1. Ordered list item.
- * Not a separate list item.
+1. Ordered list item.
+* Not a separate list item.
+```
With this extension the above will result in the following output:
- A Paragraph.
- * Not a list item.
+```html
+A Paragraph.
+* Not a list item.
-
- - Ordered list item.
- * Not a separate list item.
-
+
+ - Ordered list item.
+ * Not a separate list item.
+
+```
In all other ways, Sane Lists should behave as normal Markdown lists.
Usage
-----
-See [Extensions](index.html) for general extension usage, specify `markdown.extensions.sane_lists`
-as the name of the extension.
+See [Extensions](index.md) for general extension usage, specify
+`markdown.extensions.sane_lists` as the name of the extension.
This extension does not accept any special configuration options.
diff --git a/docs/extensions/smart_strong.md b/docs/extensions/smart_strong.md
new file mode 100644
index 000000000..1fb3c68dc
--- /dev/null
+++ b/docs/extensions/smart_strong.md
@@ -0,0 +1,39 @@
+title: Smart Strong Extension
+
+Smart_Strong
+============
+
+Summary
+-------
+
+The Smart_Strong extension adds smarter handling of double underscores within
+words. This does for double underscores what [smart_emphasis][] does for single
+underscores.
+
+The Smart_Strong extension is included in the standard Markdown library.
+
+[smart_emphasis]: ../reference.md#smart_emphasis
+
+Example
+-------
+
+```pycon
+>>> import markdown
+>>> markdown.markdown('Text with double__underscore__words.', \
+ extensions=['markdown.extensions.smart_strong'])
+u'Text with double__underscore__words.
'
+>>> markdown.markdown('__Strong__ still works.', \
+ extensions=['markdown.extensions.smart_strong'])
+u'Strong still works.
'
+>>> markdown.markdown('__this__works__too__.', \
+ extensions=['markdown.extensions.smart_strong'])
+u'this__works__too.
'
+```
+
+Usage
+-----
+
+See [Extensions](index.md) for general extension usage, specify
+`markdown.extensions.smart_strong` as the name of the extension.
+
+This extension does not accept any special configuration options.
diff --git a/docs/extensions/smart_strong.txt b/docs/extensions/smart_strong.txt
deleted file mode 100644
index e2e545883..000000000
--- a/docs/extensions/smart_strong.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-title: Smart Strong Extension
-prev_title: Tables Extension
-prev_url: tables.html
-next_title: Admonition Extension
-next_url: admonition.html
-
-Smart_Strong
-============
-
-Summary
--------
-
-The Smart_Strong extension adds smarter handling of double underscores within
-words. This does for double underscores what [smart_emphasis][] does for single
-underscores.
-
-The Smart_Strong extension is included in the standard Markdown library.
-
-[smart_emphasis]: ../reference.html#smart_emphasis
-
-Example
--------
-
- >>> import markdown
- >>> markdown.markdown('Text with double__underscore__words.', \
- extensions=['markdown.extensions.smart_strong'])
- u'Text with double__underscore__words.
'
- >>> markdown.markdown('__Strong__ still works.', \
- extensions=['markdown.extensions.smart_strong'])
- u'Strong still works.
'
- >>> markdown.markdown('__this__works__too__.', \
- extensions=['markdown.extensions.smart_strong'])
- u'this__works__too.
'
-
-Usage
------
-
-See [Extensions](index.html) for general extension usage, specify `markdown.extensions.smart_strong`
-as the name of the extension.
-
-This extension does not accept any special configuration options.
diff --git a/docs/extensions/smarty.txt b/docs/extensions/smarty.md
similarity index 71%
rename from docs/extensions/smarty.txt
rename to docs/extensions/smarty.md
index 247658ab2..8c0d8cc12 100644
--- a/docs/extensions/smarty.txt
+++ b/docs/extensions/smarty.md
@@ -1,8 +1,4 @@
title: SmartyPants Extension
-prev_title: Sane Lists Extension
-prev_url: sane_lists.html
-next_title: Table of Contents Extension
-next_url: toc.html
SmartyPants
===========
@@ -23,42 +19,44 @@ ASCII symbol | Replacements | HTML Entities | Substitution Keys
`---` | — | `—` | `'mdash'`
Using the configuration option 'substitutions' you can overwrite the
-default substitutions. Just pass a dict mapping (a subset of) the
+default substitutions. Just pass a dict mapping (a subset of) the
keys to the substitution strings.
-
-For example, one might use the following configuration to get correct quotes for
+
+For example, one might use the following configuration to get correct quotes for
the German language:
- extension_configs = {
- 'markdown.extensions.smarty': {
- 'substitutions': {
- 'left-single-quote': '‚', # sb is not a typo!
- 'right-single-quote': '‘',
- 'left-double-quote': '„',
- 'right-double-quote': '“'
- }
+```python
+extension_configs = {
+ 'markdown.extensions.smarty': {
+ 'substitutions': {
+ 'left-single-quote': '‚', # sb is not a typo!
+ 'right-single-quote': '‘',
+ 'left-double-quote': '„',
+ 'right-double-quote': '“'
}
}
+}
+```
!!! note
- This extension re-implements the Python [SmartyPants]
+ This extension re-implements the Python [SmartyPants]
library by integrating it into the markdown parser.
While this does not provide any additional features,
- it does offer a few advantages. Notably, it will not
- try to work on highlighted code blocks (using the
- [CodeHilite] Extension) like the third party library
+ it does offer a few advantages. Notably, it will not
+ try to work on highlighted code blocks (using the
+ [CodeHilite] Extension) like the third party library
has been known to do.
-
+
[SmartyPants]: http://pythonhosted.org/smartypants/
[CodeHilite]: code_hilite.html
Usage
-----
-See [Extensions](index.html) for general extension usage, specify
+See [Extensions](index.md) for general extension usage, specify
`markdown.extensions.smarty` as the name of the extension.
-See the [Library Reference](../reference.html#extensions) for information about
+See the [Library Reference](../reference.md#extensions) for information about
configuring extensions.
The following options are provided to configure the output:
diff --git a/docs/extensions/tables.md b/docs/extensions/tables.md
new file mode 100644
index 000000000..2bea47078
--- /dev/null
+++ b/docs/extensions/tables.md
@@ -0,0 +1,58 @@
+title: Tables Extension
+
+Tables
+======
+
+Summary
+-------
+
+The Tables extension adds the ability to create tables in Markdown documents.
+
+This extension is included in the standard Markdown library.
+
+Syntax
+------
+
+Tables are defined using the syntax established in [PHP Markdown Extra][php].
+
+[php]: http://www.michelf.com/projects/php-markdown/extra/#table
+
+Thus, the following text (taken from the above referenced PHP documentation):
+
+```md
+First Header | Second Header
+------------- | -------------
+Content Cell | Content Cell
+Content Cell | Content Cell
+```
+
+will be rendered as:
+
+```html
+
+
+
+ First Header
+ Second Header
+
+
+
+
+ Content Cell
+ Content Cell
+
+
+ Content Cell
+ Content Cell
+
+
+
+```
+
+Usage
+-----
+
+See [Extensions](index.md) for general extension usage, specify
+`markdown.extensions.tables` as the name of the extension.
+
+This extension does not accept any special configuration options.
diff --git a/docs/extensions/tables.txt b/docs/extensions/tables.txt
deleted file mode 100644
index 759772a02..000000000
--- a/docs/extensions/tables.txt
+++ /dev/null
@@ -1,58 +0,0 @@
-title: Tables Extension
-prev_title: Footnotes Extension
-prev_url: footnotes.html
-next_title: Smart Strong Extension
-next_url: smart_strong.html
-
-Tables
-======
-
-Summary
--------
-
-The Tables extension adds the ability to create tables in Markdown documents.
-
-This extension is included in the standard Markdown library.
-
-Syntax
-------
-
-Tables are defined using the syntax established in [PHP Markdown Extra][php].
-
-[php]: http://www.michelf.com/projects/php-markdown/extra/#table
-
-Thus, the following text (taken from the above referenced PHP documentation):
-
- First Header | Second Header
- ------------- | -------------
- Content Cell | Content Cell
- Content Cell | Content Cell
-
-will be rendered as:
-
-
-
-
- First Header
- Second Header
-
-
-
-
- Content Cell
- Content Cell
-
-
- Content Cell
- Content Cell
-
-
-
-
-Usage
------
-
-See [Extensions](index.html) for general extension usage, specify `markdown.extensions.tables`
-as the name of the extension.
-
-This extension does not accept any special configuration options.
diff --git a/docs/extensions/toc.txt b/docs/extensions/toc.md
similarity index 61%
rename from docs/extensions/toc.txt
rename to docs/extensions/toc.md
index 2cd1fa15f..a1c583f18 100644
--- a/docs/extensions/toc.txt
+++ b/docs/extensions/toc.md
@@ -1,8 +1,4 @@
-title: Table of Contents Extension
-prev_title: SmartyPants Extension
-prev_url: smarty.html
-next_title: WikiLinks Extension
-next_url: wikilinks.html
+title: Table of Contents Extension
Table of Contents
=================
@@ -18,67 +14,78 @@ This extension is included in the standard Markdown library.
Syntax
------
-By default, all headers will automatically have unique `id` attributes
+By default, all headers will automatically have unique `id` attributes
generated based upon the text of the header. Note this example, in which all
three headers would have the same `id`:
- #Header
- #Header
- #Header
+```md
+#Header
+#Header
+#Header
+```
Results in:
- Header
- Header
- Header
+```html
+Header
+Header
+Header
+```
Place a marker in the document where you would like the Table of Contents to
appear. Then, a nested list of all the headers in the document will replace the
marker. The marker defaults to `[TOC]` so the following document:
- [TOC]
+```md
+[TOC]
- # Header 1
+# Header 1
- ## Header 2
+## Header 2
+```
would generate the following output:
-
+```html
+
- Header 1
- Header 2
-
-Regardless of whether a `marker` is found in the document (or disabled), the Table of
-Contents is available as an attribute (`toc`) on the Markdown class. This allows
-one to insert the Table of Contents elsewhere in their page template. For example:
-
- >>> md = markdown.Markdown(extensions=['markdown.extensions.toc'])
- >>> html = md.convert(text)
- >>> page = render_some_template(context={'body': html, 'toc': md.toc})
+
+
+Header 1
+Header 2
+```
+
+Regardless of whether a `marker` is found in the document (or disabled), the
+Table of Contents is available as an attribute (`toc`) on the Markdown class.
+This allows one to insert the Table of Contents elsewhere in their page
+template. For example:
+
+```pycon
+>>> md = markdown.Markdown(extensions=['markdown.extensions.toc'])
+>>> html = md.convert(text)
+>>> page = render_some_template(context={'body': html, 'toc': md.toc})
+```
Usage
-----
-See [Extensions](index.html) for general extension usage, specify `markdown.extensions.toc`
+See [Extensions](index.md) for general extension usage, specify `markdown.extensions.toc`
as the name of the extension.
-See the [Library Reference](../reference.html#extensions) for information about
+See the [Library Reference](../reference.md#extensions) for information about
configuring extensions.
The following options are provided to configure the output:
* **`marker`**:
Text to find and replace with the Table of Contents. Defaults to `[TOC]`.
-
- Set to an empty string to disable searching for a marker, which may save some time,
- especially on long documents.
+
+ Set to an empty string to disable searching for a marker, which may save
+ some time, especially on long documents.
* **`title`**:
Title to insert in the Table of Contents' ``. Defaults to `None`.
@@ -89,18 +96,20 @@ The following options are provided to configure the output:
* **`permalink`**:
Set to `True` or a string to generate permanent links at the end of each header.
Useful with Sphinx style sheets.
-
- When set to `True` the paragraph symbol (¶ or "`¶`") is used as the link
- text. When set to a string, the provided string is used as the link text.
+
+ When set to `True` the paragraph symbol (¶ or "`¶`") is used as
+ the link text. When set to a string, the provided string is used as the link
+ text.
* **`baselevel`**:
Base level for headers. Defaults to `1`.
- The `baselevel` setting allows the header levels to be automatically adjusted to
- fit within the hierarchy of your HTML templates. For example, suppose the
- Markdown text for a page should not contain any headers higher than level 3
- (``). The following will accomplish that:
+ The `baselevel` setting allows the header levels to be automatically
+ adjusted to fit within the hierarchy of your HTML templates. For example,
+ suppose the Markdown text for a page should not contain any headers higher
+ than level 3 (``). The following will accomplish that:
+ :::pycon
>>> text = '''
... #Some Header
... ## Next Level'''
@@ -124,4 +133,4 @@ The following options are provided to configure the output:
The callable must return a string appropriate for use in HTML `id` attributes.
* **`separator`**:
- Word separator. Character which replaces white space in id. Defaults to "`-`".
\ No newline at end of file
+ Word separator. Character which replaces white space in id. Defaults to "`-`".
diff --git a/docs/extensions/wikilinks.txt b/docs/extensions/wikilinks.md
similarity index 59%
rename from docs/extensions/wikilinks.txt
rename to docs/extensions/wikilinks.md
index 948b957f8..a46265a5c 100644
--- a/docs/extensions/wikilinks.txt
+++ b/docs/extensions/wikilinks.md
@@ -1,14 +1,8 @@
-title: WikiLinks Extension
-prev_title: Table of Contents Extension
-prev_url: toc.html
-next_title: Extension API
-next_url: api.html
+title: WikiLinks Extension
-WikiLinks
-=========
+# WikiLinks
-Summary
--------
+## Summary
The WikiLinks extension adds support for [WikiLinks][]. Specifically, any
``[[bracketed]]`` word is converted to a link.
@@ -17,17 +11,20 @@ This extension is included in the standard Markdown library.
[WikiLinks]: http://en.wikipedia.org/wiki/Wikilink
-Syntax
-------
+## Syntax
A ``[[bracketed]]`` word is any combination of upper or lower case letters,
number, dashes, underscores and spaces surrounded by double brackets. Therefore
- [[Bracketed]]
+```md
+[[Bracketed]]
+```
would produce the following HTML:
- Bracketed
+```html
+Bracketed
+```
Note that WikiLinks are automatically assigned `class="wikilink"` making it
easy to style WikiLinks differently from other links on a page if one so
@@ -37,19 +34,22 @@ Also note that when a space is used, the space is converted to an underscore in
the link but left as-is in the label. Perhaps an example would illustrate this
best:
- [[Wiki Link]]
+```md
+[[Wiki Link]]
+```
becomes
- Wiki Link
+```html
+Wiki Link
+```
-Usage
------
+## Usage
-See [Extensions](index.html) for general extension usage, specify `markdown.extensions.wikilinks`
-as the name of the extension.
+See [Extensions](index.md) for general extension usage, specify
+`markdown.extensions.wikilinks` as the name of the extension.
-See the [Library Reference](../reference.html#extensions) for information about
+See the [Library Reference](../reference.md#extensions) for information about
configuring extensions.
The default behavior is to point each link to the document root of the current
@@ -72,46 +72,55 @@ The following options are provided to change the default behavior:
* **`build_url`**: Callable which formats the URL from its parts.
-### Examples ###
+### Examples
For an example, let us suppose links should always point to the sub-directory
`/wiki/` and end with `.html`
- >>> from markdown.extensions.wikilinks import WikiLinkExtension
- >>> html = markdown.markdown(text,
- ... extensions=[WikiLinkExtension(base_url='/wiki/', end_url='.html')]
- ... )
+```pycon
+>>> from markdown.extensions.wikilinks import WikiLinkExtension
+>>> html = markdown.markdown(text,
+... extensions=[WikiLinkExtension(base_url='/wiki/', end_url='.html')]
+... )
+```
The above would result in the following link for `[[WikiLink]]`.
- WikiLink
+```html
+WikiLink
+```
If you want to do more that just alter the base and/or end of the URL, you
could also pass in a callable which must accept three arguments (``label``,
``base``, and ``end``). The callable must return the URL in it's entirety.
- >>> def my_url_builder(label, base, end):
- ... # do stuff
- ... return url
- ...
- >>> html = markdown.markdown(text,
- ... extensions=[WikiLinkExtension(build_url=my_url_builder)],
- ... )
+```pycon
+>>> def my_url_builder(label, base, end):
+... # do stuff
+... return url
+...
+>>> html = markdown.markdown(text,
+... extensions=[WikiLinkExtension(build_url=my_url_builder)],
+... )
+```
The option is also provided to change or remove the class attribute.
- >>> html = markdown.markdown(text,
- ... extensions=[WikiLinkExtension(html_class='myclass')]
- ... )
+```pycon
+>>> html = markdown.markdown(text,
+... extensions=[WikiLinkExtension(html_class='myclass')]
+... )
+```
Would cause all WikiLinks to be assigned to the class `myclass`.
- WikiLink
+```html
+WikiLink
+```
-Using with Meta-Data extension
-------------------------------
+## Using with Meta-Data extension
-The WikiLink extension also supports the [Meta-Data](meta_data.html) extension.
+The WikiLink extension also supports the [Meta-Data](meta_data.md) extension.
Please see the documentation for that extension for specifics. The supported
meta-data keywords are:
@@ -124,12 +133,16 @@ When used, the meta-data will override the settings provided through the
This document:
- wiki_base_url: http://example.com/
- wiki_end_url: .html
- wiki_html_class:
+```md
+wiki_base_url: http://example.com/
+wiki_end_url: .html
+wiki_html_class:
- A [[WikiLink]] in the first paragraph.
+A [[WikiLink]] in the first paragraph.
+```
would result in the following output (notice the blank `wiki_html_class`):
-
A WikiLink in the first paragraph.
+```html
+A WikiLink in the first paragraph.
+```
diff --git a/docs/favicon.ico b/docs/favicon.ico
new file mode 100644
index 000000000..c9efc5844
Binary files /dev/null and b/docs/favicon.ico differ
diff --git a/docs/index.txt b/docs/index.md
similarity index 66%
rename from docs/index.txt
rename to docs/index.md
index 92ac2d043..d21b5c5aa 100644
--- a/docs/index.txt
+++ b/docs/index.md
@@ -1,19 +1,16 @@
-next_url: install.html
-next_title: Installation
-prev_title: Table of Contents
-prev_url: siteindex.html
+title: Python-Markdown
Python-Markdown
===============
-This is a Python implementation of John Gruber's
-[Markdown](http://daringfireball.net/projects/markdown/).
+This is a Python implementation of John Gruber's
+[Markdown](http://daringfireball.net/projects/markdown/).
It is almost completely compliant with the reference implementation,
-though there are a few very minor [differences](#differences). See John's
-[Syntax Documentation](http://daringfireball.net/projects/markdown/syntax)
+though there are a few very minor [differences](#differences). See John's
+[Syntax Documentation](http://daringfireball.net/projects/markdown/syntax)
for the syntax rules.
-See the [installation instructions](install.html) to get started.
+See the [installation instructions](install.md) to get started.
Goals
-----
@@ -21,13 +18,13 @@ Goals
The Python-Markdown project is developed with the following goals in mind:
* Maintain a Python 2 *and* Python 3 library (with an optional CLI wrapper)
- suited to use in web server environments (never raise an exception, never
- write to stdout, etc.) as an implementation of the markdown parser that
+ suited to use in web server environments (never raise an exception, never
+ write to stdout, etc.) as an implementation of the markdown parser that
follows the [syntax rules](http://daringfireball.net/projects/markdown/syntax)
- and the behavior of the original (markdown.pl) implementation as reasonably
- as possible (see [differences](#differences) for a few exceptions).
+ and the behavior of the original (markdown.pl) implementation as reasonably as
+ possible (see [differences](#differences) for a few exceptions).
-* Provide an [Extension API](extensions/api.html) which makes it possible
+* Provide an [Extension API](extensions/api.md) which makes it possible
to change and/or extend the behavior of the parser.
Features
@@ -38,78 +35,77 @@ features:
* __International Input__
- Python-Markdown will accept [input](reference.html#text) in any language
- supported by Unicode including bi-directional text. In fact the test suite
+ Python-Markdown will accept [input](reference.md#text) in any language
+ supported by Unicode including bi-directional text. In fact the test suite
includes documents written in Russian and Arabic.
* __Extensions__
- Various [extensions](extensions/index.html) are provided (including
- [extra](extensions/extra.html)) to change and/or extend the base syntax.
- Additionally, a public [Extension API](extensions/api.html) is available
+ Various [extensions](extensions/index.md) are provided (including
+ [extra](extensions/extra.md)) to change and/or extend the base syntax.
+ Additionally, a public [Extension API](extensions/api.md) is available
to write your own extensions.
* __Output Formats__
- Python-Markdown can output documents in HTML4, XHTML and HTML5. See the
- [Library Reference](reference.html#output_format) for details.
+ Python-Markdown can output documents with either HTML or XHTML styel tags.
+ See the [Library Reference](reference.md#output_format) for details.
* __Command Line Interface__
- In addition to being a Python Library, a
- [command line script](cli.html) is available for your convenience.
+ In addition to being a Python Library, a
+ [command line script](cli.md) is available for your convenience.
Differences
-----------
-While Python-Markdown strives to fully implement markdown as described in the
-[syntax rules](http://daringfireball.net/projects/markdown/syntax), the rules
-can be interpreted in different ways and different implementations
-occasionally vary in their behavior (see the
+While Python-Markdown strives to fully implement markdown as described in the
+[syntax rules](http://daringfireball.net/projects/markdown/syntax), the rules
+can be interpreted in different ways and different implementations
+occasionally vary in their behavior (see the
[Babelmark FAQ](http://johnmacfarlane.net/babelmark2/faq.html#what-are-some-examples-of-interesting-divergences-between-implementations)
-for some examples). Known and intentional differences found in Python-Markdown
+for some examples). Known and intentional differences found in Python-Markdown
are summarized below:
* __Middle-Word Emphasis__
Python-Markdown defaults to ignoring middle-word emphasis. In other words,
`some_long_filename.txt` will not become `somelongfilename.txt`.
- This can be switched off if desired. See the
- [Library Reference](reference.html#smart_emphasis) for details.
+ This can be switched off if desired. See the
+ [Library Reference](reference.md#smart_emphasis) for details.
* __Indentation/Tab Length__
- The [syntax rules](http://daringfireball.net/projects/markdown/syntax#list)
- clearly state that when a list item consists of multiple paragraphs, "each
- subsequent paragraph in a list item **must** be indented by either 4 spaces
- or one tab" (emphasis added). However, many implementations do not enforce
- this rule and allow less than 4 spaces of indentation. The implementers of
- Python-Markdown consider it a bug to not enforce this rule.
+ The [syntax rules](http://daringfireball.net/projects/markdown/syntax#list)
+ clearly state that when a list item consists of multiple paragraphs, "each
+ subsequent paragraph in a list item **must** be indented by either 4 spaces
+ or one tab" (emphasis added). However, many implementations do not enforce
+ this rule and allow less than 4 spaces of indentation. The implementers of
+ Python-Markdown consider it a bug to not enforce this rule.
This applies to any block level elements nested in a list, including
- paragraphs, sub-lists, blockquotes, code blocks, etc. They **must** always
+ paragraphs, sub-lists, blockquotes, code blocks, etc. They **must** always
be indented by at least four spaces (or one tab) for each level of nesting.
In the event that one would prefer different behavior,
- [tab_length](reference.html#tab_length) can be set to whatever length is
- desired. Be warned however, as this will affect indentation for all aspects
+ [tab_length](reference.md#tab_length) can be set to whatever length is
+ desired. Be warned however, as this will affect indentation for all aspects
of the syntax (including root level code blocks).
* __Consecutive Lists__
- While the syntax rules are not clear on this, many implementations (including
+ While the syntax rules are not clear on this, many implementations (including
the original) do not end one list and start a second list when the list marker
- (asterisks, pluses, hyphens, and numbers) changes. For consistency,
- Python-Markdown maintains the same behavior with no plans to change in the
- foreseeable future. That said, the [Sane List Extension](extensions/sane_lists.html)
+ (asterisks, pluses, hyphens, and numbers) changes. For consistency,
+ Python-Markdown maintains the same behavior with no plans to change in the
+ foreseeable future. That said, the [Sane List Extension](extensions/sane_lists.md)
is available to provide a less surprising behavior.
-
Support
-------
-You may ask for help and discuss various other issues on the [mailing list][]
+You may ask for help and discuss various other issues on the [mailing list][]
and report bugs on the [bug tracker][].
[mailing list]: http://lists.sourceforge.net/lists/listinfo/python-markdown-discuss
-[bug tracker]: http://github.com/Python-Markdown/markdown/issues
+[bug tracker]: http://github.com/Python-Markdown/markdown/issues
diff --git a/docs/install.txt b/docs/install.md
similarity index 66%
rename from docs/install.txt
rename to docs/install.md
index c01c3b430..d7997973b 100644
--- a/docs/install.txt
+++ b/docs/install.md
@@ -1,8 +1,4 @@
title: Installation
-prev_title: Summary
-prev_url: index.html
-next_title: Library Reference
-next_url: reference.html
Installing Python-Markdown
==========================
@@ -10,21 +6,25 @@ Installing Python-Markdown
The Easy Way
------------
-The easiest way to install Python-Markdown is simply to type one of the
+The easiest way to install Python-Markdown is simply to type one of the
following commands from the command line as an Admin/Root user:
- pip install markdown
+```bash
+pip install markdown
+```
or
- easy_install markdown
+```bash
+easy_install markdown
+```
-That's it! You're ready to [use](reference.html) Python-Markdown. Enjoy!
+That's it! You're ready to [use](reference.md) Python-Markdown. Enjoy!
Installing on Windows {: #windows }
-----------------------------------
-Download the Windows installer (`.exe`) from
+Download the Windows installer (`.exe`) from
[PyPI](http://pypi.python.org/pypi/Markdown)
Double-click the file and follow the instructions.
@@ -33,35 +33,41 @@ If you prefer to manually install Python-Markdown in Windows, download the
Zip file, unzip it, and on the command line in the directory you unzipped to,
run the following command:
- C://path/to/python.exe setup.py install
+```text
+C://path/to/python.exe setup.py install
+```
If you plan to use the provided command line script, you need to make sure your
script directory is on your system path. On a typical Python install of Windows
the Scripts directory is `C:\PythonXX\Scripts\` (were "XX" is the Python version
-number, i.e., "27"). Adjust the path according to your system and add to your
+number, i.e., "27"). Adjust the path according to your system and add to your
system path.
-Installing on *nix Systems {: #linux }
---------------------------------------
+Installing on \*nix Systems {: #linux }
+---------------------------------------
From the command line do the following (where 2.x is the version number):
- wget http://pypi.python.org/packages/source/M/Markdown/Markdown-2.x.tar.gz
- tar xvzf Markdown-2.x.tar.gz
- cd markdown-2.x/
- sudo python setup.py install
+```bash
+wget http://pypi.python.org/packages/source/M/Markdown/Markdown-2.x.tar.gz
+tar xvzf Markdown-2.x.tar.gz
+cd markdown-2.x/
+sudo python setup.py install
+```
See [PyPI](http://pypi.python.org/pypi/Markdown) for all available versions.
Using the Git Repository {: #git }
----------------------------------
-If you're the type that likes to live on the edge, you may want to keep up with
+If you're the type that likes to live on the edge, you may want to keep up with
the latest additions and bug fixes in the repository between releases.
Python-Markdown is maintained in a Git repository on GitHub.com. To
get a copy of Python-Markdown from the repository do the following from the
command line:
- git clone git://github.com/Python-Markdown/markdown.git python-markdown
- cd python-markdown
- python setup.py install
+```bash
+git clone git://github.com/Python-Markdown/markdown.git python-markdown
+cd python-markdown
+python setup.py install
+```
diff --git a/docs/reference.txt b/docs/reference.md
similarity index 58%
rename from docs/reference.txt
rename to docs/reference.md
index b65f2ddf4..7e5a30a98 100644
--- a/docs/reference.txt
+++ b/docs/reference.md
@@ -1,133 +1,139 @@
-title: Library Reference
-prev_title: Installation
-prev_url: install.html
-next_title: Command Line
-next_url: cli.html
+title: Library Reference
-
-Using Markdown as a Python Library
-==================================
+# Using Markdown as a Python Library
First and foremost, Python-Markdown is intended to be a python library module
used by various projects to convert Markdown syntax into HTML.
-The Basics
-----------
+## The Basics
To use markdown as a module:
- import markdown
- html = markdown.markdown(your_text_string)
+```python
+import markdown
+html = markdown.markdown(your_text_string)
+```
-The Details
------------
+## The Details
Python-Markdown provides two public functions ([`markdown.markdown`](#markdown)
-and [`markdown.markdownFromFile`](#markdownFromFile)) both of which wrap the
-public class [`markdown.Markdown`](#Markdown). If you're processing one
+and [`markdown.markdownFromFile`](#markdownFromFile)) both of which wrap the
+public class [`markdown.Markdown`](#Markdown). If you're processing one
document at a time, these functions will serve your needs. However, if you need
-to process multiple documents, it may be advantageous to create a single
-instance of the `markdown.Markdown` class and pass multiple documents through
+to process multiple documents, it may be advantageous to create a single
+instance of the `markdown.Markdown` class and pass multiple documents through
it. If you do use a single instance though, make sure to call the `reset`
method appropriately ([see below](#convert)).
-### `markdown.markdown (text [, **kwargs])` {: #markdown }
+### markdown.markdown(text [, **kwargs]) {: #markdown }
The following options are available on the `markdown.markdown` function:
-* __`text`__{: #text } (required): The source Unicode string.
+__text__{: #text }
+
+: The source Unicode string. (required)
!!! note "Important"
Python-Markdown expects **Unicode** as input (although
some simple ASCII strings *may* work) and returns output as Unicode.
- Do not pass encoded strings to it! If your input is encoded, (e.g. as
+ Do not pass encoded strings to it! If your input is encoded, (e.g. as
UTF-8), it is your responsibility to decode it. For example:
+ :::python
input_file = codecs.open("some_file.txt", mode="r", encoding="utf-8")
text = input_file.read()
html = markdown.markdown(text)
If you want to write the output to disk, you *must* encode it yourself:
- output_file = codecs.open("some_file.html", "w",
- encoding="utf-8",
+ :::python
+ output_file = codecs.open("some_file.html", "w",
+ encoding="utf-8",
errors="xmlcharrefreplace"
)
output_file.write(html)
-* __`extensions`__{: #extensions }: A list of extensions.
+__extensions__{: #extensions }
+
+: A list of extensions.
- Python-Markdown provides an [API](extensions/api.html) for third parties to
+ Python-Markdown provides an [API](extensions/api.md) for third parties to
write extensions to the parser adding their own additions or changes to the
- syntax. A few commonly used extensions are shipped with the markdown
- library. See the [extension documentation](extensions/index.html) for a
+ syntax. A few commonly used extensions are shipped with the markdown
+ library. See the [extension documentation](extensions/index.md) for a
list of available extensions.
- The list of extensions may contain instances of extensions and/or strings
- of extension names.
+ The list of extensions may contain instances of extensions and/or strings
+ of extension names.
+ :::python
extensions=[MyExtension(), 'path.to.my.ext']
-
+
!!! note
The preferred method is to pass in an instance of an extension. Strings
- should only be used when it is impossible to import the Extension Class
- directly (from the command line or in a template).
-
+ should only be used when it is impossible to import the Extension Class
+ directly (from the command line or in a template).
+
When passing in extension instances, each class instance must be a subclass
- of `markdown.extensions.Extension` and any configuration options should be
- defined when initiating the class instance rather than using the
+ of `markdown.extensions.Extension` and any configuration options should be
+ defined when initiating the class instance rather than using the
[`extension_configs`](#extension_configs) keyword. For example:
+ :::python
from markdown.extensions import Extension
class MyExtension(Extension):
# define your extension here...
-
+
markdown.markdown(text, extensions=[MyExtension(option='value')])
- If an extension name is provided as a string, the extension must be
- importable as a python module on your PYTHONPATH. Python's dot notation is
- supported. Therefore, to import the 'extra' extension, one could do
- `extensions=['markdown.extensions.extra']`
+ If an extension name is provided as a string, the extension must be
+ importable as a python module on your PYTHONPATH. Python's dot notation is
+ supported. Therefore, to import the 'extra' extension, one could do
+ `extensions=['markdown.extensions.extra']`
+
+ Additionally, a Class may be specified in the name. The class must be at the
+ end of the name and be separated by a colon from the module.
- Additionally, a Class may be specified in the name. The class must be at the end of
- the name and be separated by a colon from the module.
+ Therefore, if you were to import the class like this:
- Therefore, if you were to import the class like this:
-
- from path.to.module import SomeExtensionClass
+ :::python
+ from path.to.module import SomeExtensionClass
- Then the named extension would comprise this string:
+ Then the named extension would comprise this string:
- "path.to.module:SomeExtensionClass"
+ :::python
+ "path.to.module:SomeExtensionClass"
- !!! note
- You should only need to specify the class name if more than one extension
- is defined within the same module. The extensions that come with
- Python-Markdown do *not* need to have the class name specified. However,
- doing so will not effect the behavior of the parser.
+ !!! note
+ You should only need to specify the class name if more than one extension
+ is defined within the same module. The extensions that come with
+ Python-Markdown do *not* need to have the class name specified. However,
+ doing so will not effect the behavior of the parser.
When loading an extension by name (as a string), you may pass in
- configuration settings to the extension using the
+ configuration settings to the extension using the
[`extension_configs`](#extension_configs) keyword.
!!! seealso "See Also"
- See the documentation of the [Extension API](extensions/api.html) for
+ See the documentation of the [Extension API](extensions/api.md) for
assistance in creating extensions.
-* __`extension_configs`__{: #extension_configs }: A dictionary of
- configuration settings for extensions.
+__extension_configs__{: #extension_configs }
+
+: A dictionary of configuration settings for extensions.
+
+ Any configuration settings will only be passed to extensions loaded by name
+ (as a string). When loading extensions as class instances, pass the
+ configuration settings directly to the class when initializing it.
- Any configuration settings will only be passed to extensions loaded by name
- (as a string). When loading extensions as class instances, pass the
- configuration settings directly to the class when initializing it.
-
!!! Note
The preferred method is to pass in an instance of an extension, which
does not require use of the `extension_configs` keyword at all.
See the [extensions](#extensions) keyword for details.
-
+
The dictionary of configuration settings must be in the following format:
+ :::python
extension_configs = {
'extension_name_1': {
'option_1': 'value_1',
@@ -138,10 +144,12 @@ The following options are available on the `markdown.markdown` function:
}
}
- See the documentation specific to the extension you are using for help in
+ See the documentation specific to the extension you are using for help in
specifying configuration settings for that extension.
-* __`output_format`__{: #output_format }: Format of output.
+__output_format__{: #output_format }:
+
+: Format of output.
Supported formats are:
@@ -155,108 +163,132 @@ The following options are available on the `markdown.markdown` function:
The values can be in either lowercase or uppercase.
!!! warning
- It is suggested that the more specific formats (`"xhtml1"`, `"html5"`, &
- `"html4"`) be used as the more general formats (`"xhtml"` or `"html"`) may
- change in the future if it makes sense at that time.
+ It is suggested that the more specific formats (`"xhtml1"`, `"html5"`, &
+ `"html4"`) be used as the more general formats (`"xhtml"` or `"html"`) may
+ change in the future if it makes sense at that time.
-* __`safe_mode`__{: #safe_mode }: Disallow raw HTML.
+__safe_mode__{: #safe_mode }:
+
+: Disallow raw HTML.
!!! warning
"`safe_mode`" is deprecated and should not be used.
- HTML sanitizers (like [Bleach]) provide a better solution for
- dealing with markdown text submitted by untrusted users.
+ HTML sanitizers (like [Bleach]) provide a better solution for
+ dealing with markdown text submitted by untrusted users.
+ :::python
import markdown
import bleach
html = bleach.clean(markdown.markdown(untrusted_text))
See the [release notes] for more info.
-
-[Bleach]: https://github.com/jsocol/bleach
-[release notes]: release-2.6.html
-
+
The following values are accepted:
- * `False` (Default): Raw HTML is passed through unaltered.
+ `False` (Default):
+
+ : Raw HTML is passed through unaltered.
- * `replace`: Replace all HTML blocks with the text assigned to
- `html_replacement_text` To maintain backward compatibility, setting
- `safe_mode=True` will have the same effect as `safe_mode='replace'`.
+ `replace`:
+
+ : Replace all HTML blocks with the text assigned to
+ `html_replacement_text`. To maintain backward compatibility, setting
+ `safe_mode=True` will have the same effect as `safe_mode='replace'`.
To replace raw HTML with something other than the default, do:
- md = markdown.Markdown(safe_mode='replace',
- html_replacement_text='--RAW HTML NOT ALLOWED--')
+ :::python
+ md = markdown.Markdown(
+ safe_mode='replace',
+ html_replacement_text='--RAW HTML NOT ALLOWED--'
+ )
+
+ `remove`:
- * `remove`: All raw HTML will be completely stripped from the text with
+ : All raw HTML will be completely stripped from the text with
no warning to the author.
- * `escape`: All raw HTML will be escaped and included in the document.
+ `escape`:
+
+ : All raw HTML will be escaped and included in the document.
For example, the following source:
+ :::md
Foo bar.
Will result in the following HTML:
+ :::html
Foo <b>bar</b>.
- !!! Note
- "safe_mode" also alters the default value for the
+ !!! Note
+ "safe_mode" also alters the default value for the
[`enable_attributes`](#enable_attributes) option.
-
-* __`html_replacement_text`__{: #html_replacement_text }: Text used when
- safe_mode is set to `replace`. Defaults to `[HTML_REMOVED]`.
+[Bleach]: https://github.com/jsocol/bleach
+[release notes]: change_log/release-2.6.md
+
+__html_replacement_text__{: #html_replacement_text }:
+
+: Text used when safe_mode is set to `replace`. Defaults to `[HTML_REMOVED]`.
!!! warning
"`html_replacement_text`" is deprecated and should not be used.
See the [release notes] for more info.
-* __`tab_length`__{: #tab_length }: Length of tabs in the source. Default: 4
+__tab_length__{: #tab_length }:
+
+: Length of tabs in the source. Default: 4
-* __`enable_attributes`__{: #enable_attributes}: Enable the conversion of
- attributes. Defaults to `True`, unless [`safe_mode`](#safe_mode) is enabled,
- in which case the default is `False`.
+__enable_attributes__{: #enable_attributes}:
- !!! Note
- `safe_mode` only overrides the default. If `enable_attributes`
+: Enable the conversion of attributes. Defaults to `True`, unless
+ [`safe_mode`](#safe_mode) is enabled, in which case the default is `False`.
+
+ !!! Note
+ `safe_mode` only overrides the default. If `enable_attributes`
is explicitly set, the explicit value is used regardless of `safe_mode`.
However, this could potentially allow an untrusted user to inject
JavaScript into your documents.
-* __`smart_emphasis`__{: #smart_emphasis }: Treat `_connected_words_`
- intelligently Default: True
+__smart_emphasis__{: #smart_emphasis }:
-* __`lazy_ol`__{: #lazy_ol }: Ignore number of first item of ordered lists.
- Default: True
+: Treat `_connected_words_` intelligently Default: True
+
+__lazy_ol__{: #lazy_ol }:
+
+: Ignore number of first item of ordered lists. Default: True
Given the following list:
+ :::md
4. Apples
5. Oranges
6. Pears
- By default markdown will ignore the fact the the first line started
+ By default markdown will ignore the fact the the first line started
with item number "4" and the HTML list will start with a number "1".
If `lazy_ol` is set to `False`, then markdown will output the following
HTML:
+ :::html
- Apples
- Oranges
- Pears
-
### `markdown.markdownFromFile (**kwargs)` {: #markdownFromFile }
-With a few exceptions, `markdown.markdownFromFile` accepts the same options as
-`markdown.markdown`. It does **not** accept a `text` (or Unicode) string.
+With a few exceptions, `markdown.markdownFromFile` accepts the same options as
+`markdown.markdown`. It does **not** accept a `text` (or Unicode) string.
Instead, it accepts the following required options:
-* __`input`__{: #input } (required): The source text file.
+__input__{: #input } (required)
+
+: The source text file.
`input` may be set to one of three options:
@@ -264,7 +296,9 @@ Instead, it accepts the following required options:
* a readable file-like object,
* or `None` (default) which will read from `stdin`.
-* __`output`__{: #output }: The target which output is written to.
+__output__{: #output }
+
+: The target which output is written to.
`output` may be set to one of three options:
@@ -272,54 +306,62 @@ Instead, it accepts the following required options:
* a writable file-like object,
* or `None` (default) which will write to `stdout`.
-* __`encoding`__{: #encoding }: The encoding of the source text file. Defaults
- to `"utf-8"`. The same encoding will always be used for input and output.
- The `xmlcharrefreplace` error handler is used when encoding the output.
+__encoding__{: #encoding }
- !!! Note
+: The encoding of the source text file.
+
+ Defaults to `"utf-8"`. The same encoding will always be used for input and output.
+ The `xmlcharrefreplace` error handler is used when encoding the output.
+
+ !!! Note
This is the only place that decoding and encoding of Unicode
takes place in Python-Markdown. If this rather naive solution does not
meet your specific needs, it is suggested that you write your own code
to handle your encoding/decoding needs.
-### `markdown.Markdown ([**kwargs])` {: #Markdown }
+### markdown.Markdown([**kwargs]) {: #Markdown }
The same options are available when initializing the `markdown.Markdown` class
as on the [`markdown.markdown`](#markdown) function, except that the class does
**not** accept a source text string on initialization. Rather, the source text
string must be passed to one of two instance methods:
-* `Markdown.convert(source)`{: #convert }
+#### Markdown.convert(source) {: #convert }
+
+The `source` text must meet the same requirements as the [`text`](#text)
+argument of the [`markdown.markdown`](#markdown) function.
- The `source` text must meet the same requirements as the [`text`](#text)
- argument of the [`markdown.markdown`](#markdown) function.
+You should also use this method if you want to process multiple strings
+without creating a new instance of the class for each string.
- You should also use this method if you want to process multiple strings
- without creating a new instance of the class for each string.
+```python
+md = markdown.Markdown()
+html1 = md.convert(text1)
+html2 = md.convert(text2)
+```
- md = markdown.Markdown()
- html1 = md.convert(text1)
- html2 = md.convert(text2)
+Depending on which options and/or extensions are being used, the parser may
+need its state reset between each call to `convert`, otherwise performance
+can degrade drastically:
- Depending on which options and/or extensions are being used, the parser may
- need its state reset between each call to `convert`, otherwise performance
- can degrade drastically:
+```python
+html1 = md.convert(text1)
+md.reset()
+html2 = md.convert(text2)
+```
- html1 = md.convert(text1)
- md.reset()
- html2 = md.convert(text2)
-
- To make this easier, you can also chain calls to `reset` together:
-
- html3 = md.reset().convert(text3)
+To make this easier, you can also chain calls to `reset` together:
+```python
+html3 = md.reset().convert(text3)
+```
-* `Markdown.convertFile(**kwargs)`{: #convertFile }
+#### Markdown.convertFile(**kwargs) {: #convertFile }
- The arguments of this method are identical to the arguments of the same
- name on the `markdown.markdownFromFile` function ([`input`](#input),
- [`output`](#output), and [`encoding`](#encoding)). As with the
- [`convert`](#convert) method, this method should be used to
- process multiple files without creating a new instance of the class for
- each document. State may need to be `reset` between each call to
- `convertFile` as is the case with `convert`.
+The arguments of this method are identical to the arguments of the same
+name on the `markdown.markdownFromFile` function ([`input`](#input),
+[`output`](#output), and [`encoding`](#encoding)). As with the
+[`convert`](#convert) method, this method should be used to
+process multiple files without creating a new instance of the class for
+each document. State may need to be `reset` between each call to
+`convertFile` as is the case with `convert`.
diff --git a/docs/release-2.0.1.txt b/docs/release-2.0.1.txt
deleted file mode 100644
index c0b890a91..000000000
--- a/docs/release-2.0.1.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-title: Release Notes for v2.0.1
-prev_title: Release Notes for v2.0.2
-prev_url: release-2.0.2.html
-next_title: Release Notes for v2.0
-next_url: release-2.0.html
-
-Python-Markdown 2.0.1 Release Notes
-===================================
-
-Python-Markdown 2.0.1 is a bug-fix release. No new features have been added.
-Most notably, various issues with the command line script have been fixed.
-There have also been a few fixes for minor parsing bugs in some edge cases.
-For a full list of changes, see the git log.
-
-Backwards-incompatible Changes
-------------------------------
-
-Due to various complications in how Python handles command line scripts in
-difference systems and with different installation tools, we were forced to
-rename the command line script to `markdown` (no `.py`). A matching batch
-script will get installed on Windows. Any shell scripts which call
-`markdown.py` will need to be altered to call `markdown` instead.
diff --git a/docs/release-2.0.2.txt b/docs/release-2.0.2.txt
deleted file mode 100644
index 5315c8009..000000000
--- a/docs/release-2.0.2.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-title: Release Notes for v2.0.2
-prev_title: Release Notes for v2.1.0
-prev_url: release-2.1.0.html
-next_title: Release Notes for v2.0.1
-next_url: release-2.0.1.html
-
-Python-Markdown 2.0.2 Release Notes
-===================================
-
-Python-Markdown 2.0.2 is a bug-fix release. No new features have been added.
-Most notably, the setup script has been updated to include a dependency on
-ElementTree on older versions of Python (< 2.5). There have also been a few
-fixes for minor parsing bugs in some edge cases. For a full list of changes,
-see the git log.
-
diff --git a/docs/release-2.1.1.txt b/docs/release-2.1.1.txt
deleted file mode 100644
index 59caf6842..000000000
--- a/docs/release-2.1.1.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-title: Release Notes for v2.1.1
-prev_title: Release Notes for v2.2.0
-prev_url: release-2.2.0.html
-next_title: Release Notes for v2.1.0
-next_url: release-2.1.0.html
-
-Python-Markdown 2.1.1 Release Notes
-===================================
-
-Python-Markdown 2.1.1 is a bug-fix release. No new features have been added.
-Most notably, a bug which caused raw HTML paring to run __very__ slowly has
-been fixed along with a few bugs which caused the parser to raise exceptions
-while parsing. For a full list of changes, see the git log.
diff --git a/docs/release-2.2.1.txt b/docs/release-2.2.1.txt
deleted file mode 100644
index fe27c71f9..000000000
--- a/docs/release-2.2.1.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-title: Release Notes for v2.2.1
-prev_title: Release Notes for v2.3
-prev_url: release-2.3.html
-next_title: Release Notes for v2.2.0
-next_url: release-2.2.0.html
-
-Python-Markdown 2.2.1 Release Notes
-===================================
-
-Python-Markdown 2.2.1 is a bug-fix release. No new features have been added.
-However, at least one bug fix does not work in Python 2.4 so that version of
-Python is no longer supported. For a full list of changes, see the git log.
diff --git a/docs/release-2.3.txt b/docs/release-2.3.txt
deleted file mode 100644
index 81c5d888e..000000000
--- a/docs/release-2.3.txt
+++ /dev/null
@@ -1,88 +0,0 @@
-title: Release Notes for v2.3
-prev_title: Release Notes for v2.4
-prev_url: release-2.4.html
-next_title: Release Notes for v2.2.1
-next_url: release-2.2.1.html
-
-Python-Markdown 2.3 Release Notes
-=================================
-
-We are pleased to release Python-Markdown 2.3 which adds one new extension,
-removes a few old (obsolete) extensions, and now runs on both Python 2 and
-Python 3 without running the 2to3 conversion tool. See the list of changes
-below for details.
-
-Python-Markdown supports Python versions 2.6, 2.7, 3.1, 3.2, and 3.3.
-
-Backwards-incompatible Changes
-------------------------------
-
-* Support has been dropped for Python 2.5. No guarantees are made that the
-library will work in any version of Python lower than 2.6. As all supported
-Python versions include the ElementTree library, Python-Markdown will no
-longer try to import a third-party installation of ElementTree.
-
-* All classes are now "new-style" classes. In other words, all classes
-subclass from 'object'. While this is not likely to affect most users,
-extension authors may need to make a few minor adjustments to their code.
-
-* "safe_mode" has been further restricted. Markdown formatted links must be
-of a known white-listed scheme when in "safe_mode" or the URL is discarded.
-The white-listed schemes are: 'HTTP', 'HTTPS', 'FTP', 'FTPS', 'MAILTO', and
-'news'. Schemeless URLs are also permitted, but are checked in other ways -
-as they have been for some time.
-
-* The ids assigned to footnotes now contain a dash (`-`) rather than a colon
-(`:`) when `output_format` it set to `"html5"` or `"xhtml5"`. If you are making
-reference to those ids in your JavaScript or CSS and using the HTML5 output,
-you will need to update your code accordingly. No changes are necessary if
-you are outputting XHTML (the default) or HTML4.
-
-* The `force_linenos` configuration setting of the CodeHilite extension has been
-marked as **Pending Deprecation** and a new setting `linenums` has been added to
-replace it. See documentation for the [CodeHilite Extension] for an explanation
-of the new `linenums` setting. The new setting will honor the old
-`force_linenos` if it is set, but it will raise a `PendingDeprecationWarning`
-and will likely be removed in a future version of Python-Markdown.
-
-[CodeHilite Extension]: extensions/codehilite.html
-
-* The "RSS" extension has been removed and no longer ships with Python-Markdown.
-If you would like to continue using the extension (not recommended), it is
-archived on [GitHub](https://gist.github.com/waylan/4773365).
-
-* The "HTML Tidy" Extension has been removed and no longer ships with Python-Markdown.
-If you would like to continue using the extension (not recommended), it is
-archived on [GitHub](https://gist.github.com/waylan/5152650). Note that the
-underlying library, uTidylib, is not Python 3 compatible. Instead, it is
-recommended that the newer [PyTidyLib] (version 0.2.2+ for Python 3
-comparability - install from GitHub not PyPI) be used. As the API for that
-library is rather simple, it is recommended that the output of Markdown be
-wrapped in a call to PyTidyLib rather than using an extension (for example:
-`tidylib.tidy_fragment(markdown.markdown(source), options={...})`).
-
-[PyTidyLib]: http://countergram.com/open-source/pytidylib
-
-What's New in Python-Markdown 2.3
----------------------------------
-
-* The entire code base now universally runs in Python 2 and Python 3 without
-any need for running the 2to3 conversion tool. This not only simplifies testing,
-but by using Unicode_literals, results in more consistent behavior across
-Python versions. Additionally, the relative imports (made possible in Python 2
-via absolute_import) allows the entire library to more easily be embedded in a
-sub-directory of another project. The various files within the library will
-still import each other properly even though 'markdown' may not be in Python's
-root namespace.
-
-* The [Admonition Extension] has been added, which implements [rST-style][rST]
-admonitions in the Markdown syntax. However, be warned that this extension
-is experimental and the syntax and behavior is still subject to change. Please
-try it out and report bugs and/or improvements.
-
-[Admonition Extension]: extensions/admonition.html
-[rST]: http://docutils.sourceforge.net/docs/ref/rst/directives.html#specific-admonitions
-
-* Various bug fixes have been made. See the
-[commit log](https://github.com/Python-Markdown/markdown/commits/master)
-for a complete history of the changes.
diff --git a/docs/release-2.4.txt b/docs/release-2.4.txt
deleted file mode 100644
index f1d00af47..000000000
--- a/docs/release-2.4.txt
+++ /dev/null
@@ -1,77 +0,0 @@
-title: Release Notes for v2.4
-prev_title: Release Notes for v2.5
-prev_url: release-2.5.html
-next_title: Release Notes for v2.3
-next_url: release-2.3.html
-
-Python-Markdown 2.4 Release Notes
-=================================
-
-We are pleased to release Python-Markdown 2.4 which adds one new extension
-and fixes various bugs. See the list of changes below for details.
-
-Python-Markdown supports Python versions 2.6, 2.7, 3.1, 3.2, and 3.3.
-
-Backwards-incompatible Changes
-------------------------------
-
-* The `force_linenos` configuration setting of the CodeHilite extension has been
-marked as **Deprecated**. It had previously been marked as "Pending Deprecation"
-in version 2.3 when a new setting `linenums` was added to replace it. See
-documentation for the [CodeHilite Extension] for an explanation of the new
-`linenums` setting. The new setting will honor the old `force_linenos` if it
-is set, but `force_linenos` will raise a `DeprecationWarning` and will likely
-be removed in a future version of Python-Markdown.
-
-[CodeHilite Extension]: extensions/code_hilite.html
-
-* URLs are no longer percent-encoded. This improves compatibility with the
-original (written in Perl) Markdown implementation. Please percent-encode
-your URLs manually when needed.
-
-What's New in Python-Markdown 2.4
----------------------------------
-
-* Thanks to the hard work of [Dmitry Shachnev] the [Smarty Extension] has been
-added, which implements [SmartyPants] using Python-Markdown's Extension API.
-This offers a few benefits over a third party script. The HTML does not need
-to be "tokenized" twice, no hacks are required to combine SmartyPants and
-code highlighting, and we get markdown's escaping feature for free. Please try
-it out and report bugs and/or improvements.
-
-[Dmitry Shachnev]: https://github.com/mitya57
-[Smarty Extension]: extensions/smarty.html
-[SmartyPants]: http://daringfireball.net/projects/smartypants/
-
-* The [Table of Contents Extension] now supports new `permalink` option
-for creating [Sphinx]-style anchor links.
-
-[Table of Contents Extension]: extensions/toc.html
-[Sphinx]: http://sphinx-doc.org/
-
-* It is now possible to enable Markdown formatting inside HTML blocks by
-appending `markdown=1` to opening tag attributes. See [Markdown Inside HTML
-Blocks] section for details. Thanks to [ryneeverett] for implementing this
-feature.
-
-[Markdown Inside HTML Blocks]: extensions/extra.html#nested-markdown-inside-html-blocks
-[ryneeverett]: https://github.com/ryneeverett
-
-* The code blocks now support emphasizing some of the code lines. To use this
-feature, specify `hl_lines` option after language name, for example (using
-the [Fenced Code Extension]):
-
- ```.python hl_lines="1 3"
- # This line will be emphasized.
- # This one won't.
- # This one will be also emphasized.
- ```
-
- Thanks to [A. Jesse Jiryu Davis] for implementing this feature.
-
-[Fenced Code Extension]: extensions/fenced_code_blocks.html
-[A. Jesse Jiryu Davis]: https://github.com/ajdavis
-
-* Various bug fixes have been made. See the
-[commit log](https://github.com/Python-Markdown/markdown/commits/master)
-for a complete history of the changes.
diff --git a/docs/release-2.5.txt b/docs/release-2.5.txt
deleted file mode 100644
index 7cde02f4a..000000000
--- a/docs/release-2.5.txt
+++ /dev/null
@@ -1,187 +0,0 @@
-title: Release Notes for v2.5
-prev_title: Release Notes for v2.6
-prev_url: release-2.6.html
-next_title: Release Notes for v2.4
-next_url: release-2.4.html
-
-Python-Markdown 2.5 Release Notes
-=================================
-
-We are pleased to release Python-Markdown 2.5 which adds a few new features
-and fixes various bugs. See the list of changes below for details.
-
-Python-Markdown version 2.5 supports Python versions 2.7, 3.2, 3.3, and 3.4.
-
-Backwards-incompatible Changes
-------------------------------
-
-* Python-Markdown no longer supports Python version 2.6. You must be using Python
- versions 2.7, 3.2, 3.3, or 3.4.
-
-[importlib]: https://pypi.python.org/pypi/importlib
-
-* The `force_linenos` configuration key on the [CodeHilite Extension] has been **deprecated**
- and will raise a `KeyError` if provided. In the previous release (2.4), it was
- issuing a `DeprecationWarning`. The [`linenums`][linenums] keyword should be used
- instead, which provides more control of the output.
-
-[CodeHilite Extension]: extensions/code_hilite.html
-[linenums]: extensions/code_hilite.html#usage
-
-* Both `safe_mode` and the associated `html_replacement_text` keywords will be deprecated
- in version 2.6 and will raise a **`PendingDeprecationWarning`** in 2.5. The so-called
- "safe mode" was never actually "safe" which has resulted in many people having a false
- sense of security when using it. As an alternative, the developers of Python-Markdown
- recommend that any untrusted content be passed through an HTML sanitizer (like [Bleach])
- after being converted to HTML by markdown.
-
- If your code previously looked like this:
-
- html = markdown.markdown(text, same_mode=True)
-
- Then it is recommended that you change your code to read something like this:
-
- import bleach
- html = bleach.clean(markdown.markdown(text))
-
- If you are not interested in sanitizing untrusted text, but simply desire to escape
- raw HTML, then that can be accomplished through an extension which removes HTML parsing:
-
- from markdown.extensions import Extension
-
- class EscapeHtml(Extension):
- def extendMarkdown(self, md, md_globals):
- del md.preprocessors['html_block']
- del md.inlinePatterns['html']
-
- html = markdown.markdown(text, extensions=[EscapeHtml()])
-
- As the HTML would not be parsed with the above Extension, then the serializer will
- escape the raw HTML, which is exactly what happens now when `safe_mode="escape"`.
-
-[Bleach]: https://bleach.readthedocs.io/
-
-* Positional arguments on the `markdown.Markdown()` are pending deprecation as are
- all except the `text` argument on the `markdown.markdown()` wrapper function.
- Only keyword arguments should be used. For example, if your code previously
- looked like this:
-
- html = markdown.markdown(text, ['extra'])
-
- Then it is recommended that you change it to read something like this:
-
- html = markdown.markdown(text, extensions=['extra'])
-
- !!! Note
- This change is being made as a result of deprecating `"safe_mode"` as the
- `safe_mode` argument was one of the positional arguments. When that argument
- is removed, the two arguments following it will no longer be at the correct
- position. It is recommended that you always use keywords when they are supported
- for this reason.
-
-* In previous versions of Python-Markdown, the built-in extensions received
- special status and did not require the full path to be provided. Additionally,
- third party extensions whose name started with `"mdx_"` received the same
- special treatment. This behavior will be deprecated in version 2.6 and will
- raise a **`PendingDeprecationWarning`** in 2.5. Ensure that you always use the full
- path to your extensions. For example, if you previously did the following:
-
- markdown.markdown(text, extensions=['extra'])
-
- You should change your code to the following:
-
- markdown.markdown(text, extensions=['markdown.extensions.extra'])
-
- The same applies to the command line:
-
- $ python -m markdown -x markdown.extensions.extra input.txt
-
- See the [documentation](reference.html#extensions) for a full explanation
- of the current behavior.
-
-* The previously documented method of appending the extension configuration as
- a string to the extension name will be deprecated in Python-Markdown
- version 2.6 and will raise a **`PendingDeprecationWarning`** in 2.5. The
- [`extension_configs`](reference.html#extension_configs) keyword should
- be used instead. See the [documentation](reference.html#extension-configs)
- for a full explanation of the current behavior.
-
-What's New in Python-Markdown 2.5
----------------------------------
-
-* The [Smarty Extension] has had a number of additional configuration settings
- added, which allows one to define their own substitutions to better support
- languages other than English. Thanks to [Martin Altmayer] for implementing this
- feature.
-
-[Smarty Extension]: extensions/smarty.html
-[Martin Altmayer]:https://github.com/MartinAltmayer
-
-* Named Extensions (strings passed to the [`extensions`][ex] keyword of
- `markdown.Markdown`) can now point to any module and/or Class on your PYTHONPATH.
- While dot notation was previously supported, a module could not be at the root of
- your PYTHONPATH. The name had to contain at least one dot (requiring it to be a
- sub-module). This restriction no longer exists.
-
- Additionally, a Class may be specified in the name. The class must be at the end of
- the name (which uses dot notation from PYTHONPATH) and be separated by a colon from
- the module.
-
- Therefore, if you were to import the class like this:
-
- from path.to.module import SomeExtensionClass
-
- Then the named extension would comprise this string:
-
- "path.to.module:SomeExtensionClass"
-
- This allows multiple extensions to be implemented within the same module and still
- accessible when the user is not able to import the extension directly (perhaps from
- a template filter or the command line).
-
- This also means that extension modules are no longer required to include the
- `makeExtension` function which returns an instance of the extension class. However,
- if the user does not specify the class name (she only provides `"path.to.module"`)
- the extension will fail to load without the `makeExtension` function included in
- the module. Extension authors will want to document carefully what is required to
- load their extensions.
-
-[ex]: reference.html#extensions
-
-* The Extension Configuration code has been refactored to make it a little easier
- for extension authors to work with configuration settings. As a result, the
- [`extension_configs`][ec] keyword now accepts a dictionary rather than requiring
- a list of tuples. A list of tuples is still supported so no one needs to change
- their existing code. This should also simplify the learning curve for new users.
-
- Extension authors are encouraged to review the new methods available on the
- `markdown.extnesions.Extension` class for handling configuration and adjust their
- code going forward. The included extensions provide a model for best practices.
- See the [API] documentation for a full explanation.
-
-[ec]: reference.html#extension_configs
-[API]: extensions/api.html#configsettings
-
-* The [Command Line Interface][cli] now accepts a `--extensions_config` (or `-c`)
- option which accepts a file name and passes the parsed content of a [YAML] or
- [JSON] file to the [`extension_configs`][ec] keyword of the `markdown.Markdown`
- class. The contents of the YAML or JSON must map to a Python Dictionary which
- matches the format required by the `extension_configs` keyword. Note that
- [PyYAML] is required to parse YAML files.
-
-[cli]: cli.html#using-extensions
-[YAML]: http://yaml.org/
-[JSON]: http://json.org/
-[PyYAML]: http://pyyaml.org/
-
-* The [admonition extension][ae] is no longer considered "experimental."
-
-[ae]: extensions/admonition.html
-
-* There have been various refactors of the testing framework. While those changes
- will not directly effect end users, the code is being better tested which will
- benefit everyone.
-
-* Various bug fixes have been made. See the
- [commit log](https://github.com/Python-Markdown/markdown/commits/master)
- for a complete history of the changes.
diff --git a/docs/release-2.6.txt b/docs/release-2.6.txt
deleted file mode 100644
index e4501628f..000000000
--- a/docs/release-2.6.txt
+++ /dev/null
@@ -1,263 +0,0 @@
-title: Release Notes for v2.6
-prev_title: Change Log
-prev_url: change_log.html
-next_title: Release Notes for v2.5
-next_url: release-2.5.html
-
-Python-Markdown 2.6 Release Notes
-=================================
-
-We are pleased to release Python-Markdown 2.6 which adds a few new features
-and fixes various bugs. See the list of changes below for details.
-
-Python-Markdown version 2.6 supports Python versions 2.7, 3.2, 3.3, and 3.4 as well as PyPy.
-
-Backwards-incompatible Changes
-------------------------------
-
-### `safe_mode` Deprecated
-
-Both `safe_mode` and the associated `html_replacement_text` keywords are deprecated
-in version 2.6 and will raise a **`DeprecationWarning`**. The `safe_mode` and
-`html_replacement_text` keywords will be ignored in version 2.7. The so-called
-"safe mode" was never actually "safe" which has resulted in many people having a false
-sense of security when using it. As an alternative, the developers of Python-Markdown
-recommend that any untrusted content be passed through an HTML sanitizer (like [Bleach])
-after being converted to HTML by markdown.
-
-If your code previously looked like this:
-
- html = markdown.markdown(text, safe_mode=True)
-
-Then it is recommended that you change your code to read something like this:
-
- import bleach
- html = bleach.clean(markdown.markdown(text))
-
-If you are not interested in sanitizing untrusted text, but simply desire to escape
-raw HTML, then that can be accomplished through an extension which removes HTML parsing:
-
- from markdown.extensions import Extension
-
- class EscapeHtml(Extension):
- def extendMarkdown(self, md, md_globals):
- del md.preprocessors['html_block']
- del md.inlinePatterns['html']
-
- html = markdown.markdown(text, extensions=[EscapeHtml()])
-
-As the HTML would not be parsed with the above Extension, then the serializer will
-escape the raw HTML, which is exactly what happens now when `safe_mode="escape"`.
-
-[Bleach]: https://bleach.readthedocs.io/
-
-### Positional Arguments Deprecated
-
-Positional arguments on the `markdown.Markdown()` class are deprecated as are
-all except the `text` argument on the `markdown.markdown()` wrapper function.
-Using positional arguments will raise a **`DeprecationWarning`** in 2.6 and an error
-in version 2.7. Only keyword arguments should be used. For example, if your code
-previously looked like this:
-
- html = markdown.markdown(text, [SomeExtension()])
-
-Then it is recommended that you change it to read something like this:
-
- html = markdown.markdown(text, extensions=[SomeExtension()])
-
-!!! Note
- This change is being made as a result of deprecating `"safe_mode"` as the
- `safe_mode` argument was one of the positional arguments. When that argument
- is removed, the two arguments following it will no longer be at the correct
- position. It is recommended that you always use keywords when they are supported
- for this reason.
-
-### "Shortened" Extension Names Deprecated
-
-In previous versions of Python-Markdown, the built-in extensions received
-special status and did not require the full path to be provided. Additionally,
-third party extensions whose name started with `"mdx_"` received the same
-special treatment. This behavior is deprecated and will raise a
-**`DeprecationWarning`** in version 2.6 and an error in 2.7. Ensure that you
-always use the full path to your extensions. For example, if you previously
-did the following:
-
- markdown.markdown(text, extensions=['extra'])
-
-You should change your code to the following:
-
- markdown.markdown(text, extensions=['markdown.extensions.extra'])
-
-The same applies to the command line:
-
- $ python -m markdown -x markdown.extensions.extra input.txt
-
-Similarly, if you have used a third party extension (for example `mdx_math`), previously
-you might have called it like this:
-
- markdown.markdown(text, extensions=['math'])
-
-As the `"mdx"` prefix will no longer be appended, you will need to change your code
-as follows (assuming the file `mdx_math.py` is installed at the root of your PYTHONPATH):
-
- markdown.markdown(text, extensions=['mdx_math'])
-
-Extension authors will want to update their documentation to reflect the new behavior.
-
-See the [documentation](reference.html#extensions) for a full explanation
-of the current behavior.
-
-### Extension Configuration as Part of Extension Name Deprecated
-
-The previously documented method of appending the extension configuration options as
-a string to the extension name is deprecated and will raise a
-**`DeprecationWarning`** in version 2.6 and an error in 2.7.
-The [`extension_configs`](reference.html#extension_configs) keyword should
-be used instead. See the [documentation](reference.html#extension-configs)
-for a full explanation of the current behavior.
-
-### HeaderId Extension Pending Deprecation
-
-The [HeaderId][hid] Extension is pending deprecation and will raise a
-**`PendingDeprecationWarning`** in version 2.6. The extension will be
-deprecated in version 2.7 and raise an error in version 2.8. Use the
-[Table of Contents][TOC] Extension instead, which offers most of the
-features of the HeaderId Extension and more (support for meta data is missing).
-
-Extension authors who have been using the `slugify` and `unique` functions
-defined in the HeaderId Extension should note that those functions are now
-defined in the Table of Contents extension and should adjust their import
-statements accordingly (`from markdown.extensions.toc import slugify, unique`).
-
-[hid]: extensions/header_id.html
-
-### The `configs` Keyword is Deprecated
-
-Positional arguments and the `configs` keyword on the `markdown.extension.Extension` class
-(and its subclasses) are deprecated. Each individual configuration option should be passed
-to the class as a keyword/value pair. For example. one might have previously initiated
-an extension subclass like this:
-
- ext = SomeExtension(configs={'somekey': 'somevalue'})
-
-That code should be updated to pass in the options directly:
-
- ext = SomeExtension(somekey='somevalue')
-
-Extension authors will want to note that this affects the `makeExtension` function as well.
-Previously it was common for the function to be defined as follows:
-
- def makeExtension(configs=None):
- return SomeExtension(configs=configs)
-
-Extension authors will want to update their code to the following instead:
-
- def makeExtension(**kwargs):
- return SomeExtension(**kwargs)
-
-Failing to do so will result in a **`DeprecationWarning`** and will raise an error in the next
-release. See the [Extension API][mext] documentation for more information.
-
-In the event that an `markdown.extension.Extension` subclass overrides the `__init__` method
-and implements its own configuration handling, then the above may not apply. However, it is
-recommended that the subclass still calls the parent `__init__` method to handle configuration
-options like so:
-
- class SomeExtension(markdown.extension.Extension):
- def __init__(**kwargs):
- # Do pre-config stuff here
- # Set config defaults
- self.config = {
- 'option1' : ['value1', 'description1'],
- 'option2' : ['value2', 'description2']
- }
- # Set user defined configs
- super(MyExtension, self).__init__(**kwargs)
- # Do post-config stuff here
-
-Note the call to `super` to get the benefits of configuration handling from the parent class.
-See the [documentation][config] for more information.
-
-[config]: extensions/api.html#configsettings
-[mext]: extensions/api.html#makeextension
-
-What's New in Python-Markdown 2.6
----------------------------------
-
-### Official Support for PyPy
-
-Official support for [PyPy] has been added. While Python-Markdown has most likely
-worked on PyPy for some time, it is now officially supported and tested on PyPy.
-
-[PyPy]: http://pypy.org/
-
-### YAML Style Meta-Data
-
-The [Meta-Data] Extension now includes optional support for [YAML] style
-meta-data. By default, the YAML deliminators are recognized, however, the
-actual data is parsed as previously. This follows the syntax of
-[MultiMarkdown], which inspired this extension.
-
-Alternatively, if the `yaml` option is set, then the data is parsed as YAML.
-As the `yaml` option was buggy, it was removed in 2.6.1. It is suggested that a third
-party extension be used if you want true YAML support. See [Issue #390][#390] for a full
-explanation.
-
-[MultiMarkdown]: http://fletcherpenney.net/MultiMarkdown_Syntax_Guide#metadata
-[Meta-Data]: extensions/meta_data.html
-[YAML]: http://yaml.org/
-[#390]: https://github.com/Python-Markdown/markdown/issues/390
-
-### Table of Contents Extension Refactored
-
-The [Table of Contents][TOC] Extension has been refactored and some new features
-have been added. See the documentation for a full explanation of each feature
-listed below:
-
-* The extension now assigns the Table of Contents to the `toc` attribute of
- the Markdown class regardless of whether a "marker" was found in the document.
- Third party frameworks no longer need to insert a "marker," run the document
- through Markdown, then extract the Table of Contents from the document.
-
-* The Table of Contents Extension is now a "registered extension." Therefore, when the `reset`
- method of the Markdown class is called, the `toc` attribute on the Markdown
- class is cleared (set to an empty string).
-
-* When the `marker` configuration option is set to an empty string, the parser completely
- skips the process of searching the document for markers. This should save parsing
- time when the Table of Contents Extension is being used only to assign ids to headers.
-
-* A `separator` configuration option has been added allowing users to override the
- separator character used by the slugify function.
-
-* A `baselevel` configuration option has been added allowing users to set the base level
- of headers in their documents (h1-h6). This allows the header levels to be
- automatically adjusted to fit within the hierarchy of an HTML template.
-
-[TOC]: extensions/toc.html
-
-### Pygments can now be disabled
-
-The [CodeHilite][ch] Extension has gained a new configuration option: `use_pygments`.
-The option is `True` by default, however, it allows one to turn off Pygments code
-highlighting (set to `False`) while preserving the language detection features of
-the extension. Note that Pygments language guessing is not used as that would 'use
-Pygments'. If a language is defined for a code block, it will be assigned to the
-`` tag as a class in the manner suggested by the [HTML5 spec][spec]
-(alternate output will not be entertained) and could potentially be used by a JavaScript
-library in the browser to highlight the code block.
-
-[ch]: extensions/code_hilite.html
-[spec]: http://www.w3.org/TR/html5/text-level-semantics.html#the-code-element
-
-### Miscellaneous
-
-Test coverage has been improved including running [flake8]. While those changes
-will not directly effect end users, the code is being better tested which will
-benefit everyone.
-
-[flake8]: https://flake8.readthedocs.io/en/latest/
-
-Various bug fixes have been made. See the
-[commit log](https://github.com/Python-Markdown/markdown/commits/master)
-for a complete history of the changes.
diff --git a/docs/siteindex.txt b/docs/siteindex.txt
deleted file mode 100644
index 0139bd7c8..000000000
--- a/docs/siteindex.txt
+++ /dev/null
@@ -1,78 +0,0 @@
-title: Table of Contents
-prev_title: Authors
-prev_url: authors.html
-next_title: Summary
-next_url: index.html
-
-Table of Contents
-=================
-
-* [Python Markdown](index.html)
- * [Goals](index.html#goals)
- * [Features](index.html#features)
- * [Differences](index.html#differences)
- * [Support](index.html#support)
-* [Installation](install.html)
- * [The Easy Way](install.html#the-easy-way)
- * [Installing on Windows](install.html#windows)
- * [Installing on *nix Systems](install.html#linux)
- * [Using the Git Repository](install.html#git)
- * [Dependencies](install.html#dependencies)
-* [Library Reference](reference.html)
- * [The Basics](reference.html#the-basics)
- * [The Details](reference.html#the-details)
- * [`markdown.markdown`](reference.html#markdown)
- * [`markdown.markdownFromFile`](reference.html#markdownFromFile)
- * [`markdown.Markdown`](reference.html#Markdown)
-* [Command Line](cli.html)
- * [Setup](cli.html#setup)
- * [Usage](cli.html#usage)
- * [Using Extensions](cli.html#using-extensions)
-* [Extensions](extensions/index.html)
- * [Officially Supported Extensions](extensions/index.html#officially-supported-extensions)
- * [Extra](extensions/extra.html)
- * [Abbreviations](extensions/abbreviations.html)
- * [Attribute Lists](extensions/attr_list.html)
- * [Definition Lists](extensions/definition_lists.html)
- * [Fenced Code Blocks](extensions/fenced_code_blocks.html)
- * [Footnotes](extensions/footnotes.html)
- * [Tables](extensions/tables.html)
- * [Smart Strong](extensions/smart_strong.html)
- * [Admonition](extensions/admonition.html)
- * [CodeHilite](extensions/code_hilite.html)
- * [HeaderId](extensions/header_id.html)
- * [Meta-Data](extensions/meta_data.html)
- * [New Line to Break](extensions/nl2br.html)
- * [Sane Lists](extensions/sane_lists.html)
- * [SmartyPants](extensions/smarty.html)
- * [Table of Contents](extensions/toc.html)
- * [WikiLinks](extensions/wikilinks.html)
- * [Third Party Extensions](extensions/index.html#third-party-extensions)
- * [Extension API](extensions/api.html)
- * [Preprocessors](extensions/api.html#preprocessors)
- * [Inline Patterns](extensions/api.html#inlinepatterns)
- * [Treeprocessors](extensions/api.html#treeprocessors)
- * [Postprocessors](extensions/api.html#postprocessors)
- * [BlockParser](extensions/api.html#blockparser)
- * [Working with the ElementTree](extensions/api.html#working_with_et)
- * [Integrating your code into Markdown](extensions/api.html#integrating_into_markdown)
- * [extendMarkdown](extensions/api.html#extendmarkdown)
- * [OrderedDict](extensions/api.html#ordereddict)
- * [registerExtension](extensions/api.html#registerextension)
- * [Configuration Settings](extensions/api.html#configsettings)
- * [makeExtension](extensions/api.html#makeextension)
-* [Test Suite](test_suite.html)
- * [Markdown Syntax Test](test_suite.html#markdown-syntax-tests)
- * [Syntax Test Configuration Settings](test_suite.html#syntax-test-config-settings)
- * [Unit Tests](test_suite.html#unit-tests)
-* [Change Log](change_log.html)
- * [Release Notes for v.2.6](release-2.6.html)
- * [Release Notes for v.2.5](release-2.5.html)
- * [Release Notes for v.2.4](release-2.4.html)
- * [Release Notes for v.2.3](release-2.3.html)
- * [Release Notes for v.2.2.1](release-2.1.1.html)
- * [Release Notes for v.2.2.0](release-2.1.0.html)
- * [Release Notes for v.2.0.2](release-2.0.2.html)
- * [Release Notes for v.2.0.1](release-2.0.1.html)
- * [Release Notes for v.2.0](release-2.0.html)
-* [Authors](authors.html)
diff --git a/docs/test_suite.txt b/docs/test_suite.md
similarity index 89%
rename from docs/test_suite.txt
rename to docs/test_suite.md
index ee761f2d4..9ead4c605 100644
--- a/docs/test_suite.txt
+++ b/docs/test_suite.md
@@ -7,10 +7,10 @@ next_url: change_log.html
# Test Suite
Python-Markdown comes with a test suite which uses the [Nose] testing
-framework and [YAML]. The test suite primarily serves to ensure that new bugs
-are not introduced as existing bugs are patched or new features are added. It
-also allows Python-Markdown to be tested with the tests from other
-implementations such as John Gruber's [Perl] implementation or Michel
+framework and [YAML]. The test suite primarily serves to ensure that new bugs
+are not introduced as existing bugs are patched or new features are added. It
+also allows Python-Markdown to be tested with the tests from other
+implementations such as John Gruber's [Perl] implementation or Michel
Fortin's [PHP] implementation.
The test suite can be run by calling the `run_tests.py` command at the root of
@@ -24,8 +24,8 @@ temporary file in `test-output.html`. Open the file in a browser to view
the report.
A `tox.ini` file is also provided, so [tox] can be used to automatically create
-virtual environments, install all testing dependencies and run the tests on
-each supported Python version. See the wiki for instructions on
+virtual environments, install all testing dependencies and run the tests on
+each supported Python version. See the wiki for instructions on
[setting up a testing environment] to use tox.
The test suite contains two kinds of tests: Markdown Syntax Tests and Unit
@@ -61,18 +61,18 @@ insignificant white space differences:
MarkdownSyntaxError: Output from "/home/waylan/code/python-markdown/te
sts/misc/lists3.txt" failed to match expected output.
- --- /home/waylan/code/python-markdown/tests/misc/lists3.html
- +++ actual_output.html
- @@ -1,5 +1,5 @@
-
- - blah blah blah
- -sdf asdf asdf asdf asdf
- -asda asdf asdfasd
- + sdf asdf asdf asdf asdf
- + asda asdf asdfasd
+ --- /home/waylan/code/python-markdown/tests/misc/lists3.html
+ +++ actual_output.html
+ @@ -1,5 +1,5 @@
+
+ - blah blah blah
+ -sdf asdf asdf asdf asdf
+ -asda asdf asdfasd
+ + sdf asdf asdf asdf asdf
+ + asda asdf asdfasd
- ----------------------------------------------------------------------
+ ----------------------------------------------------------------------
Ran 219 tests in 7.698s
FAILED (MarkdownSyntaxError=1, SKIP=53)
@@ -109,29 +109,29 @@ settings under a specific file section will override anything in the
Below are the configuration options available and the defaults used when they
are not explicitly set.
-* `normalize`: Switches white space normalization of the test output on or off.
- Defaults to `False` (off). Note: This requires that [PyTidyLib] be installed on
- the system. Otherwise the test will be skipped, regardless of any other
- settings.
-* `skip`: Switches skipping of the test on and off. Defaults to `False` (off).
-* `input_ext`: Extension of input file. Defaults to `.txt`. Useful for tests
+* `normalize`: Switches white space normalization of the test output on or off.
+ Defaults to `False` (off). Note: This requires that [PyTidyLib] be installed
+ on the system. Otherwise the test will be skipped, regardless of any other
+ settings.
+* `skip`: Switches skipping of the test on and off. Defaults to `False` (off).
+* `input_ext`: Extension of input file. Defaults to `.txt`. Useful for tests
from other implementations.
* `output_ext`: Extension of output file. Defaults to `.html`. Useful for tests
from other implementations.
-* Any keyword argument accepted by the Markdown class. If not set, Markdown's
- defaults are used.
+* Any keyword argument accepted by the Markdown class. If not set, Markdown's
+ defaults are used.
## Unit Tests
Unit Tests are used as regression tests for Python-Markdown's API.
All Unit Tests shipped with Python-Markdown are standard Python Unit Tests and
-are all contained in `tests/test_apis.py` and `tests/test_extensions.py`.
-Standard discovery methods are used to find and run the tests. Therefore, when
+are all contained in `tests/test_apis.py` and `tests/test_extensions.py`.
+Standard discovery methods are used to find and run the tests. Therefore, when
writing new tests, those standards and naming conventions should be followed.
-[Nose]: http://somethingaboutorange.com/mrl/projects/nose/
-[Perl]: http://daringfireball.net/projects/markdown/
-[PHP]: http://michelf.com/projects/php-markdown/
+[Nose]: http://somethingaboutorange.com/mrl/projects/nose/
+[Perl]: http://daringfireball.net/projects/markdown/
+[PHP]: http://michelf.com/projects/php-markdown/
[PyTidyLib]: http://countergram.com/open-source/pytidylib/
[tox]: http://testrun.org/tox/latest/
[setting up a testing environment]: https://github.com/Python-Markdown/markdown/wiki/Test-Environment-Setup
diff --git a/makefile b/makefile
index 2752d6a05..aeb81aab5 100644
--- a/makefile
+++ b/makefile
@@ -22,6 +22,7 @@ install:
deploy:
python setup.py sdist --manifest-only
python setup.py sdist --formats zip,gztar upload
+ mkdocs gh-deploy -r pages -b master
.PHONY : build
build:
@@ -35,8 +36,7 @@ build-win:
.PHONY : docs
docs:
- python setup.py build_docs --force
- cd build/docs && zip -r ../docs.zip .
+ mkdocs build --clean
.PHONY : test
test:
@@ -62,4 +62,5 @@ clean:
rm -rf build
rm -rf dist
rm -rf tmp
+ rm -rf site
# git clean -dfx'
diff --git a/markdown/__init__.py b/markdown/__init__.py
index 409f9cfd4..5b8be470d 100644
--- a/markdown/__init__.py
+++ b/markdown/__init__.py
@@ -10,7 +10,7 @@
import markdown
html = markdown.markdown(your_text_string)
-See for more
+See for more
information and instructions on how to extend the functionality of
Python Markdown. Read that before you try modifying this file.
diff --git a/markdown/__main__.py b/markdown/__main__.py
index 17bfa9f3c..c24f7562c 100644
--- a/markdown/__main__.py
+++ b/markdown/__main__.py
@@ -27,7 +27,7 @@ def parse_options(args=None, values=None):
usage = """%prog [options] [INPUTFILE]
(STDIN is assumed if no INPUTFILE is given)"""
desc = "A Python implementation of John Gruber's Markdown. " \
- "https://pythonhosted.org/Markdown/"
+ "https://Python-Markdown.github.io/"
ver = "%%prog %s" % markdown.version
parser = optparse.OptionParser(usage=usage, description=desc, version=ver)
diff --git a/markdown/extensions/abbr.py b/markdown/extensions/abbr.py
index 353d126f6..bfa8c10b0 100644
--- a/markdown/extensions/abbr.py
+++ b/markdown/extensions/abbr.py
@@ -4,7 +4,7 @@
This extension adds abbreviation handling to Python-Markdown.
-See
+See
for documentation.
Oringinal code Copyright 2007-2008 [Waylan Limberg](http://achinghead.com/) and
diff --git a/markdown/extensions/admonition.py b/markdown/extensions/admonition.py
index 0c5ce4669..2e83900be 100644
--- a/markdown/extensions/admonition.py
+++ b/markdown/extensions/admonition.py
@@ -6,7 +6,7 @@
[rST]: http://docutils.sourceforge.net/docs/ref/rst/directives.html#specific-admonitions # noqa
-See
+See
for documentation.
Original code Copyright [Tiago Serafim](http://www.tiagoserafim.com/).
diff --git a/markdown/extensions/attr_list.py b/markdown/extensions/attr_list.py
index a7f92b66d..894e5455e 100644
--- a/markdown/extensions/attr_list.py
+++ b/markdown/extensions/attr_list.py
@@ -6,7 +6,7 @@
[maruku](http://maruku.rubyforge.org/proposal.html#attribute_lists)'s
feature of the same name.
-See
+See
for documentation.
Original code Copyright 2011 [Waylan Limberg](http://achinghead.com/).
diff --git a/markdown/extensions/codehilite.py b/markdown/extensions/codehilite.py
index 20b889c44..ee42d57c8 100644
--- a/markdown/extensions/codehilite.py
+++ b/markdown/extensions/codehilite.py
@@ -4,7 +4,7 @@
Adds code/syntax highlighting to standard Python-Markdown code blocks.
-See
+See
for documentation.
Original code Copyright 2006-2008 [Waylan Limberg](http://achinghead.com/).
diff --git a/markdown/extensions/def_list.py b/markdown/extensions/def_list.py
index 77cca6eb8..9057ebd98 100644
--- a/markdown/extensions/def_list.py
+++ b/markdown/extensions/def_list.py
@@ -4,7 +4,7 @@
Adds parsing of Definition Lists to Python-Markdown.
-See
+See
for documentation.
Original code Copyright 2008 [Waylan Limberg](http://achinghead.com)
diff --git a/markdown/extensions/extra.py b/markdown/extensions/extra.py
index de5db03cd..587ba6402 100644
--- a/markdown/extensions/extra.py
+++ b/markdown/extensions/extra.py
@@ -20,7 +20,7 @@
variable defined below, but be aware that such changes may be lost
when you upgrade to any future version of Python-Markdown.
-See
+See
for documentation.
Copyright The Python Markdown Project
diff --git a/markdown/extensions/fenced_code.py b/markdown/extensions/fenced_code.py
index 277bac405..392c654e3 100644
--- a/markdown/extensions/fenced_code.py
+++ b/markdown/extensions/fenced_code.py
@@ -4,7 +4,7 @@
This extension adds Fenced Code Blocks to Python-Markdown.
-See
+See
for documentation.
Original code Copyright 2007-2008 [Waylan Limberg](http://achinghead.com/).
diff --git a/markdown/extensions/footnotes.py b/markdown/extensions/footnotes.py
index 8bd85959c..7edf8135c 100644
--- a/markdown/extensions/footnotes.py
+++ b/markdown/extensions/footnotes.py
@@ -4,7 +4,7 @@
Adds footnote handling to Python-Markdown.
-See
+See
for documentation.
Copyright The Python Markdown Project
diff --git a/markdown/extensions/headerid.py b/markdown/extensions/headerid.py
index 2cb20b97a..fdcc8f206 100644
--- a/markdown/extensions/headerid.py
+++ b/markdown/extensions/headerid.py
@@ -4,7 +4,7 @@
Auto-generate id attributes for HTML headers.
-See
+See
for documentation.
Original code Copyright 2007-2011 [Waylan Limberg](http://achinghead.com/).
diff --git a/markdown/extensions/meta.py b/markdown/extensions/meta.py
index 711235ef4..7902bd437 100644
--- a/markdown/extensions/meta.py
+++ b/markdown/extensions/meta.py
@@ -4,7 +4,7 @@
This extension adds Meta Data handling to markdown.
-See
+See
for documentation.
Original code Copyright 2007-2008 [Waylan Limberg](http://achinghead.com).
diff --git a/markdown/extensions/nl2br.py b/markdown/extensions/nl2br.py
index 8acd60c2e..a4c0fab02 100644
--- a/markdown/extensions/nl2br.py
+++ b/markdown/extensions/nl2br.py
@@ -5,7 +5,7 @@
A Python-Markdown extension to treat newlines as hard breaks; like
GitHub-flavored Markdown does.
-See
+See
for documentation.
Oringinal code Copyright 2011 [Brian Neal](http://deathofagremmie.com/)
diff --git a/markdown/extensions/sane_lists.py b/markdown/extensions/sane_lists.py
index 828ae7ab3..651b12b25 100644
--- a/markdown/extensions/sane_lists.py
+++ b/markdown/extensions/sane_lists.py
@@ -4,7 +4,7 @@
Modify the behavior of Lists in Python-Markdown to act in a sane manor.
-See
+See
for documentation.
Original code Copyright 2011 [Waylan Limberg](http://achinghead.com)
diff --git a/markdown/extensions/smart_strong.py b/markdown/extensions/smart_strong.py
index 58570bb55..eeded3114 100644
--- a/markdown/extensions/smart_strong.py
+++ b/markdown/extensions/smart_strong.py
@@ -4,7 +4,7 @@
This extention adds smarter handling of double underscores within words.
-See
+See
for documentation.
Original code Copyright 2011 [Waylan Limberg](http://achinghead.com)
diff --git a/markdown/extensions/smarty.py b/markdown/extensions/smarty.py
index 600d74cd6..5031bc402 100644
--- a/markdown/extensions/smarty.py
+++ b/markdown/extensions/smarty.py
@@ -6,7 +6,7 @@
Adds conversion of ASCII dashes, quotes and ellipses to their HTML
entity equivalents.
-See
+See
for documentation.
Author: 2013, Dmitry Shachnev
diff --git a/markdown/extensions/tables.py b/markdown/extensions/tables.py
index ec3b6ac9f..6d28aefff 100644
--- a/markdown/extensions/tables.py
+++ b/markdown/extensions/tables.py
@@ -4,7 +4,7 @@
Added parsing of tables to Python-Markdown.
-See
+See
for documentation.
Original code Copyright 2009 [Waylan Limberg](http://achinghead.com)
diff --git a/markdown/extensions/toc.py b/markdown/extensions/toc.py
index 56db33c50..2c4a4b54e 100644
--- a/markdown/extensions/toc.py
+++ b/markdown/extensions/toc.py
@@ -2,7 +2,7 @@
Table of Contents Extension for Python-Markdown
===============================================
-See
+See
for documentation.
Oringinal code Copyright 2008 [Jack Miller](http://codezen.org)
diff --git a/markdown/extensions/wikilinks.py b/markdown/extensions/wikilinks.py
index 94e1b6794..ff16494b9 100644
--- a/markdown/extensions/wikilinks.py
+++ b/markdown/extensions/wikilinks.py
@@ -4,7 +4,7 @@
Converts [[WikiLinks]] to relative links.
-See
+See
for documentation.
Original code Copyright [Waylan Limberg](http://achinghead.com/).
diff --git a/mkdocs.yml b/mkdocs.yml
new file mode 100644
index 000000000..dfecb3cea
--- /dev/null
+++ b/mkdocs.yml
@@ -0,0 +1,57 @@
+site_name: Python-Markdown
+site_url: https://Python-Markdown.github.io/
+repo_url: https://github.com/Python-Markdown/markdown
+site_author: "The Python-Markdown Project"
+copyright: "Copyright © 2010-2017"
+
+use_directory_urls: true
+
+theme:
+ name: nature
+ icon: py.png
+ release: 2.6.9
+ issue_tracker: https://github.com/Python-Markdown/markdown/issues
+
+pages:
+ - Python-Markdown: index.md
+ - Installation: install.md
+ - Library Reference: reference.md
+ - Command Line: cli.md
+ - Extensions: extensions/index.md
+ - Officially Supported Extensions:
+ - Abbreviations: extensions/abbreviations.md
+ - Admonition: extensions/admonition.md
+ - Attribute Lists: extensions/attr_list.md
+ - CodeHilite: extensions/code_hilite.md
+ - Definition Lists: extensions/definition_lists.md
+ - Extra: extensions/extra.md
+ - Fenced Code Blocks: extensions/fenced_code_blocks.md
+ - Footnotes: extensions/footnotes.md
+ - HeaderId: extensions/header_id.md
+ - Meta-Data: extensions/meta_data.md
+ - New Line to Break: extensions/nl2br.md
+ - Sane Lists: extensions/sane_lists.md
+ - Smart Strong: extensions/smart_strong.md
+ - SmartyPants: extensions/smarty.md
+ - Table of Contents: extensions/toc.md
+ - Tables: extensions/tables.md
+ - WikiLinks: extensions/wikilinks.md
+ - Extension API: extensions/api.md
+ - Test Suite: test_suite.md
+ - Change Log: change_log/index.md
+ - Release Notes for v.2.6: change_log/release-2.6.md
+ - Release Notes for v.2.5: change_log/release-2.5.md
+ - Release Notes for v.2.4: change_log/release-2.4.md
+ - Release Notes for v.2.3: change_log/release-2.3.md
+ - Release Notes for v.2.2: change_log/release-2.2.md
+ - Release Notes for v.2.1: change_log/release-2.1.md
+ - Release Notes for v.2.0: change_log/release-2.0.md
+ - Authors: authors.md
+
+markdown_extensions:
+ - extra
+ - admonition
+ - smarty
+ - codehilite
+ - toc:
+ permalink: true
diff --git a/setup.py b/setup.py
index 3821c6c24..fba517215 100755
--- a/setup.py
+++ b/setup.py
@@ -5,10 +5,6 @@
import os
from distutils.core import setup
from distutils.command.install_scripts import install_scripts
-from distutils.command.build import build
-from distutils.core import Command
-from distutils.util import change_root, newer
-import codecs
import imp
@@ -68,150 +64,6 @@ def run(self):
print('ERROR: Unable to create %s: %s' % (bat_path, err))
-class build_docs(Command):
-
- """ Build markdown documentation into html."""
-
- description = '"build" documentation (convert markdown text to html)'
-
- user_options = [
- ('build-base=', 'd', 'directory to "build" to'),
- ('force', 'f', 'forcibly build everything (ignore file timestamps)'),
- ]
-
- boolean_options = ['force']
-
- def initialize_options(self):
- self.build_base = None
- self.force = None
- self.docs = None
- self.sitemap = ''
-
- def finalize_options(self):
- self.set_undefined_options(
- 'build',
- ('build_base', 'build_base'),
- ('force', 'force')
- )
- self.docs = self._get_docs()
-
- def _get_docs(self):
- for root, dirs, files in os.walk('docs'):
- for file in files:
- if not file.startswith('_'):
- path = os.path.join(root, file)
- yield path
-
- def _get_context(self, src, path):
- """ Build and return context to pass to template. """
- # set defaults
- c = {
- 'title': '',
- 'prev_url': '',
- 'prev_title': '',
- 'next_url': '',
- 'next_title': '',
- 'crumb': '',
- 'version': version,
- }
- c['body'] = self.md.convert(src)
- c['toc'] = self.md.toc
- for k, v in self.md.Meta.items():
- c[k] = ' '.join(v)
- self.md.reset()
- # Manipulate path
- path = path[len(os.path.join(self.build_base, 'docs/')):]
- dir, file = os.path.split(path)
- name, ext = os.path.splitext(file)
- parts = [x for x in dir.split(os.sep) if x]
- c['source'] = '%s.txt' % name
- c['base'] = '../' * len(parts)
- # Build page title
- if name.lower() != 'index' or parts:
- c['page_title'] = '%s — Python Markdown' % c['title']
- else:
- c['page_title'] = 'Python Markdown'
- # Build crumb trail
- crumbs = []
- ctemp = '- %s »
'
- for n, part in enumerate(parts):
- href = ('../' * n) + 'index.html'
- label = part.replace('_', ' ').capitalize()
- crumbs.append(ctemp % (href, label))
- if c['title'] and name.lower() != 'index':
- crumbs.append(ctemp % (file, c['title']))
- c['crumb'] = '\n'.join(crumbs)
- return c
-
- def run(self):
- # Before importing markdown, tweak sys.path to import from the
- # build directory (2to3 might have run on the library).
- bld_cmd = self.get_finalized_command("build")
- sys.path.insert(0, bld_cmd.build_lib)
- try:
- import markdown
- except ImportError:
- print('skipping build_docs: Markdown "import" failed!')
- else:
- with codecs.open('docs/_template.html', encoding='utf-8') as f:
- template = f.read()
- self.md = markdown.Markdown(
- extensions=[
- 'extra',
- 'toc(permalink=true)',
- 'meta',
- 'admonition',
- 'smarty'
- ]
- )
- for infile in self.docs:
- outfile, ext = os.path.splitext(infile)
- if ext == '.txt':
- # Copy src to .txt file
- srcfile = outfile + '.txt'
- srcfile = change_root(self.build_base, srcfile)
- self.mkpath(os.path.split(srcfile)[0])
- self.copy_file(infile, srcfile)
- # Render html file
- outfile += '.html'
- outfile = change_root(self.build_base, outfile)
- self.mkpath(os.path.split(outfile)[0])
- if self.force or newer(infile, outfile):
- if self.verbose:
- print('Converting %s -> %s' % (infile, outfile))
- if not self.dry_run:
- with codecs.open(infile, encoding='utf-8') as f:
- src = f.read()
- out = template % self._get_context(src, outfile)
- doc = open(outfile, 'wb')
- doc.write(out.encode('utf-8'))
- doc.close()
- else:
- outfile = change_root(self.build_base, infile)
- self.mkpath(os.path.split(outfile)[0])
- self.copy_file(infile, outfile)
-
-
-class md_build(build):
-
- """ Run "build_docs" command from "build" command. """
-
- user_options = build.user_options + [
- ('no-build-docs', None, 'do not build documentation'),
- ]
-
- boolean_options = build.boolean_options + ['build-docs']
-
- def initialize_options(self):
- build.initialize_options(self)
- self.no_build_docs = False
-
- def has_docs(self):
- return not self.no_build_docs
-
- sub_commands = build.sub_commands + [('build_docs', has_docs)]
-
-
long_description = '''
This is a Python implementation of John Gruber's Markdown_.
It is almost completely compliant with the reference implementation,
@@ -220,8 +72,8 @@ def has_docs(self):
supported by the `Available Extensions`_.
.. _Markdown: http://daringfireball.net/projects/markdown/
-.. _Features: https://pythonhosted.org/Markdown/index.html#Features
-.. _`Available Extensions`: https://pythonhosted.org/Markdown/extensions/index.html
+.. _Features: https://Python-Markdown.github.io#Features
+.. _`Available Extensions`: https://Python-Markdown.github.io/extensions/
Support
=======
@@ -236,7 +88,7 @@ def has_docs(self):
setup(
name='Markdown',
version=version,
- url='https://pythonhosted.org/Markdown/',
+ url='https://Python-Markdown.github.io/',
download_url='http://pypi.python.org/packages/source/M/Markdown/Markdown-%s.tar.gz' % version,
description='Python implementation of Markdown.',
long_description=long_description,
@@ -248,9 +100,7 @@ def has_docs(self):
packages=['markdown', 'markdown.extensions'],
scripts=['bin/%s' % SCRIPT_NAME],
cmdclass={
- 'install_scripts': md_install_scripts,
- 'build_docs': build_docs,
- 'build': md_build
+ 'install_scripts': md_install_scripts
},
classifiers=[
'Development Status :: %s' % DEVSTATUS,
diff --git a/test-requirements.txt b/test-requirements.txt
index b7bcf16d1..65bfae034 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -2,4 +2,5 @@ nose
coverage<4.0
pyyaml
pytidylib
-pygments
+mkdocs
+mkdocs-nature
diff --git a/tests/misc/em-around-links.html b/tests/misc/em-around-links.html
index a7593c517..cc415f505 100644
--- a/tests/misc/em-around-links.html
+++ b/tests/misc/em-around-links.html
@@ -1,13 +1,13 @@
Title
-- Python in Markdown by some
+
- Python in Markdown by some
great folks - This does work as expected.
-- Python in Markdown by some
+
- Python in Markdown by some
great folks - This does work as expected.
-- Python in Markdown by some
+
- Python in Markdown by some
great folks - This does work as expected.
-- Python in Markdown by some
+
- Python in Markdown by some
great folks - This does work as expected.
-Python in Markdown by some
+Python in Markdown by some
great folks - This does work as expected.
\ No newline at end of file
diff --git a/tests/misc/em-around-links.txt b/tests/misc/em-around-links.txt
index de04d3b7c..dbc36443b 100644
--- a/tests/misc/em-around-links.txt
+++ b/tests/misc/em-around-links.txt
@@ -1,14 +1,14 @@
# Title
- - *[Python in Markdown](https://pythonhosted.org/Markdown/) by some
+ - *[Python in Markdown](http://example.com) by some
great folks* - This *does* work as expected.
- - _[Python in Markdown](https://pythonhosted.org/Markdown/) by some
+ - _[Python in Markdown](http://example.com) by some
great folks_ - This *does* work as expected.
- - [_Python in Markdown_](https://pythonhosted.org/Markdown/) by some
+ - [_Python in Markdown_](http://example.com) by some
great folks - This *does* work as expected.
- - [_Python in Markdown_](https://pythonhosted.org/Markdown/) _by some
+ - [_Python in Markdown_](http://example.com) _by some
great folks_ - This *does* work as expected.
-_[Python in Markdown](https://pythonhosted.org/Markdown/) by some
+_[Python in Markdown](http://example.com) by some
great folks_ - This *does* work as expected.