pax_global_header00006660000000000000000000000064133575722510014524gustar00rootroot0000000000000052 comment=6470c42b2087a4649ad0437227cf7b5c570c3a91 mistune-0.8.4/000077500000000000000000000000001335757225100132215ustar00rootroot00000000000000mistune-0.8.4/.gitignore000066400000000000000000000002201335757225100152030ustar00rootroot00000000000000*.pyc *.pyo *.egg-info __pycache__ bin build develop-eggs dist eggs parts .DS_Store .installed.cfg docs/_build cover/ .tox *.bak *.c *.so venv/ mistune-0.8.4/.travis.yml000066400000000000000000000004161335757225100153330ustar00rootroot00000000000000language: python python: - "2.7" - "3.5" - "3.6" - "pypy" script: - python setup.py -q nosetests after_success: - pip install coveralls - coverage run --source=mistune setup.py -q nosetests - coveralls notifications: email: false mistune-0.8.4/CHANGES.rst000066400000000000000000000114271335757225100150300ustar00rootroot00000000000000Changelog ---------- Here is the full history of mistune. Version 0.8.4 ~~~~~~~~~~~~~ Released on Oct. 11, 2018 * Support an escaped pipe char in a table cell. `#150`_ * Fix ordered and unordered list. `#152`_ * Fix spaces between = in HTML tags * Add max_recursive_depth for list and blockquote. * Fix fences code block. .. _`#150`: https://github.com/lepture/mistune/pull/150 .. _`#152`: https://github.com/lepture/mistune/pull/152 Version 0.8.3 ~~~~~~~~~~~~~ Relased on Dec. 04, 2017 * Fix nested html issue. `#137`_ .. _`#137`: https://github.com/lepture/mistune/pull/137 Version 0.8.2 ~~~~~~~~~~~~~ Relased on Dec. 04, 2017 * Fix ``_keyify`` with lower case. Version 0.8.1 ~~~~~~~~~~~~~ Released on Nov. 07, 2017 * Security fix CVE-2017-16876, thanks Dawid Czarnecki Version 0.8 ~~~~~~~~~~~ Released on Oct. 26, 2017 * Remove non breaking spaces preprocessing * Remove rev and rel attribute for footnotes * Fix bypassing XSS vulnerability by junorouse This version is strongly recommended, since it fixed a security issue. Version 0.7.4 ~~~~~~~~~~~~~ Released on Mar. 14, 2017 * Fix escape_link method by Marcos Ojeda * Handle block HTML with no content by David Baumgold * Use expandtabs for tab * Fix escape option for text renderer * Fix HTML attribute regex pattern Version 0.7.3 ~~~~~~~~~~~~~ Released on Jun. 28, 2016 * Fix strikethrough regex * Fix HTML attribute regex * Fix close tag regex Version 0.7.2 ~~~~~~~~~~~~~ Released on Feb. 26, 2016 * Fix `hard_wrap` options on renderer. * Fix emphasis regex pattern * Fix base64 image link `#80`_. * Fix link security per `#87`_. .. _`#80`: https://github.com/lepture/mistune/issues/80 .. _`#87`: https://github.com/lepture/mistune/issues/87 Version 0.7.1 ~~~~~~~~~~~~~ Released on Aug. 22, 2015 * Fix inline html when there is no content per `#71`_. .. _`#71`: https://github.com/lepture/mistune/issues/71 Version 0.7 ~~~~~~~~~~~ Released on Jul. 18, 2015 * Fix the breaking change in version 0.6 with options: **parse_inline_html** and **parse_block_html** * Breaking change: remove **parse_html** option for explicit * Change option **escape** default value to ``True`` for security reason Version 0.6 ~~~~~~~~~~~ Released on Jun. 17, 2015 * Breaking change on inline HTML, text in inline HTML will not be parsed per `#38`_. * Replace **tag** renderer with **inline_html** for breaking change on inline HTML * Double emphasis, emphasis, code, and strikethrough can contain one linebreak per `#48`_. * Match autolinks that do not have / in their URI via `#53`_. * A work around on link that contains ``)`` per `#46`_. * Add ```` tag for inline tags per `#55`_. .. _`#38`: https://github.com/lepture/mistune/issues/38 .. _`#46`: https://github.com/lepture/mistune/issues/46 .. _`#48`: https://github.com/lepture/mistune/issues/48 .. _`#53`: https://github.com/lepture/mistune/pull/53 .. _`#55`: https://github.com/lepture/mistune/issues/55 Version 0.5.1 ~~~~~~~~~~~~~ Released on Mar. 10, 2015 * Fix a bug when list item is blank via `ipython#7929`_. * Use python-wheels to build wheels for Mac. .. _`ipython#7929`: https://github.com/ipython/ipython/issues/7929 Version 0.5 ~~~~~~~~~~~ Released on Dec. 5, 2014. This release will break things. * For custom lexers, **features** is replaced with **rules**. * Refactor on function names and codes. * Add a way to output the render tree via `#20`_. * Fix emphasis and strikethrough regular expressions. .. _`#20`: https://github.com/lepture/mistune/pull/20 Version 0.4.1 ~~~~~~~~~~~~~ Released on Oct. 12, 2014 * Add option for parse markdown in block level html. * Fix on lheading, any number of underline = or - will work. * Patch for setup if Cython is available but no C compiler. Version 0.4 ~~~~~~~~~~~ Released on Aug. 14, 2014 * Bugfix. Use inspect to detect renderer class. * Move all meth:`escape` to renderer. Use renderer to escape everything. * A little changes in code style and parameter naming. * Don't parse text in a block html, behave like sundown. Version 0.3.1 ~~~~~~~~~~~~~ Released on Jul. 31, 2014 * Fix in meth:`Renderer.block_code`, no need to add ``\n`` in ````. * Trim whitespace of code in code span via `#15`_. .. _`#15`: https://github.com/lepture/mistune/issues/15 Version 0.3 ~~~~~~~~~~~ Released on Jun. 27, 2014 * Add ``
`` in footnotes renderer * Add hard_wrap configuration for GFM linebreaks. * Add text renderer, via `#9`_. * Define features for lexers available via `#11`_. .. _`#9`: https://github.com/lepture/mistune/pull/9 .. _`#11`: https://github.com/lepture/mistune/pull/11 Version 0.2 ~~~~~~~~~~~ Released on Mar. 12, 2014 * Use tuple instead of list for efficient * Add ``line_match`` and ``line_started`` property on InlineLexer, via `#4`_ .. _`#4`: https://github.com/lepture/mistune/pull/4 Version 0.1 ~~~~~~~~~~~ First preview release. mistune-0.8.4/LICENSE000066400000000000000000000027121335757225100142300ustar00rootroot00000000000000Copyright (c) 2014 - 2015, Hsiaoming Yang All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the creator nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. mistune-0.8.4/MANIFEST.in000066400000000000000000000002301335757225100147520ustar00rootroot00000000000000include Makefile LICENSE README.rst CHANGES.rst exclude mistune.c recursive-include tests * recursive-exclude tests *.pyc recursive-exclude tests *.pyo mistune-0.8.4/Makefile000066400000000000000000000012771335757225100146700ustar00rootroot00000000000000.PHONY: clean-pyc clean-build docs test: @nosetests -s bench: @python tests/bench.py coverage: @rm -f .coverage @nosetests --with-coverage --cover-package=mistune --cover-html clean: clean-build clean-pyc clean-docs clean-build: @rm -fr build/ @rm -fr dist/ @rm -fr *.egg-info @rm -f mistune.c @rm -fr cover/ clean-pyc: @find . -name '*.pyc' -exec rm -f {} + @find . -name '*.pyo' -exec rm -f {} + @find . -name '*~' -exec rm -f {} + @find . -name '__pycache__' -exec rm -fr {} + clean-docs: @rm -fr docs/_build docs: @$(MAKE) -C docs html rtd: curl -X POST http://readthedocs.org/build/mistune publish: @twine upload dist/*.tar.gz @twine upload dist/*.whl .PHONY: build mistune-0.8.4/README.rst000066400000000000000000000163401335757225100147140ustar00rootroot00000000000000Mistune ======= The fastest markdown parser in pure Python with renderer features, inspired by marked_. .. image:: https://img.shields.io/badge/donate-lepture-green.svg :target: https://lepture.com/donate :alt: Donate lepture .. image:: https://img.shields.io/pypi/wheel/mistune.svg?style=flat :target: https://pypi.python.org/pypi/mistune/ :alt: Wheel Status .. image:: https://anaconda.org/conda-forge/mistune/badges/version.svg :target: https://anaconda.org/conda-forge/mistune :alt: Conda Version .. image:: https://img.shields.io/pypi/v/mistune.svg :target: https://pypi.python.org/pypi/mistune/ :alt: Latest Version .. image:: https://travis-ci.org/lepture/mistune.svg?branch=master :target: https://travis-ci.org/lepture/mistune :alt: Travis CI Status .. image:: https://coveralls.io/repos/lepture/mistune/badge.svg?branch=master :target: https://coveralls.io/r/lepture/mistune :alt: Coverage Status .. image:: https://ci.appveyor.com/api/projects/status/8ai8tfwp75oela17?svg=true :target: https://ci.appveyor.com/project/lepture/mistune :alt: App Veyor CI Status .. _marked: https://github.com/chjj/marked Features -------- * **Pure Python**. Tested in Python 2.7, Python 3.5+ and PyPy. * **Very Fast**. It is the fastest in all **pure Python** markdown parsers. * **More Features**. Table, footnotes, autolink, fenced code etc. View the `benchmark results `_. Installation ------------ Installing mistune with pip:: $ pip install mistune Mistune can be faster, if you compile with cython:: $ pip install cython mistune Basic Usage ----------- A simple API that render a markdown formatted text: .. code:: python import mistune mistune.markdown('I am using **mistune markdown parser**') # output:

I am using mistune markdown parser

If you care about performance, it is better to re-use the Markdown instance: .. code:: python import mistune markdown = mistune.Markdown() markdown('I am using **mistune markdown parser**') Mistune has enabled all features by default. You don't have to configure anything. But there are options for you to change the parser behaviors. Options ------- Here is a list of all options that will affect the rendering results, configure them with ``mistune.Renderer``: .. code:: python renderer = mistune.Renderer(escape=True, hard_wrap=True) # use this renderer instance markdown = mistune.Markdown(renderer=renderer) markdown(text) * **escape**: if set to *False*, all raw html tags will not be escaped. * **hard_wrap**: if set to *True*, it will has GFM line breaks feature. All new lines will be replaced with ``
`` tag * **use_xhtml**: if set to *True*, all tags will be in xhtml, for example: ``
``. * **parse_block_html**: parse text only in block level html. * **parse_inline_html**: parse text only in inline level html. When using the default renderer, you can use one of the following shortcuts:: mistune.markdown(text, escape=True, hard_wrap=True) markdown = mistune.Markdown(escape=True, hard_wrap=True) markdown(text) Renderer -------- Like misaka/sundown, you can influence the rendering by custom renderers. All you need to do is subclassing a `Renderer` class. Here is an example of code highlighting: .. code:: python import mistune from pygments import highlight from pygments.lexers import get_lexer_by_name from pygments.formatters import html class HighlightRenderer(mistune.Renderer): def block_code(self, code, lang): if not lang: return '\n
%s
\n' % \ mistune.escape(code) lexer = get_lexer_by_name(lang, stripall=True) formatter = html.HtmlFormatter() return highlight(code, lexer, formatter) renderer = HighlightRenderer() markdown = mistune.Markdown(renderer=renderer) print(markdown('```python\nassert 1 == 1\n```')) Find more renderers in `mistune-contrib`_. Block Level ~~~~~~~~~~~ Here is a list of block level renderer API:: block_code(code, language=None) block_quote(text) block_html(html) header(text, level, raw=None) hrule() list(body, ordered=True) list_item(text) paragraph(text) table(header, body) table_row(content) table_cell(content, **flags) The *flags* tells you whether it is header with ``flags['header']``. And it also tells you the align with ``flags['align']``. Span Level ~~~~~~~~~~ Here is a list of span level renderer API:: autolink(link, is_email=False) codespan(text) double_emphasis(text) emphasis(text) image(src, title, alt_text) linebreak() newline() link(link, title, content) strikethrough(text) text(text) inline_html(text) Footnotes ~~~~~~~~~ Here is a list of renderers related to footnotes:: footnote_ref(key, index) footnote_item(key, text) footnotes(text) Lexers ------ Sometimes you want to add your own rules to Markdown, such as GitHub Wiki links. You can't achieve this goal with renderers. You will need to deal with the lexers, it would be a little difficult for the first time. We will take an example for GitHub Wiki links: ``[[Page 2|Page 2]]``. It is an inline grammar, which requires custom ``InlineGrammar`` and ``InlineLexer``: .. code:: python import copy,re from mistune import Renderer, InlineGrammar, InlineLexer class WikiLinkRenderer(Renderer): def wiki_link(self, alt, link): return '%s' % (link, alt) class WikiLinkInlineLexer(InlineLexer): def enable_wiki_link(self): # add wiki_link rules self.rules.wiki_link = re.compile( r'\[\[' # [[ r'([\s\S]+?\|[\s\S]+?)' # Page 2|Page 2 r'\]\](?!\])' # ]] ) # Add wiki_link parser to default rules # you can insert it some place you like # but place matters, maybe 3 is not good self.default_rules.insert(3, 'wiki_link') def output_wiki_link(self, m): text = m.group(1) alt, link = text.split('|') # you can create an custom render # you can also return the html if you like return self.renderer.wiki_link(alt, link) You should pass the inline lexer to ``Markdown`` parser: .. code:: python renderer = WikiLinkRenderer() inline = WikiLinkInlineLexer(renderer) # enable the feature inline.enable_wiki_link() markdown = Markdown(renderer, inline=inline) markdown('[[Link Text|Wiki Link]]') It is the same with block level lexer. It would take a while to understand the whole mechanism. But you won't do the trick a lot. Contribution & Extensions ------------------------- Mistune itself doesn't accept any extension. It will always be a simple one file script. If you want to add features, you can head over to `mistune-contrib`_. Here are some extensions already in `mistune-contrib`_: * Math/MathJax features * Highlight Code Renderer * TOC table of content features * MultiMarkdown Metadata parser Get inspired with the contrib repository. .. _`mistune-contrib`: https://github.com/lepture/mistune-contrib mistune-0.8.4/appveyor.yml000066400000000000000000000004211335757225100156060ustar00rootroot00000000000000build: false environment: matrix: - PYTHON: "C:\\Python27-x64" - PYTHON: "C:\\Python35-x64" init: - SET PATH=%PYTHON%;%PATH% - python -c "import sys;sys.stdout.write(sys.version)" install: - python -m pip install nose test_script: - python -m nose -s mistune-0.8.4/docs/000077500000000000000000000000001335757225100141515ustar00rootroot00000000000000mistune-0.8.4/docs/Makefile000066400000000000000000000151561335757225100156210ustar00rootroot00000000000000# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build # User-friendly check for sphinx-build ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) endif # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . # the i18n builder cannot share the environment and doctrees with the others I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " singlehtml to make a single large HTML file" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " devhelp to make HTML files and a Devhelp project" @echo " epub to make an epub" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " latexpdf to make LaTeX files and run them through pdflatex" @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" @echo " text to make text files" @echo " man to make manual pages" @echo " texinfo to make Texinfo files" @echo " info to make Texinfo files and run them through makeinfo" @echo " gettext to make PO message catalogs" @echo " changes to make an overview of all changed/added/deprecated items" @echo " xml to make Docutils-native XML files" @echo " pseudoxml to make pseudoxml-XML files for display purposes" @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" clean: rm -rf $(BUILDDIR)/* html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." singlehtml: $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml @echo @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." qthelp: $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/otpauth.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/otpauth.qhc" devhelp: $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp @echo @echo "Build finished." @echo "To view the help file:" @echo "# mkdir -p $$HOME/.local/share/devhelp/otpauth" @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/otpauth" @echo "# devhelp" epub: $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub @echo @echo "Build finished. The epub file is in $(BUILDDIR)/epub." latex: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make' in that directory to run these through (pdf)latex" \ "(use \`make latexpdf' here to do that automatically)." latexpdf: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through pdflatex..." $(MAKE) -C $(BUILDDIR)/latex all-pdf @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." latexpdfja: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through platex and dvipdfmx..." $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." text: $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text @echo @echo "Build finished. The text files are in $(BUILDDIR)/text." man: $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man @echo @echo "Build finished. The manual pages are in $(BUILDDIR)/man." texinfo: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." @echo "Run \`make' in that directory to run these through makeinfo" \ "(use \`make info' here to do that automatically)." info: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo "Running Texinfo files through makeinfo..." make -C $(BUILDDIR)/texinfo info @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." gettext: $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale @echo @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." linkcheck: $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." xml: $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml @echo @echo "Build finished. The XML files are in $(BUILDDIR)/xml." pseudoxml: $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml @echo @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." mistune-0.8.4/docs/_themes/000077500000000000000000000000001335757225100155755ustar00rootroot00000000000000mistune-0.8.4/docs/_themes/LICENSE000066400000000000000000000033751335757225100166120ustar00rootroot00000000000000Copyright (c) 2010 by Armin Ronacher. Some rights reserved. Redistribution and use in source and binary forms of the theme, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission. We kindly ask you to only use these themes in an unmodified manner just for Flask and Flask-related products, not for unrelated projects. If you like the visual style and want to use it for your own projects, please consider making some larger changes to the themes (such as changing font faces, sizes, colors or margins). THIS THEME IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS THEME, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. mistune-0.8.4/docs/_themes/flask_small/000077500000000000000000000000001335757225100200655ustar00rootroot00000000000000mistune-0.8.4/docs/_themes/flask_small/layout.html000066400000000000000000000012551335757225100222730ustar00rootroot00000000000000{% extends "basic/layout.html" %} {% block header %} {{ super() }} {% if pagename == 'index' %}
{% endif %} {% endblock %} {% block footer %} {% if pagename == 'index' %}
{% endif %} {% endblock %} {# do not display relbars #} {% block relbar1 %}{% endblock %} {% block relbar2 %} {% if theme_github_fork %} Fork me on GitHub {% endif %} {% endblock %} {% block sidebar1 %}{% endblock %} {% block sidebar2 %}{% endblock %} mistune-0.8.4/docs/_themes/flask_small/static/000077500000000000000000000000001335757225100213545ustar00rootroot00000000000000mistune-0.8.4/docs/_themes/flask_small/static/flasky.css_t000066400000000000000000000110011335757225100236730ustar00rootroot00000000000000/* * flasky.css_t * ~~~~~~~~~~~~ * * Sphinx stylesheet -- flasky theme based on nature theme. * * :copyright: Copyright 2007-2010 by the Sphinx team, see AUTHORS. * :license: BSD, see LICENSE for details. * */ @import url("basic.css"); /* -- page layout ----------------------------------------------------------- */ body { font-family: 'Georgia', serif; font-size: 17px; color: #000; background: white; margin: 0; padding: 0; } div.documentwrapper { float: left; width: 100%; } div.bodywrapper { margin: 40px auto 0 auto; width: 700px; } hr { border: 1px solid #B1B4B6; } div.body { background-color: #ffffff; color: #3E4349; padding: 0 30px 30px 30px; } img.floatingflask { padding: 0 0 10px 10px; float: right; } div.footer { text-align: right; color: #888; padding: 10px; font-size: 14px; width: 650px; margin: 0 auto 40px auto; } div.footer a { color: #888; text-decoration: underline; } div.related { line-height: 32px; color: #888; } div.related ul { padding: 0 0 0 10px; } div.related a { color: #444; } /* -- body styles ----------------------------------------------------------- */ a { color: #004B6B; text-decoration: underline; } a:hover { color: #6D4100; text-decoration: underline; } div.body { padding-bottom: 40px; /* saved for footer */ } div.body h1, div.body h2, div.body h3, div.body h4, div.body h5, div.body h6 { font-family: 'Garamond', 'Georgia', serif; font-weight: normal; margin: 30px 0px 10px 0px; padding: 0; } {% if theme_index_logo %} div.indexwrapper h1 { text-indent: -999999px; background: url({{ theme_index_logo }}) no-repeat center center; height: {{ theme_index_logo_height }}; } {% endif %} div.body h2 { font-size: 180%; } div.body h3 { font-size: 150%; } div.body h4 { font-size: 130%; } div.body h5 { font-size: 100%; } div.body h6 { font-size: 100%; } a.headerlink { color: white; padding: 0 4px; text-decoration: none; } a.headerlink:hover { color: #444; background: #eaeaea; } div.body p, div.body dd, div.body li { line-height: 1.4em; } div.admonition { background: #fafafa; margin: 20px -30px; padding: 10px 30px; border-top: 1px solid #ccc; border-bottom: 1px solid #ccc; } div.admonition p.admonition-title { font-family: 'Garamond', 'Georgia', serif; font-weight: normal; font-size: 24px; margin: 0 0 10px 0; padding: 0; line-height: 1; } div.admonition p.last { margin-bottom: 0; } div.highlight{ background-color: white; } dt:target, .highlight { background: #FAF3E8; } 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, tt { font-family: 'Consolas', 'Menlo', 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono', monospace; font-size: 0.85em; } img.screenshot { } tt.descname, tt.descclassname { font-size: 0.95em; } tt.descname { padding-right: 0.08em; } img.screenshot { -moz-box-shadow: 2px 2px 4px #eee; -webkit-box-shadow: 2px 2px 4px #eee; box-shadow: 2px 2px 4px #eee; } table.docutils { border: 1px solid #888; -moz-box-shadow: 2px 2px 4px #eee; -webkit-box-shadow: 2px 2px 4px #eee; box-shadow: 2px 2px 4px #eee; } table.docutils td, table.docutils th { border: 1px solid #888; padding: 0.25em 0.7em; } table.field-list, table.footnote { border: none; -moz-box-shadow: none; -webkit-box-shadow: none; box-shadow: none; } table.footnote { margin: 15px 0; width: 100%; border: 1px solid #eee; } table.field-list th { padding: 0 0.8em 0 0; } table.field-list td { padding: 0; } table.footnote td { padding: 0.5em; } dl { margin: 0; padding: 0; } dl dd { margin-left: 30px; } pre { padding: 0; margin: 15px -30px; padding: 8px; line-height: 1.3em; padding: 7px 30px; background: #eee; border-radius: 2px; -moz-border-radius: 2px; -webkit-border-radius: 2px; } dl pre { margin-left: -60px; padding-left: 60px; } tt { background-color: #ecf0f3; color: #222; /* padding: 1px 2px; */ } tt.xref, a tt { background-color: #FBFBFB; } a:hover tt { background: #EEE; } mistune-0.8.4/docs/_themes/flask_small/theme.conf000066400000000000000000000002621335757225100220360ustar00rootroot00000000000000[theme] inherit = basic stylesheet = flasky.css nosidebar = true pygments_style = flask_theme_support.FlaskyStyle [options] index_logo = index_logo_height = 120px github_fork = mistune-0.8.4/docs/_themes/flask_theme_support.py000066400000000000000000000114131335757225100222250ustar00rootroot00000000000000# flasky extensions. flasky pygments style based on tango style from pygments.style import Style from pygments.token import Keyword, Name, Comment, String, Error, \ Number, Operator, Generic, Whitespace, Punctuation, Other, Literal class FlaskyStyle(Style): background_color = "#f8f8f8" default_style = "" styles = { # No corresponding class for the following: #Text: "", # class: '' Whitespace: "underline #f8f8f8", # class: 'w' Error: "#a40000 border:#ef2929", # class: 'err' Other: "#000000", # class 'x' Comment: "italic #8f5902", # class: 'c' Comment.Preproc: "noitalic", # class: 'cp' Keyword: "bold #004461", # class: 'k' Keyword.Constant: "bold #004461", # class: 'kc' Keyword.Declaration: "bold #004461", # class: 'kd' Keyword.Namespace: "bold #004461", # class: 'kn' Keyword.Pseudo: "bold #004461", # class: 'kp' Keyword.Reserved: "bold #004461", # class: 'kr' Keyword.Type: "bold #004461", # class: 'kt' Operator: "#582800", # class: 'o' Operator.Word: "bold #004461", # class: 'ow' - like keywords Punctuation: "bold #000000", # class: 'p' # because special names such as Name.Class, Name.Function, etc. # are not recognized as such later in the parsing, we choose them # to look the same as ordinary variables. Name: "#000000", # class: 'n' Name.Attribute: "#c4a000", # class: 'na' - to be revised Name.Builtin: "#004461", # class: 'nb' Name.Builtin.Pseudo: "#3465a4", # class: 'bp' Name.Class: "#000000", # class: 'nc' - to be revised Name.Constant: "#000000", # class: 'no' - to be revised Name.Decorator: "#888", # class: 'nd' - to be revised Name.Entity: "#ce5c00", # class: 'ni' Name.Exception: "bold #cc0000", # class: 'ne' Name.Function: "#000000", # class: 'nf' Name.Property: "#000000", # class: 'py' Name.Label: "#f57900", # class: 'nl' Name.Namespace: "#000000", # class: 'nn' - to be revised Name.Other: "#000000", # class: 'nx' Name.Tag: "bold #004461", # class: 'nt' - like a keyword Name.Variable: "#000000", # class: 'nv' - to be revised Name.Variable.Class: "#000000", # class: 'vc' - to be revised Name.Variable.Global: "#000000", # class: 'vg' - to be revised Name.Variable.Instance: "#000000", # class: 'vi' - to be revised Number: "#990000", # class: 'm' Literal: "#000000", # class: 'l' Literal.Date: "#000000", # class: 'ld' String: "#4e9a06", # class: 's' String.Backtick: "#4e9a06", # class: 'sb' String.Char: "#4e9a06", # class: 'sc' String.Doc: "italic #8f5902", # class: 'sd' - like a comment String.Double: "#4e9a06", # class: 's2' String.Escape: "#4e9a06", # class: 'se' String.Heredoc: "#4e9a06", # class: 'sh' String.Interpol: "#4e9a06", # class: 'si' String.Other: "#4e9a06", # class: 'sx' String.Regex: "#4e9a06", # class: 'sr' String.Single: "#4e9a06", # class: 's1' String.Symbol: "#4e9a06", # class: 'ss' Generic: "#000000", # class: 'g' Generic.Deleted: "#a40000", # class: 'gd' Generic.Emph: "italic #000000", # class: 'ge' Generic.Error: "#ef2929", # class: 'gr' Generic.Heading: "bold #000080", # class: 'gh' Generic.Inserted: "#00A000", # class: 'gi' Generic.Output: "#888", # class: 'go' Generic.Prompt: "#745334", # class: 'gp' Generic.Strong: "bold #000000", # class: 'gs' Generic.Subheading: "bold #800080", # class: 'gu' Generic.Traceback: "bold #a40000", # class: 'gt' } mistune-0.8.4/docs/conf.py000066400000000000000000000176161335757225100154630ustar00rootroot00000000000000# -*- coding: utf-8 -*- # # mistune documentation build configuration file, created by # sphinx-quickstart on Fri Aug 16 15:28:41 2013. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys, os # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. sys.path.insert(0, os.path.abspath('..')) sys.path.append(os.path.abspath('_themes')) # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.autodoc'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = u'mistune' copyright = u'2014, Hsiaoming Yang' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. import mistune version = mistune.__version__ # The full version, including alpha/beta/rc tags. release = version # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build'] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. #pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. #modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. #keep_warnings = False # -- Options for HTML output --------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'flask_small' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. html_theme_options = { 'github_fork': 'lepture/mistune' } # Add any paths that contain custom themes here, relative to this directory. html_theme_path = ['_themes'] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. #html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_domain_indices = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, links to the reST sources are added to the pages. #html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. #html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. #html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = 'mistunedoc' # -- Options for LaTeX output -------------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). #'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). #'pointsize': '10pt', # Additional stuff for the LaTeX preamble. #'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ ('index', 'mistune.tex', u'mistune Documentation', u'Hsiaoming Yang', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # If true, show page references after internal links. #latex_show_pagerefs = False # If true, show URL addresses after external links. #latex_show_urls = False # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_domain_indices = True # -- Options for manual page output -------------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ ('index', 'mistune', u'mistune Documentation', [u'Hsiaoming Yang'], 1) ] # If true, show URL addresses after external links. #man_show_urls = False # -- Options for Texinfo output ------------------------------------------------ # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ ('index', 'mistune', u'mistune Documentation', u'Hsiaoming Yang', 'mistune', 'One line description of project.', 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. #texinfo_appendices = [] # If false, no module index is generated. #texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. #texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. #texinfo_no_detailmenu = False mistune-0.8.4/docs/index.rst000066400000000000000000000004271335757225100160150ustar00rootroot00000000000000.. include:: ../README.rst Developer Guide --------------- Here is the API reference for mistune. .. module:: mistune .. autoclass:: Renderer :members: .. autoclass:: Markdown :members: .. autofunction:: markdown .. autofunction:: escape .. include:: ../CHANGES.rst mistune-0.8.4/mistune.py000066400000000000000000001072441335757225100152670ustar00rootroot00000000000000# coding: utf-8 """ mistune ~~~~~~~ The fastest markdown parser in pure Python with renderer feature. :copyright: (c) 2014 - 2018 by Hsiaoming Yang. """ import re import inspect __version__ = '0.8.4' __author__ = 'Hsiaoming Yang ' __all__ = [ 'BlockGrammar', 'BlockLexer', 'InlineGrammar', 'InlineLexer', 'Renderer', 'Markdown', 'markdown', 'escape', ] _key_pattern = re.compile(r'\s+') _nonalpha_pattern = re.compile(r'\W') _escape_pattern = re.compile(r'&(?!#?\w+;)') _newline_pattern = re.compile(r'\r\n|\r') _block_quote_leading_pattern = re.compile(r'^ *> ?', flags=re.M) _block_code_leading_pattern = re.compile(r'^ {4}', re.M) _inline_tags = [ 'a', 'em', 'strong', 'small', 's', 'cite', 'q', 'dfn', 'abbr', 'data', 'time', 'code', 'var', 'samp', 'kbd', 'sub', 'sup', 'i', 'b', 'u', 'mark', 'ruby', 'rt', 'rp', 'bdi', 'bdo', 'span', 'br', 'wbr', 'ins', 'del', 'img', 'font', ] _pre_tags = ['pre', 'script', 'style'] _valid_end = r'(?!:/|[^\w\s@]*@)\b' _valid_attr = r'''\s*[a-zA-Z\-](?:\s*\=\s*(?:"[^"]*"|'[^']*'|[^\s'">]+))?''' _block_tag = r'(?!(?:%s)\b)\w+%s' % ('|'.join(_inline_tags), _valid_end) _scheme_blacklist = ('javascript:', 'vbscript:') def _pure_pattern(regex): pattern = regex.pattern if pattern.startswith('^'): pattern = pattern[1:] return pattern def _keyify(key): key = escape(key.lower(), quote=True) return _key_pattern.sub(' ', key) def escape(text, quote=False, smart_amp=True): """Replace special characters "&", "<" and ">" to HTML-safe sequences. The original cgi.escape will always escape "&", but you can control this one for a smart escape amp. :param quote: if set to True, " and ' will be escaped. :param smart_amp: if set to False, & will always be escaped. """ if smart_amp: text = _escape_pattern.sub('&', text) else: text = text.replace('&', '&') text = text.replace('<', '<') text = text.replace('>', '>') if quote: text = text.replace('"', '"') text = text.replace("'", ''') return text def escape_link(url): """Remove dangerous URL schemes like javascript: and escape afterwards.""" lower_url = url.lower().strip('\x00\x1a \n\r\t') for scheme in _scheme_blacklist: if re.sub(r'[^A-Za-z0-9\/:]+', '', lower_url).startswith(scheme): return '' return escape(url, quote=True, smart_amp=False) def preprocessing(text, tab=4): text = _newline_pattern.sub('\n', text) text = text.expandtabs(tab) text = text.replace('\u2424', '\n') pattern = re.compile(r'^ +$', re.M) return pattern.sub('', text) class BlockGrammar(object): """Grammars for block level tokens.""" def_links = re.compile( r'^ *\[([^^\]]+)\]: *' # [key]: r']+)>?' # or link r'(?: +["(]([^\n]+)[")])? *(?:\n+|$)' ) def_footnotes = re.compile( r'^\[\^([^\]]+)\]: *(' r'[^\n]*(?:\n+|$)' # [^key]: r'(?: {1,}[^\n]*(?:\n+|$))*' r')' ) newline = re.compile(r'^\n+') block_code = re.compile(r'^( {4}[^\n]+\n*)+') fences = re.compile( r'^ *(`{3,}|~{3,}) *([^`\s]+)? *\n' # ```lang r'([\s\S]+?)\s*' r'\1 *(?:\n+|$)' # ``` ) hrule = re.compile(r'^ {0,3}[-*_](?: *[-*_]){2,} *(?:\n+|$)') heading = re.compile(r'^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)') lheading = re.compile(r'^([^\n]+)\n *(=|-)+ *(?:\n+|$)') block_quote = re.compile(r'^( *>[^\n]+(\n[^\n]+)*\n*)+') list_block = re.compile( r'^( *)(?=[*+-]|\d+\.)(([*+-])?(?:\d+\.)?) [\s\S]+?' r'(?:' r'\n+(?=\1?(?:[-*_] *){3,}(?:\n+|$))' # hrule r'|\n+(?=%s)' # def links r'|\n+(?=%s)' # def footnotes\ r'|\n+(?=\1(?(3)\d+\.|[*+-]) )' # heterogeneous bullet r'|\n{2,}' r'(?! )' r'(?!\1(?:[*+-]|\d+\.) )\n*' r'|' r'\s*$)' % ( _pure_pattern(def_links), _pure_pattern(def_footnotes), ) ) list_item = re.compile( r'^(( *)(?:[*+-]|\d+\.) [^\n]*' r'(?:\n(?!\2(?:[*+-]|\d+\.) )[^\n]*)*)', flags=re.M ) list_bullet = re.compile(r'^ *(?:[*+-]|\d+\.) +') paragraph = re.compile( r'^((?:[^\n]+\n?(?!' r'%s|%s|%s|%s|%s|%s|%s|%s|%s' r'))+)\n*' % ( _pure_pattern(fences).replace(r'\1', r'\2'), _pure_pattern(list_block).replace(r'\1', r'\3'), _pure_pattern(hrule), _pure_pattern(heading), _pure_pattern(lheading), _pure_pattern(block_quote), _pure_pattern(def_links), _pure_pattern(def_footnotes), '<' + _block_tag, ) ) block_html = re.compile( r'^ *(?:%s|%s|%s) *(?:\n{2,}|\s*$)' % ( r'', r'<(%s)((?:%s)*?)>([\s\S]*?)<\/\1>' % (_block_tag, _valid_attr), r'<%s(?:%s)*?\s*\/?>' % (_block_tag, _valid_attr), ) ) table = re.compile( r'^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*' ) nptable = re.compile( r'^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*' ) text = re.compile(r'^[^\n]+') class BlockLexer(object): """Block level lexer for block grammars.""" grammar_class = BlockGrammar default_rules = [ 'newline', 'hrule', 'block_code', 'fences', 'heading', 'nptable', 'lheading', 'block_quote', 'list_block', 'block_html', 'def_links', 'def_footnotes', 'table', 'paragraph', 'text' ] list_rules = ( 'newline', 'block_code', 'fences', 'lheading', 'hrule', 'block_quote', 'list_block', 'block_html', 'text', ) footnote_rules = ( 'newline', 'block_code', 'fences', 'heading', 'nptable', 'lheading', 'hrule', 'block_quote', 'list_block', 'block_html', 'table', 'paragraph', 'text' ) def __init__(self, rules=None, **kwargs): self.tokens = [] self.def_links = {} self.def_footnotes = {} if not rules: rules = self.grammar_class() self.rules = rules self._max_recursive_depth = kwargs.get('max_recursive_depth', 6) self._list_depth = 0 self._blockquote_depth = 0 def __call__(self, text, rules=None): return self.parse(text, rules) def parse(self, text, rules=None): text = text.rstrip('\n') if not rules: rules = self.default_rules def manipulate(text): for key in rules: rule = getattr(self.rules, key) m = rule.match(text) if not m: continue getattr(self, 'parse_%s' % key)(m) return m return False # pragma: no cover while text: m = manipulate(text) if m is not False: text = text[len(m.group(0)):] continue if text: # pragma: no cover raise RuntimeError('Infinite loop at: %s' % text) return self.tokens def parse_newline(self, m): length = len(m.group(0)) if length > 1: self.tokens.append({'type': 'newline'}) def parse_block_code(self, m): # clean leading whitespace code = _block_code_leading_pattern.sub('', m.group(0)) self.tokens.append({ 'type': 'code', 'lang': None, 'text': code, }) def parse_fences(self, m): self.tokens.append({ 'type': 'code', 'lang': m.group(2), 'text': m.group(3), }) def parse_heading(self, m): self.tokens.append({ 'type': 'heading', 'level': len(m.group(1)), 'text': m.group(2), }) def parse_lheading(self, m): """Parse setext heading.""" self.tokens.append({ 'type': 'heading', 'level': 1 if m.group(2) == '=' else 2, 'text': m.group(1), }) def parse_hrule(self, m): self.tokens.append({'type': 'hrule'}) def parse_list_block(self, m): bull = m.group(2) self.tokens.append({ 'type': 'list_start', 'ordered': '.' in bull, }) self._list_depth += 1 if self._list_depth > self._max_recursive_depth: self.tokens.append({'type': 'list_item_start'}) self.parse_text(m) self.tokens.append({'type': 'list_item_end'}) else: cap = m.group(0) self._process_list_item(cap, bull) self.tokens.append({'type': 'list_end'}) self._list_depth -= 1 def _process_list_item(self, cap, bull): cap = self.rules.list_item.findall(cap) _next = False length = len(cap) for i in range(length): item = cap[i][0] # remove the bullet space = len(item) item = self.rules.list_bullet.sub('', item) # outdent if '\n ' in item: space = space - len(item) pattern = re.compile(r'^ {1,%d}' % space, flags=re.M) item = pattern.sub('', item) # determine whether item is loose or not loose = _next if not loose and re.search(r'\n\n(?!\s*$)', item): loose = True rest = len(item) if i != length - 1 and rest: _next = item[rest-1] == '\n' if not loose: loose = _next if loose: t = 'loose_item_start' else: t = 'list_item_start' self.tokens.append({'type': t}) # recurse self.parse(item, self.list_rules) self.tokens.append({'type': 'list_item_end'}) def parse_block_quote(self, m): self.tokens.append({'type': 'block_quote_start'}) self._blockquote_depth += 1 if self._blockquote_depth > self._max_recursive_depth: self.parse_text(m) else: # clean leading > cap = _block_quote_leading_pattern.sub('', m.group(0)) self.parse(cap) self.tokens.append({'type': 'block_quote_end'}) self._blockquote_depth -= 1 def parse_def_links(self, m): key = _keyify(m.group(1)) self.def_links[key] = { 'link': m.group(2), 'title': m.group(3), } def parse_def_footnotes(self, m): key = _keyify(m.group(1)) if key in self.def_footnotes: # footnote is already defined return self.def_footnotes[key] = 0 self.tokens.append({ 'type': 'footnote_start', 'key': key, }) text = m.group(2) if '\n' in text: lines = text.split('\n') whitespace = None for line in lines[1:]: space = len(line) - len(line.lstrip()) if space and (not whitespace or space < whitespace): whitespace = space newlines = [lines[0]] for line in lines[1:]: newlines.append(line[whitespace:]) text = '\n'.join(newlines) self.parse(text, self.footnote_rules) self.tokens.append({ 'type': 'footnote_end', 'key': key, }) def parse_table(self, m): item = self._process_table(m) cells = re.sub(r'(?: *\| *)?\n$', '', m.group(3)) cells = cells.split('\n') for i, v in enumerate(cells): v = re.sub(r'^ *\| *| *\| *$', '', v) cells[i] = re.split(r' *(?~|])') # \* \+ \! .... inline_html = re.compile( r'^(?:%s|%s|%s)' % ( r'', r'<(\w+%s)((?:%s)*?)\s*>([\s\S]*?)<\/\1>' % ( _valid_end, _valid_attr), r'<\w+%s(?:%s)*?\s*\/?>' % (_valid_end, _valid_attr), ) ) autolink = re.compile(r'^<([^ >]+(@|:)[^ >]+)>') link = re.compile( r'^!?\[(' r'(?:\[[^^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*' r')\]\(' r'''\s*(<)?([\s\S]*?)(?(2)>)(?:\s+['"]([\s\S]*?)['"])?\s*''' r'\)' ) reflink = re.compile( r'^!?\[(' r'(?:\[[^^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*' r')\]\s*\[([^^\]]*)\]' ) nolink = re.compile(r'^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]') url = re.compile(r'''^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])''') double_emphasis = re.compile( r'^_{2}([\s\S]+?)_{2}(?!_)' # __word__ r'|' r'^\*{2}([\s\S]+?)\*{2}(?!\*)' # **word** ) emphasis = re.compile( r'^\b_((?:__|[^_])+?)_\b' # _word_ r'|' r'^\*((?:\*\*|[^\*])+?)\*(?!\*)' # *word* ) code = re.compile(r'^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)') # `code` linebreak = re.compile(r'^ {2,}\n(?!\s*$)') strikethrough = re.compile(r'^~~(?=\S)([\s\S]*?\S)~~') # ~~word~~ footnote = re.compile(r'^\[\^([^\]]+)\]') text = re.compile(r'^[\s\S]+?(?=[\\%s' % (tag, extra, text, tag) else: html = m.group(0) return self.renderer.inline_html(html) def output_footnote(self, m): key = _keyify(m.group(1)) if key not in self.footnotes: return None if self.footnotes[key]: return None self.footnote_index += 1 self.footnotes[key] = self.footnote_index return self.renderer.footnote_ref(key, self.footnote_index) def output_link(self, m): return self._process_link(m, m.group(3), m.group(4)) def output_reflink(self, m): key = _keyify(m.group(2) or m.group(1)) if key not in self.links: return None ret = self.links[key] return self._process_link(m, ret['link'], ret['title']) def output_nolink(self, m): key = _keyify(m.group(1)) if key not in self.links: return None ret = self.links[key] return self._process_link(m, ret['link'], ret['title']) def _process_link(self, m, link, title=None): line = m.group(0) text = m.group(1) if line[0] == '!': return self.renderer.image(link, title, text) self._in_link = True text = self.output(text) self._in_link = False return self.renderer.link(link, title, text) def output_double_emphasis(self, m): text = m.group(2) or m.group(1) text = self.output(text) return self.renderer.double_emphasis(text) def output_emphasis(self, m): text = m.group(2) or m.group(1) text = self.output(text) return self.renderer.emphasis(text) def output_code(self, m): text = m.group(2) return self.renderer.codespan(text) def output_linebreak(self, m): return self.renderer.linebreak() def output_strikethrough(self, m): text = self.output(m.group(1)) return self.renderer.strikethrough(text) def output_text(self, m): text = m.group(0) return self.renderer.text(text) class Renderer(object): """The default HTML renderer for rendering Markdown. """ def __init__(self, **kwargs): self.options = kwargs def placeholder(self): """Returns the default, empty output value for the renderer. All renderer methods use the '+=' operator to append to this value. Default is a string so rendering HTML can build up a result string with the rendered Markdown. Can be overridden by Renderer subclasses to be types like an empty list, allowing the renderer to create a tree-like structure to represent the document (which can then be reprocessed later into a separate format like docx or pdf). """ return '' def block_code(self, code, lang=None): """Rendering block level code. ``pre > code``. :param code: text content of the code block. :param lang: language of the given code. """ code = code.rstrip('\n') if not lang: code = escape(code, smart_amp=False) return '
%s\n
\n' % code code = escape(code, quote=True, smart_amp=False) return '
%s\n
\n' % (lang, code) def block_quote(self, text): """Rendering
with the given text. :param text: text content of the blockquote. """ return '
%s\n
\n' % text.rstrip('\n') def block_html(self, html): """Rendering block level pure html content. :param html: text content of the html snippet. """ if self.options.get('skip_style') and \ html.lower().startswith('`` ``

``. :param text: rendered text content for the header. :param level: a number for the header level, for example: 1. :param raw: raw text content of the header. """ return '%s\n' % (level, text, level) def hrule(self): """Rendering method for ``
`` tag.""" if self.options.get('use_xhtml'): return '
\n' return '
\n' def list(self, body, ordered=True): """Rendering list tags like ``
    `` and ``
      ``. :param body: body contents of the list. :param ordered: whether this list is ordered or not. """ tag = 'ul' if ordered: tag = 'ol' return '<%s>\n%s\n' % (tag, body, tag) def list_item(self, text): """Rendering list item snippet. Like ``
    1. ``.""" return '
    2. %s
    3. \n' % text def paragraph(self, text): """Rendering paragraph tags. Like ``

      ``.""" return '

      %s

      \n' % text.strip(' ') def table(self, header, body): """Rendering table element. Wrap header and body in it. :param header: header part of the table. :param body: body part of the table. """ return ( '\n%s\n' '\n%s\n
      \n' ) % (header, body) def table_row(self, content): """Rendering a table row. Like ````. :param content: content of current table row. """ return '\n%s\n' % content def table_cell(self, content, **flags): """Rendering a table cell. Like ```` ````. :param content: content of current table cell. :param header: whether this is header or not. :param align: align of current table cell. """ if flags['header']: tag = 'th' else: tag = 'td' align = flags['align'] if not align: return '<%s>%s\n' % (tag, content, tag) return '<%s style="text-align:%s">%s\n' % ( tag, align, content, tag ) def double_emphasis(self, text): """Rendering **strong** text. :param text: text content for emphasis. """ return '%s' % text def emphasis(self, text): """Rendering *emphasis* text. :param text: text content for emphasis. """ return '%s' % text def codespan(self, text): """Rendering inline `code` text. :param text: text content for inline code. """ text = escape(text.rstrip(), smart_amp=False) return '%s' % text def linebreak(self): """Rendering line break like ``
      ``.""" if self.options.get('use_xhtml'): return '
      \n' return '
      \n' def strikethrough(self, text): """Rendering ~~strikethrough~~ text. :param text: text content for strikethrough. """ return '%s' % text def text(self, text): """Rendering unformatted text. :param text: text content. """ if self.options.get('parse_block_html'): return text return escape(text) def escape(self, text): """Rendering escape sequence. :param text: text content. """ return escape(text) def autolink(self, link, is_email=False): """Rendering a given link or email address. :param link: link content or email address. :param is_email: whether this is an email or not. """ text = link = escape_link(link) if is_email: link = 'mailto:%s' % link return '%s' % (link, text) def link(self, link, title, text): """Rendering a given link with content and title. :param link: href link for ```` tag. :param title: title content for `title` attribute. :param text: text content for description. """ link = escape_link(link) if not title: return '%s' % (link, text) title = escape(title, quote=True) return '%s' % (link, title, text) def image(self, src, title, text): """Rendering a image with title and text. :param src: source link of the image. :param title: title text of the image. :param text: alt text of the image. """ src = escape_link(src) text = escape(text, quote=True) if title: title = escape(title, quote=True) html = '%s' % html return '%s>' % html def inline_html(self, html): """Rendering span level pure html content. :param html: text content of the html snippet. """ if self.options.get('escape'): return escape(html) return html def newline(self): """Rendering newline element.""" return '' def footnote_ref(self, key, index): """Rendering the ref anchor of a footnote. :param key: identity key for the footnote. :param index: the index count of current footnote. """ html = ( '' '%d' ) % (escape(key), escape(key), index) return html def footnote_item(self, key, text): """Rendering a footnote item. :param key: identity key for the footnote. :param text: text content of the footnote. """ back = ( '' ) % escape(key) text = text.rstrip() if text.endswith('

      '): text = re.sub(r'<\/p>$', r'%s

      ' % back, text) else: text = '%s

      %s

      ' % (text, back) html = '
    4. %s
    5. \n' % (escape(key), text) return html def footnotes(self, text): """Wrapper for all footnotes. :param text: contents of all footnotes. """ html = '
      \n%s
        %s
      \n
      \n' return html % (self.hrule(), text) class Markdown(object): """The Markdown parser. :param renderer: An instance of ``Renderer``. :param inline: An inline lexer class or instance. :param block: A block lexer class or instance. """ def __init__(self, renderer=None, inline=None, block=None, **kwargs): if not renderer: renderer = Renderer(**kwargs) else: kwargs.update(renderer.options) self.renderer = renderer if inline and inspect.isclass(inline): inline = inline(renderer, **kwargs) if block and inspect.isclass(block): block = block(**kwargs) if inline: self.inline = inline else: self.inline = InlineLexer(renderer, **kwargs) self.block = block or BlockLexer(BlockGrammar()) self.footnotes = [] self.tokens = [] # detect if it should parse text in block html self._parse_block_html = kwargs.get('parse_block_html') def __call__(self, text): return self.parse(text) def render(self, text): """Render the Markdown text. :param text: markdown formatted text content. """ return self.parse(text) def parse(self, text): out = self.output(preprocessing(text)) keys = self.block.def_footnotes # reset block self.block.def_links = {} self.block.def_footnotes = {} # reset inline self.inline.links = {} self.inline.footnotes = {} if not self.footnotes: return out footnotes = filter(lambda o: keys.get(o['key']), self.footnotes) self.footnotes = sorted( footnotes, key=lambda o: keys.get(o['key']), reverse=True ) body = self.renderer.placeholder() while self.footnotes: note = self.footnotes.pop() body += self.renderer.footnote_item( note['key'], note['text'] ) out += self.renderer.footnotes(body) return out def pop(self): if not self.tokens: return None self.token = self.tokens.pop() return self.token def peek(self): if self.tokens: return self.tokens[-1] return None # pragma: no cover def output(self, text, rules=None): self.tokens = self.block(text, rules) self.tokens.reverse() self.inline.setup(self.block.def_links, self.block.def_footnotes) out = self.renderer.placeholder() while self.pop(): out += self.tok() return out def tok(self): t = self.token['type'] # sepcial cases if t.endswith('_start'): t = t[:-6] return getattr(self, 'output_%s' % t)() def tok_text(self): text = self.token['text'] while self.peek()['type'] == 'text': text += '\n' + self.pop()['text'] return self.inline(text) def output_newline(self): return self.renderer.newline() def output_hrule(self): return self.renderer.hrule() def output_heading(self): return self.renderer.header( self.inline(self.token['text']), self.token['level'], self.token['text'], ) def output_code(self): return self.renderer.block_code( self.token['text'], self.token['lang'] ) def output_table(self): aligns = self.token['align'] aligns_length = len(aligns) cell = self.renderer.placeholder() # header part header = self.renderer.placeholder() for i, value in enumerate(self.token['header']): align = aligns[i] if i < aligns_length else None flags = {'header': True, 'align': align} cell += self.renderer.table_cell(self.inline(value), **flags) header += self.renderer.table_row(cell) # body part body = self.renderer.placeholder() for i, row in enumerate(self.token['cells']): cell = self.renderer.placeholder() for j, value in enumerate(row): align = aligns[j] if j < aligns_length else None flags = {'header': False, 'align': align} cell += self.renderer.table_cell(self.inline(value), **flags) body += self.renderer.table_row(cell) return self.renderer.table(header, body) def output_block_quote(self): body = self.renderer.placeholder() while self.pop()['type'] != 'block_quote_end': body += self.tok() return self.renderer.block_quote(body) def output_list(self): ordered = self.token['ordered'] body = self.renderer.placeholder() while self.pop()['type'] != 'list_end': body += self.tok() return self.renderer.list(body, ordered) def output_list_item(self): body = self.renderer.placeholder() while self.pop()['type'] != 'list_item_end': if self.token['type'] == 'text': body += self.tok_text() else: body += self.tok() return self.renderer.list_item(body) def output_loose_item(self): body = self.renderer.placeholder() while self.pop()['type'] != 'list_item_end': body += self.tok() return self.renderer.list_item(body) def output_footnote(self): self.inline._in_footnote = True body = self.renderer.placeholder() key = self.token['key'] while self.pop()['type'] != 'footnote_end': body += self.tok() self.footnotes.append({'key': key, 'text': body}) self.inline._in_footnote = False return self.renderer.placeholder() def output_close_html(self): text = self.token['text'] return self.renderer.block_html(text) def output_open_html(self): text = self.token['text'] tag = self.token['tag'] if self._parse_block_html and tag not in _pre_tags: text = self.inline(text, rules=self.inline.inline_html_rules) extra = self.token.get('extra') or '' html = '<%s%s>%s' % (tag, extra, text, tag) return self.renderer.block_html(html) def output_paragraph(self): return self.renderer.paragraph(self.inline(self.token['text'])) def output_text(self): return self.renderer.paragraph(self.tok_text()) def markdown(text, escape=True, **kwargs): """Render markdown formatted text to html. :param text: markdown formatted text content. :param escape: if set to False, all html tags will not be escaped. :param use_xhtml: output with xhtml tags. :param hard_wrap: if set to True, it will use the GFM line breaks feature. :param parse_block_html: parse text only in block level html. :param parse_inline_html: parse text only in inline level html. """ return Markdown(escape=escape, **kwargs)(text) mistune-0.8.4/setup.cfg000066400000000000000000000001151335757225100150370ustar00rootroot00000000000000[wheel] universal = 1 [check-manifest] ignore = .travis.yml tox.ini mistune-0.8.4/setup.py000066400000000000000000000026221335757225100147350ustar00rootroot00000000000000#!/usr/bin/env python # coding: utf-8 import mistune from setuptools import setup def fread(filepath): with open(filepath, 'r') as f: return f.read() setup( name='mistune', version=mistune.__version__, url='https://github.com/lepture/mistune', author='Hsiaoming Yang', author_email='me@lepture.com', description='The fastest markdown parser in pure Python', long_description=fread('README.rst'), license='BSD', py_modules=['mistune'], zip_safe=False, platforms='any', tests_require=['nose'], test_suite='nose.collector', classifiers=[ 'Development Status :: 4 - Beta', 'Environment :: Web Environment', 'Intended Audience :: Developers', 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy', 'Topic :: Text Processing :: Markup', 'Topic :: Software Development :: Libraries :: Python Modules' ] ) mistune-0.8.4/tests/000077500000000000000000000000001335757225100143635ustar00rootroot00000000000000mistune-0.8.4/tests/__init__.py000066400000000000000000000000001335757225100164620ustar00rootroot00000000000000mistune-0.8.4/tests/bench.py000066400000000000000000000046261335757225100160240ustar00rootroot00000000000000# coding: utf-8 import os import time import functools class benchmark(object): suites = [] def __init__(self, name): self._name = name def __call__(self, func): @functools.wraps(func) def wrapper(text, loops=1000): start = time.clock() while loops: func(text) loops -= 1 end = time.clock() return end - start # register benchmark.suites.append((self._name, wrapper)) return wrapper @classmethod def bench(cls, text, loops=1000): print('Parsing the Markdown Syntax document %d times...' % loops) for name, func in cls.suites: try: total = func(text, loops=loops) print('{0}: {1}'.format(name, total)) except ImportError: print('{0} is not available'.format(name)) @benchmark('mistune') def benchmark_mistune(text): import mistune mistune.markdown(text) @benchmark('misaka') def benchmark_misaka(text): import misaka as m # mistune has all these features extensions = ( m.EXT_NO_INTRA_EMPHASIS | m.EXT_FENCED_CODE | m.EXT_AUTOLINK | m.EXT_TABLES | m.EXT_STRIKETHROUGH ) md = m.Markdown(m.HtmlRenderer(), extensions=extensions) md(text) @benchmark('markdown2') def benchmark_markdown2(text): import markdown2 extras = ['code-friendly', 'fenced-code-blocks', 'footnotes'] markdown2.markdown(text, extras=extras) @benchmark('markdown') def benchmark_markdown(text): import markdown markdown.markdown(text, ['extra']) @benchmark('cMarkdown') def benchmark_cMarkdown(text): import cMarkdown cMarkdown.markdown(text) @benchmark('discount') def benchmark_discount(text): import discount discount.Markdown(text).get_html_content() @benchmark('hoep') def benchmark_hoep(text): import hoep as m # mistune has all these features extensions = ( m.EXT_NO_INTRA_EMPHASIS | m.EXT_FENCED_CODE | m.EXT_AUTOLINK | m.EXT_TABLES | m.EXT_STRIKETHROUGH | m.EXT_FOOTNOTES ) md = m.Hoep(extensions=extensions) md.render(text.decode('utf-8')) if __name__ == '__main__': root = os.path.dirname(__file__) filepath = os.path.join( root, 'fixtures/normal', 'markdown_documentation_syntax.text' ) with open(filepath, 'r') as f: text = f.read() benchmark.bench(text) mistune-0.8.4/tests/fixtures/000077500000000000000000000000001335757225100162345ustar00rootroot00000000000000mistune-0.8.4/tests/fixtures/data/000077500000000000000000000000001335757225100171455ustar00rootroot00000000000000mistune-0.8.4/tests/fixtures/data/math-paragraph.md000066400000000000000000000003661335757225100223700ustar00rootroot00000000000000Water that is stored in $t$, $s_t$, must equal the storage content of the previous stage, $s_{t-1}$, plus a stochastic inflow, $I_t$, minus what is being released in $t$, $r_t$. With $s_0$ defined as the initial storage content in $t=1$, we have mistune-0.8.4/tests/fixtures/data/math.md000066400000000000000000000002211335757225100204130ustar00rootroot00000000000000\begin{equation*} \left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right) \end{equation*} mistune-0.8.4/tests/fixtures/data/tree.md000066400000000000000000000001451335757225100204260ustar00rootroot00000000000000## Title here Some text. In two paragraphs. And then a list. - foo - bar 1. meep 1. stuff mistune-0.8.4/tests/fixtures/extra/000077500000000000000000000000001335757225100173575ustar00rootroot00000000000000mistune-0.8.4/tests/fixtures/extra/autolink_lines.html000066400000000000000000000001101335757225100232550ustar00rootroot00000000000000

      hello world http://example.com

      mistune-0.8.4/tests/fixtures/extra/autolink_lines.text000066400000000000000000000000411335757225100233000ustar00rootroot00000000000000hello world mistune-0.8.4/tests/fixtures/extra/blockquote_list_item.html000066400000000000000000000001541335757225100244660ustar00rootroot00000000000000

      This fails in markdown.pl and upskirt:

      • hello

        world

      mistune-0.8.4/tests/fixtures/extra/blockquote_list_item.text000066400000000000000000000000721335757225100245050ustar00rootroot00000000000000This fails in markdown.pl and upskirt: * hello > world mistune-0.8.4/tests/fixtures/extra/case_insensitive_refs.html000066400000000000000000000000351335757225100246150ustar00rootroot00000000000000

      hi

      mistune-0.8.4/tests/fixtures/extra/case_insensitive_refs.text000066400000000000000000000000211335757225100246300ustar00rootroot00000000000000[hi] [HI]: /url mistune-0.8.4/tests/fixtures/extra/double_link.html000066400000000000000000000003601335757225100225330ustar00rootroot00000000000000

      Already linked: http://example.com/.

      Already linked: http://example.com/.

      Already linked: **http://example.com/**.

      mistune-0.8.4/tests/fixtures/extra/double_link.text000066400000000000000000000003271335757225100225560ustar00rootroot00000000000000

      Already linked: http://example.com/.

      Already linked: [http://example.com/](http://example.com/). Already linked: **http://example.com/**. mistune-0.8.4/tests/fixtures/extra/escaped_angles.html000066400000000000000000000000141335757225100231750ustar00rootroot00000000000000

      >

      mistune-0.8.4/tests/fixtures/extra/escaped_angles.text000066400000000000000000000000031335757225100232130ustar00rootroot00000000000000\> mistune-0.8.4/tests/fixtures/extra/footnotes.html000066400000000000000000000051021335757225100222630ustar00rootroot00000000000000

      This is the first paragraph.1

      • List item one.2
      • List item two.3

      Header4

      Some paragraph with a footnote5, and another6.

      Another paragraph with a named footnote7.

      This paragraph should not have a footnote marker since the footnote is undefined.[^3]

      This paragraph should not have a footnote marker since the footnote has already been used before.[^1]

      This paragraph links to a footnote with plenty of block-level content.8

      This paragraph host the footnote reference within a footnote test9.


      1. This is the first note.

      2. This is the second note.

      3. This is the third note, defined out of order.

      4. This is the fourth note.

      5. Content for fifth footnote.

      6. Content for sixth footnote spaning on three lines, with some span-level markup like emphasis, a link.

      7. Footnote beginning on the line next to the marker.

      8. Paragraph.

        • List item

        Blockquote

        Code block
        

      9. This footnote attemps to refer to another footnote. This should be impossible.[^impossible]

      mistune-0.8.4/tests/fixtures/extra/footnotes.text000066400000000000000000000024121335757225100223040ustar00rootroot00000000000000This is the first paragraph.[^first] [^first]: This is the first note. * List item one.[^second] * List item two.[^third] [^third]: This is the third note, defined out of order. [^second]: This is the second note. [^fourth]: This is the fourth note. # Header[^fourth] Some paragraph with a footnote[^1], and another[^2]. [^1]: Content for fifth footnote. [^2]: Content for sixth footnote spaning on three lines, with some span-level markup like _emphasis_, a [link][]. [link]: http://www.michelf.com/ Another paragraph with a named footnote[^fn-name]. [^fn-name]: Footnote beginning on the line next to the marker. This paragraph should not have a footnote marker since the footnote is undefined.[^3] This paragraph should not have a footnote marker since the footnote has already been used before.[^1] This paragraph links to a footnote with plenty of block-level content.[^block] [^block]: Paragraph. * List item > Blockquote Code block This paragraph host the footnote reference within a footnote test[^reference]. [^reference]: This footnote attemps to refer to another footnote. This should be impossible.[^impossible] [^impossible]: This footnote should not appear, as it is refered from another footnote, which is not allowed. mistune-0.8.4/tests/fixtures/extra/gfm_code.html000066400000000000000000000005251335757225100220120ustar00rootroot00000000000000
      var a = 'hello';
      console.log(a + ' world');
      echo "hello, ${WORLD}"
      Q: What do you call a tall person who sells stolen goods?
      A longfence!
      mistune-0.8.4/tests/fixtures/extra/gfm_code.text000066400000000000000000000003371335757225100220330ustar00rootroot00000000000000``` js var a = 'hello'; console.log(a + ' world'); ``` ~~~bash echo "hello, ${WORLD}" ~~~ ```````longfence Q: What do you call a tall person who sells stolen goods? ``````` ~~~~~~~~~~ ManyTildes A longfence! ~~~~~~~~~~ mistune-0.8.4/tests/fixtures/extra/gfm_code_hr_list.html000066400000000000000000000012721335757225100235360ustar00rootroot00000000000000

      foo

      1. bar:

        • one
          • two
            • three
            • four
            • five
      2. foo:

         line 1
         line 2
      3. foo:

        1. foo bar bar:

           some code here
          
        2. foo bar bar:

           foo
           ---
           bar
           ---
           foo
           bar
        3. foo bar bar:

           ---
           foo
           foo
           ---
           bar
        4. foo bar bar:

           foo
           ---
           bar
        5. foo

      mistune-0.8.4/tests/fixtures/extra/gfm_code_hr_list.text000066400000000000000000000010521335757225100235520ustar00rootroot00000000000000## foo 1. bar: > - one - two - three - four - five 1. foo: ``` line 1 line 2 ``` 1. foo: 1. foo `bar` bar: ``` erb some code here ``` 2. foo `bar` bar: ``` erb foo --- bar --- foo bar ``` 3. foo `bar` bar: ``` html --- foo foo --- bar ``` 4. foo `bar` bar: foo --- bar 5. foo mistune-0.8.4/tests/fixtures/extra/gfm_del.html000066400000000000000000000001171335757225100216410ustar00rootroot00000000000000

      hello hi world how are you ~~ today~~?

      mistune-0.8.4/tests/fixtures/extra/gfm_del.text000066400000000000000000000000631335757225100216610ustar00rootroot00000000000000hello ~~hi~~ world ~~how~~ are ~~you~~ ~~ today~~? mistune-0.8.4/tests/fixtures/extra/gfm_em.html000066400000000000000000000000551335757225100214770ustar00rootroot00000000000000

      These words should_not_be_emphasized.

      mistune-0.8.4/tests/fixtures/extra/gfm_em.text000066400000000000000000000000461335757225100215170ustar00rootroot00000000000000These words should_not_be_emphasized. mistune-0.8.4/tests/fixtures/extra/gfm_links.html000066400000000000000000000001531335757225100222150ustar00rootroot00000000000000

      This should be a link: http://example.com/hello-world.

      mistune-0.8.4/tests/fixtures/extra/gfm_links.text000066400000000000000000000000671335757225100222410ustar00rootroot00000000000000This should be a link: http://example.com/hello-world. mistune-0.8.4/tests/fixtures/extra/gfm_tables.html000066400000000000000000000032271335757225100223540ustar00rootroot00000000000000
      Heading 1Heading 2
      Cell 1Cell 2
      Cell 3Cell 4
      Header 1Header 2Header 3Header 4
      Cell 1Cell 2Cell 3Cell 4
      Cell 5Cell 6Cell 7Cell 8
      Test code
      Header 1Header 2
      Cell 1Cell 2
      Cell 3Cell 4
      Header 1Header 2Header 3Header 4
      Cell 1Cell 2Cell 3Cell 4
      Cell 5Cell 6Cell 7Cell 8
      Header 1Header 2
      Cell 1Cell 2 with a pipe in | inline code
      Cell 3Cell 4 with escaped | pipe for some content
      mistune-0.8.4/tests/fixtures/extra/gfm_tables.text000066400000000000000000000012631335757225100223720ustar00rootroot00000000000000| Heading 1 | Heading 2 | --------- | --------- | Cell 1 | Cell 2 | Cell 3 | Cell 4 | Header 1 | Header 2 | Header 3 | Header 4 | | :------: | -------: | :------- | -------- | | Cell 1 | Cell 2 | Cell 3 | Cell 4 | | Cell 5 | Cell 6 | Cell 7 | Cell 8 | Test code Header 1 | Header 2 -------- | -------- Cell 1 | Cell 2 Cell 3 | Cell 4 Header 1|Header 2|Header 3|Header 4 :-------|:------:|-------:|-------- Cell 1 |Cell 2 |Cell 3 |Cell 4 *Cell 5*|Cell 6 |Cell 7 |Cell 8 Header 1 | Header 2 -------- | -------------------------------------------- Cell 1 | Cell 2 with a pipe in `\|` inline code Cell 3 | Cell 4 with escaped \| pipe for some content mistune-0.8.4/tests/fixtures/extra/gfm_tables_uneven.html000066400000000000000000000002251335757225100237270ustar00rootroot00000000000000
      x y z
      1 2 3 4
      mistune-0.8.4/tests/fixtures/extra/gfm_tables_uneven.text000066400000000000000000000000421335757225100237440ustar00rootroot00000000000000x | y | z --- | --- 1 | 2 | 3 | 4 mistune-0.8.4/tests/fixtures/extra/hetero_list.html000066400000000000000000000003351335757225100225670ustar00rootroot00000000000000
      1. foo
      • bar
        1. one
        2. two
        • three
      • foobar
      mistune-0.8.4/tests/fixtures/extra/hetero_list.text000066400000000000000000000000701335757225100226030ustar00rootroot000000000000001. foo - bar 1. one 2. two * three - foobar mistune-0.8.4/tests/fixtures/extra/hr_list_break.html000066400000000000000000000001121335757225100230470ustar00rootroot00000000000000
      • hello world
      • how are

      you today?

      mistune-0.8.4/tests/fixtures/extra/hr_list_break.text000066400000000000000000000000511335757225100230710ustar00rootroot00000000000000* hello world * how are * * * you today? mistune-0.8.4/tests/fixtures/extra/lazy_blockquotes.html000066400000000000000000000000611335757225100236340ustar00rootroot00000000000000

      hi there bud

      mistune-0.8.4/tests/fixtures/extra/lazy_blockquotes.text000066400000000000000000000000171335757225100236550ustar00rootroot00000000000000> hi there bud mistune-0.8.4/tests/fixtures/extra/list_item_text.html000066400000000000000000000001061335757225100232770ustar00rootroot00000000000000
      • item1

        • item2

        text

      mistune-0.8.4/tests/fixtures/extra/list_item_text.text000066400000000000000000000000371335757225100233220ustar00rootroot00000000000000 * item1 * item2 text mistune-0.8.4/tests/fixtures/extra/loose_lists.html000066400000000000000000000011121335757225100225770ustar00rootroot00000000000000
      • hello world

        how are

      • you

      better behavior:

      • hello

        • world how

          are you

        • today

      • hi
      • hello

      • world

      • hi
      • hello
      • world

      • hi

      • hello
      • world

        how

      • hi
      • hello
      • world
      • how

        are

      • hello
      • world

      • how

        are

      mistune-0.8.4/tests/fixtures/extra/loose_lists.text000066400000000000000000000004051335757225100226230ustar00rootroot00000000000000* hello world how are * you better behavior: * hello * world how are you * today * hi * hello * world * hi * hello * world * hi * hello * world how * hi * hello * world * how are * hello * world * how are mistune-0.8.4/tests/fixtures/extra/main.html000066400000000000000000000023601335757225100211720ustar00rootroot00000000000000

      A heading

      Just a note, I've found that I can't test my markdown parser vs others. For example, both markdown.js and showdown code blocks in lists wrong. They're also completely inconsistent with regards to paragraphs in list items.

      A link. Not anymore.

      • List Item 1

      • List Item 2

        • New List Item 1 Hi, this is a list item.
        • New List Item 2 Another item
          Code goes here.
          Lots of it...
        • New List Item 3 The last item
      • List Item 3 The final item.

      • List Item 4 The real final item.

      Paragraph.

      • bq Item 1
      • bq Item 2
        • New bq Item 1
        • New bq Item 2 Text here

      Another blockquote! I really need to get more creative with mockup text.. markdown.js breaks here again

      Another Heading

      Hello world. Here is a link. And an image alt.

      Code goes here.
      Lots of it...
      mistune-0.8.4/tests/fixtures/extra/main.text000066400000000000000000000020151335757225100212070ustar00rootroot00000000000000[test]: http://google.com/ "Google" # A heading Just a note, I've found that I can't test my markdown parser vs others. For example, both markdown.js and showdown code blocks in lists wrong. They're also completely [inconsistent][test] with regards to paragraphs in list items. A link. Not anymore. * List Item 1 * List Item 2 * New List Item 1 Hi, this is a list item. * New List Item 2 Another item Code goes here. Lots of it... * New List Item 3 The last item * List Item 3 The final item. * List Item 4 The real final item. Paragraph. > * bq Item 1 > * bq Item 2 > * New bq Item 1 > * New bq Item 2 > Text here * * * > Another blockquote! > I really need to get > more creative with > mockup text.. > markdown.js breaks here again Another Heading ------------- Hello *world*. Here is a [link](//hello). And an image ![alt](src). Code goes here. Lots of it... mistune-0.8.4/tests/fixtures/extra/nested_blockquotes.html000066400000000000000000000006151335757225100241440ustar00rootroot00000000000000

      a

      b

      c

      d

      e

      f

      > g

      mistune-0.8.4/tests/fixtures/extra/nested_blockquotes.text000066400000000000000000000001061335757225100241570ustar00rootroot00000000000000> a > > b > > > c > > > > d > > > > > e > > > > > > f > > > > > > > g mistune-0.8.4/tests/fixtures/extra/nested_code.html000066400000000000000000000000461335757225100225210ustar00rootroot00000000000000

      hi ther `` ok ```

      mistune-0.8.4/tests/fixtures/extra/nested_code.text000066400000000000000000000000361335757225100225400ustar00rootroot00000000000000````` hi ther `` ok ``` ````` mistune-0.8.4/tests/fixtures/extra/nested_em.html000066400000000000000000000001411335757225100222040ustar00rootroot00000000000000

      test test test

      test test test

      mistune-0.8.4/tests/fixtures/extra/nested_em.text000066400000000000000000000000531335757225100222260ustar00rootroot00000000000000*test **test** test* _test __test__ test_ mistune-0.8.4/tests/fixtures/extra/nested_list.html000066400000000000000000000007641335757225100225710ustar00rootroot00000000000000
      • a
        • b
          • c
            • d
              • e
                • f
                  • - g
      mistune-0.8.4/tests/fixtures/extra/nested_list.text000066400000000000000000000001061335757225100225770ustar00rootroot00000000000000- a - b - c - d - e - f - g mistune-0.8.4/tests/fixtures/extra/nested_square_link.html000066400000000000000000000000671335757225100241270ustar00rootroot00000000000000

      the ] character

      mistune-0.8.4/tests/fixtures/extra/nested_square_link.text000066400000000000000000000000321335757225100241370ustar00rootroot00000000000000[the `]` character](/url) mistune-0.8.4/tests/fixtures/extra/not_a_link.html000066400000000000000000000000321335757225100223550ustar00rootroot00000000000000

      [test](not a link)

      mistune-0.8.4/tests/fixtures/extra/not_a_link.text000066400000000000000000000000241335757225100223760ustar00rootroot00000000000000\[test](not a link) mistune-0.8.4/tests/fixtures/extra/ref_paren.html000066400000000000000000000000531335757225100222040ustar00rootroot00000000000000

      hi

      mistune-0.8.4/tests/fixtures/extra/ref_paren.text000066400000000000000000000000311335757225100222200ustar00rootroot00000000000000[hi] [hi]: /url (there) mistune-0.8.4/tests/fixtures/extra/same_bullet.html000066400000000000000000000000651335757225100225420ustar00rootroot00000000000000
      • test
      • test
      • test
      mistune-0.8.4/tests/fixtures/extra/same_bullet.text000066400000000000000000000000251335757225100225560ustar00rootroot00000000000000* test + test - test mistune-0.8.4/tests/fixtures/extra/toplevel_paragraphs.gfm.html000066400000000000000000000007711335757225100250640ustar00rootroot00000000000000

      hello world how are you how are you

      hello world

      how are you

      hello world


      hello world

      how are you

      hello world

      how are you

      hello world

      how are you

      hello world

      • how are you

      hello world

      how are you

      hello world how are you

      hello world

      hello

      hello

      mistune-0.8.4/tests/fixtures/extra/toplevel_paragraphs.gfm.text000066400000000000000000000005521335757225100251010ustar00rootroot00000000000000hello world how are you how are you hello world ``` how are you ``` hello world * * * hello world # how are you hello world how are you =========== hello world > how are you hello world * how are you hello world
      how are you
      hello world how are you hello [world][how] [how]: /are/you
      hello
      hello mistune-0.8.4/tests/fixtures/extra/tricky_list.html000066400000000000000000000004731335757225100226110ustar00rootroot00000000000000

      hello world

      • hello world

      hello world

      • hello world

      hello world

      • Hello world

      hello world

      • hello world
      mistune-0.8.4/tests/fixtures/extra/tricky_list.text000066400000000000000000000002071335757225100226240ustar00rootroot00000000000000**hello** _world_ * hello world **hello** _world_ * hello world **hello** _world_ * Hello world **hello** _world_ * hello world mistune-0.8.4/tests/fixtures/normal/000077500000000000000000000000001335757225100175245ustar00rootroot00000000000000mistune-0.8.4/tests/fixtures/normal/amps_and_angles_encoding.html000066400000000000000000000007741335757225100254030ustar00rootroot00000000000000

      AT&T has an ampersand in their name.

      AT&T is another way to write it.

      This & that.

      4 < 5.

      6 > 5.

      Here's a link with an ampersand in the URL.

      Here's a link with an amersand in the link text: AT&T.

      Here's an inline link.

      Here's an inline link.

      mistune-0.8.4/tests/fixtures/normal/amps_and_angles_encoding.text000066400000000000000000000005761335757225100254230ustar00rootroot00000000000000AT&T has an ampersand in their name. AT&T is another way to write it. This & that. 4 < 5. 6 > 5. Here's a [link] [1] with an ampersand in the URL. Here's a link with an amersand in the link text: [AT&T] [2]. Here's an inline [link](/script?foo=1&bar=2). Here's an inline [link](). [1]: http://example.com/?foo=1&bar=2 [2]: http://att.com/ "AT&T" mistune-0.8.4/tests/fixtures/normal/auto_email.html000066400000000000000000000001221335757225100225240ustar00rootroot00000000000000

      This should be a link: me@example.com.

      mistune-0.8.4/tests/fixtures/normal/auto_email.text000066400000000000000000000000511335757225100225450ustar00rootroot00000000000000This should be a link: . mistune-0.8.4/tests/fixtures/normal/auto_links.html000066400000000000000000000010421335757225100225570ustar00rootroot00000000000000

      Link: http://example.com/.

      With an ampersand: http://example.com/?foo=1&bar=2

      Blockquoted: http://example.com/

      Auto-links should not occur here: <http://example.com/>

      or here: <http://example.com/>
      
      mistune-0.8.4/tests/fixtures/normal/auto_links.text000066400000000000000000000004101335757225100225750ustar00rootroot00000000000000Link: . With an ampersand: * In a list? * * It should. > Blockquoted: Auto-links should not occur here: `` or here: mistune-0.8.4/tests/fixtures/normal/backslash_escapes.html000066400000000000000000000032641335757225100240550ustar00rootroot00000000000000

      These should all get escaped:

      Backslash: \

      Backtick: `

      Asterisk: *

      Underscore: _

      Left brace: {

      Right brace: }

      Left bracket: [

      Right bracket: ]

      Left paren: (

      Right paren: )

      Greater-than: >

      Hash: #

      Period: .

      Bang: !

      Plus: +

      Minus: -

      These should not, because they occur within a code block:

      Backslash: \\
      
      Backtick: \`
      
      Asterisk: \*
      
      Underscore: \_
      
      Left brace: \{
      
      Right brace: \}
      
      Left bracket: \[
      
      Right bracket: \]
      
      Left paren: \(
      
      Right paren: \)
      
      Greater-than: \>
      
      Hash: \#
      
      Period: \.
      
      Bang: \!
      
      Plus: \+
      
      Minus: \-
      

      Nor should these, which occur in code spans:

      Backslash: \\

      Backtick: \`

      Asterisk: \*

      Underscore: \_

      Left brace: \{

      Right brace: \}

      Left bracket: \[

      Right bracket: \]

      Left paren: \(

      Right paren: \)

      Greater-than: \>

      Hash: \#

      Period: \.

      Bang: \!

      Plus: \+

      Minus: \-

      These should get escaped, even though they're matching pairs for other Markdown constructs:

      *asterisks*

      _underscores_

      `backticks`

      This is a code span with a literal backslash-backtick sequence: \`

      This is a tag with unescaped backticks bar.

      This is a tag with backslashes bar.

      mistune-0.8.4/tests/fixtures/normal/backslash_escapes.text000066400000000000000000000023421335757225100240710ustar00rootroot00000000000000These should all get escaped: Backslash: \\ Backtick: \` Asterisk: \* Underscore: \_ Left brace: \{ Right brace: \} Left bracket: \[ Right bracket: \] Left paren: \( Right paren: \) Greater-than: \> Hash: \# Period: \. Bang: \! Plus: \+ Minus: \- These should not, because they occur within a code block: Backslash: \\ Backtick: \` Asterisk: \* Underscore: \_ Left brace: \{ Right brace: \} Left bracket: \[ Right bracket: \] Left paren: \( Right paren: \) Greater-than: \> Hash: \# Period: \. Bang: \! Plus: \+ Minus: \- Nor should these, which occur in code spans: Backslash: `\\` Backtick: `` \` `` Asterisk: `\*` Underscore: `\_` Left brace: `\{` Right brace: `\}` Left bracket: `\[` Right bracket: `\]` Left paren: `\(` Right paren: `\)` Greater-than: `\>` Hash: `\#` Period: `\.` Bang: `\!` Plus: `\+` Minus: `\-` These should get escaped, even though they're matching pairs for other Markdown constructs: \*asterisks\* \_underscores\_ \`backticks\` This is a code span with a literal backslash-backtick sequence: `` \` `` This is a tag with unescaped backticks bar. This is a tag with backslashes bar. mistune-0.8.4/tests/fixtures/normal/blockquotes_with_code_blocks.html000066400000000000000000000002721335757225100263300ustar00rootroot00000000000000

      Example:

      sub status {
          print "working";
      }
      

      Or:

      sub status {
          return "working";
      }
      
      mistune-0.8.4/tests/fixtures/normal/blockquotes_with_code_blocks.text000066400000000000000000000002071335757225100263460ustar00rootroot00000000000000> Example: > > sub status { > print "working"; > } > > Or: > > sub status { > return "working"; > } mistune-0.8.4/tests/fixtures/normal/code_blocks.html000066400000000000000000000004701335757225100226620ustar00rootroot00000000000000
      code block on the first line
      

      Regular text.

      code block indented by spaces
      

      Regular text.

      the lines in this block  
      all contain trailing spaces  
      

      Regular Text.

      code block on the last line
      
      mistune-0.8.4/tests/fixtures/normal/code_blocks.text000066400000000000000000000003101335757225100226730ustar00rootroot00000000000000 code block on the first line Regular text. code block indented by spaces Regular text. the lines in this block all contain trailing spaces Regular Text. code block on the last line mistune-0.8.4/tests/fixtures/normal/code_spans.html000066400000000000000000000005561335757225100225360ustar00rootroot00000000000000

      <test a=" content of attribute ">

      Fix for backticks within HTML tag: like this

      Here's how you put `backticks` in a code span.

      From <!-- to --> on two lines.

      From <!-- to --> on three lines.

      mistune-0.8.4/tests/fixtures/normal/code_spans.text000066400000000000000000000003601335757225100225470ustar00rootroot00000000000000`` Fix for backticks within HTML tag: like this Here's how you put `` `backticks` `` in a code span. From `` on two lines. From `` on three lines. mistune-0.8.4/tests/fixtures/normal/headers.html000066400000000000000000000005061335757225100220260ustar00rootroot00000000000000

      Header

      Header

      Header


      Header

      Paragraph

      Header

      Paragraph

      Header

      Paragraph


      Paragraph

      Header

      Paragraph

      Paragraph

      Header

      Paragraph

      Paragraph

      Header

      Paragraph

      mistune-0.8.4/tests/fixtures/normal/headers.text000066400000000000000000000003471335757225100220510ustar00rootroot00000000000000Header ====== Header ------ ### Header - - - Header ====== Paragraph Header ------ Paragraph ### Header Paragraph - - - Paragraph Header ====== Paragraph Paragraph Header ------ Paragraph Paragraph ### Header Paragraph mistune-0.8.4/tests/fixtures/normal/horizontal_rules.html000066400000000000000000000006011335757225100240120ustar00rootroot00000000000000

      Dashes:





      ---
      




      - - -
      

      Asterisks:





      ***
      




      * * *
      

      Underscores:





      ___
      




      _ _ _
      
      mistune-0.8.4/tests/fixtures/normal/horizontal_rules.text000066400000000000000000000004161335757225100240360ustar00rootroot00000000000000Dashes: --- --- --- --- --- - - - - - - - - - - - - - - - Asterisks: *** *** *** *** *** * * * * * * * * * * * * * * * Underscores: ___ ___ ___ ___ ___ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ mistune-0.8.4/tests/fixtures/normal/inline_html_advanced.html000066400000000000000000000002451335757225100245420ustar00rootroot00000000000000

      Simple block on one line:

      foo

      And nested without indentation:

      foo
      bar
      mistune-0.8.4/tests/fixtures/normal/inline_html_advanced.text000066400000000000000000000002271335757225100245620ustar00rootroot00000000000000Simple block on one line:
      foo
      And nested without indentation:
      foo
      bar
      mistune-0.8.4/tests/fixtures/normal/inline_html_comments.html000066400000000000000000000002741335757225100246240ustar00rootroot00000000000000

      Paragraph one.

      Paragraph two.

      The end.

      mistune-0.8.4/tests/fixtures/normal/inline_html_comments.text000066400000000000000000000002441335757225100246410ustar00rootroot00000000000000Paragraph one. Paragraph two. The end. mistune-0.8.4/tests/fixtures/normal/inline_html_simple.html000066400000000000000000000020211335757225100242600ustar00rootroot00000000000000

      Here's a simple block:

      foo

      This should be a code block, though:

      <div>
          foo
      </div>
      

      As should this:

      <div>foo</div>
      

      Now, nested:

      foo

      This should just be an HTML comment:

      Multiline:

      Code block:

      <!-- Comment -->
      

      Just plain comment, with trailing spaces on the line:

      Code:

      <hr />
      

      Hr's:










      iframe:

      iframe with content:

      mistune-0.8.4/tests/fixtures/normal/inline_html_simple.text000066400000000000000000000014331335757225100243060ustar00rootroot00000000000000Here's a simple block:
      foo
      This should be a code block, though:
      foo
      As should this:
      foo
      Now, nested:
      foo
      This should just be an HTML comment: Multiline: Code block: Just plain comment, with trailing spaces on the line: Code:
      Hr's:








      iframe: iframe with content: mistune-0.8.4/tests/fixtures/normal/links_inline_style.html000066400000000000000000000007601335757225100243130ustar00rootroot00000000000000

      Just a URL.

      URL and title.

      URL and title.

      URL and title.

      URL and title.

      URL and title.

      URL and title.

      Empty.

      mistune-0.8.4/tests/fixtures/normal/links_inline_style.text000066400000000000000000000005101335757225100243240ustar00rootroot00000000000000Just a [URL](/url/). [URL and title](/url/ "title"). [URL and title](/url/ "title preceded by two spaces"). [URL and title](/url/ "title preceded by a tab"). [URL and title](/url/ "title has spaces afterward" ). [URL and title]( /url/has space ). [URL and title]( /url/has space/ "url has space and title"). [Empty](). mistune-0.8.4/tests/fixtures/normal/links_reference_style.html000066400000000000000000000021411335757225100247660ustar00rootroot00000000000000

      Foo bar.

      Foo bar.

      Foo bar.

      With embedded [brackets].

      Indented once.

      Indented twice.

      Indented thrice.

      Indented [four][] times.

      [four]: /url
      

      this should work

      So should this.

      And this.

      And this.

      And this.

      But not [that] [].

      Nor [that][].

      Nor [that].

      [Something in brackets like this should work]

      [Same with this.]

      In this case, this points to something else.

      Backslashing should suppress [this] and [this].


      Here's one where the link breaks across lines.

      Here's another where the link breaks across lines, but with a line-ending space.

      mistune-0.8.4/tests/fixtures/normal/links_reference_style.text000066400000000000000000000014271335757225100250140ustar00rootroot00000000000000Foo [bar] [1]. Foo [bar][1]. Foo [bar] [1]. [1]: /url/ "Title" With [embedded [brackets]] [b]. Indented [once][]. Indented [twice][]. Indented [thrice][]. Indented [four][] times. [once]: /url [twice]: /url [thrice]: /url [four]: /url [b]: /url/ * * * [this] [this] should work So should [this][this]. And [this] []. And [this][]. And [this]. But not [that] []. Nor [that][]. Nor [that]. [Something in brackets like [this][] should work] [Same with [this].] In this case, [this](/somethingelse/) points to something else. Backslashing should suppress \[this] and [this\]. [this]: foo * * * Here's one where the [link breaks] across lines. Here's another where the [link breaks] across lines, but with a line-ending space. [link breaks]: /url/ mistune-0.8.4/tests/fixtures/normal/links_shortcut_references.html000066400000000000000000000004001335757225100256600ustar00rootroot00000000000000

      This is the simple case.

      This one has a line break.

      This one has a line break with a line-ending space.

      this and the other

      mistune-0.8.4/tests/fixtures/normal/links_shortcut_references.text000066400000000000000000000003541335757225100257100ustar00rootroot00000000000000This is the [simple case]. [simple case]: /simple This one has a [line break]. This one has a [line break] with a line-ending space. [line break]: /foo [this] [that] and the [other] [this]: /this [that]: /that [other]: /other mistune-0.8.4/tests/fixtures/normal/literal_quotes_in_titles.html000066400000000000000000000002431335757225100255170ustar00rootroot00000000000000

      Foo bar.

      Foo bar.

      mistune-0.8.4/tests/fixtures/normal/literal_quotes_in_titles.text000066400000000000000000000001541335757225100255400ustar00rootroot00000000000000Foo [bar][]. Foo [bar](/url/ "Title with "quotes" inside"). [bar]: /url/ "Title with "quotes" inside" mistune-0.8.4/tests/fixtures/normal/markdown_documentation_basics.html000066400000000000000000000222501335757225100265120ustar00rootroot00000000000000

      Markdown: Basics

      Getting the Gist of Markdown's Formatting Syntax

      This page offers a brief overview of what it's like to use Markdown. The syntax page provides complete, detailed documentation for every feature, but Markdown should be very easy to pick up simply by looking at a few examples of it in action. The examples on this page are written in a before/after style, showing example syntax and the HTML output produced by Markdown.

      It's also helpful to simply try Markdown out; the Dingus is a web application that allows you type your own Markdown-formatted text and translate it to XHTML.

      Note: This document is itself written using Markdown; you can see the source for it by adding '.text' to the URL.

      Paragraphs, Headers, Blockquotes

      A paragraph is simply one or more consecutive lines of text, separated by one or more blank lines. (A blank line is any line that looks like a blank line -- a line containing nothing spaces or tabs is considered blank.) Normal paragraphs should not be intended with spaces or tabs.

      Markdown offers two styles of headers: Setext and atx. Setext-style headers for <h1> and <h2> are created by "underlining" with equal signs (=) and hyphens (-), respectively. To create an atx-style header, you put 1-6 hash marks (#) at the beginning of the line -- the number of hashes equals the resulting HTML header level.

      Blockquotes are indicated using email-style '>' angle brackets.

      Markdown:

      A First Level Header
      ====================
      
      A Second Level Header
      ---------------------
      
      Now is the time for all good men to come to
      the aid of their country. This is just a
      regular paragraph.
      
      The quick brown fox jumped over the lazy
      dog's back.
      
      ### Header 3
      
      > This is a blockquote.
      > 
      > This is the second paragraph in the blockquote.
      >
      > ## This is an H2 in a blockquote
      

      Output:

      <h1>A First Level Header</h1>
      
      <h2>A Second Level Header</h2>
      
      <p>Now is the time for all good men to come to
      the aid of their country. This is just a
      regular paragraph.</p>
      
      <p>The quick brown fox jumped over the lazy
      dog's back.</p>
      
      <h3>Header 3</h3>
      
      <blockquote>
          <p>This is a blockquote.</p>
      
          <p>This is the second paragraph in the blockquote.</p>
      
          <h2>This is an H2 in a blockquote</h2>
      </blockquote>
      

      Phrase Emphasis

      Markdown uses asterisks and underscores to indicate spans of emphasis.

      Markdown:

      Some of these words *are emphasized*.
      Some of these words _are emphasized also_.
      
      Use two asterisks for **strong emphasis**.
      Or, if you prefer, __use two underscores instead__.
      

      Output:

      <p>Some of these words <em>are emphasized</em>.
      Some of these words <em>are emphasized also</em>.</p>
      
      <p>Use two asterisks for <strong>strong emphasis</strong>.
      Or, if you prefer, <strong>use two underscores instead</strong>.</p>
      

      Lists

      Unordered (bulleted) lists use asterisks, pluses, and hyphens (*, +, and -) as list markers. These three markers are interchangable; this:

      *   Candy.
      *   Gum.
      *   Booze.
      

      this:

      +   Candy.
      +   Gum.
      +   Booze.
      

      and this:

      -   Candy.
      -   Gum.
      -   Booze.
      

      all produce the same output:

      <ul>
      <li>Candy.</li>
      <li>Gum.</li>
      <li>Booze.</li>
      </ul>
      

      Ordered (numbered) lists use regular numbers, followed by periods, as list markers:

      1.  Red
      2.  Green
      3.  Blue
      

      Output:

      <ol>
      <li>Red</li>
      <li>Green</li>
      <li>Blue</li>
      </ol>
      

      If you put blank lines between items, you'll get <p> tags for the list item text. You can create multi-paragraph list items by indenting the paragraphs by 4 spaces or 1 tab:

      *   A list item.
      
          With multiple paragraphs.
      
      *   Another item in the list.
      

      Output:

      <ul>
      <li><p>A list item.</p>
      <p>With multiple paragraphs.</p></li>
      <li><p>Another item in the list.</p></li>
      </ul>
      

      Links

      Markdown supports two styles for creating links: inline and reference. With both styles, you use square brackets to delimit the text you want to turn into a link.

      Inline-style links use parentheses immediately after the link text. For example:

      This is an [example link](http://example.com/).
      

      Output:

      <p>This is an <a href="http://example.com/">
      example link</a>.</p>
      

      Optionally, you may include a title attribute in the parentheses:

      This is an [example link](http://example.com/ "With a Title").
      

      Output:

      <p>This is an <a href="http://example.com/" title="With a Title">
      example link</a>.</p>
      

      Reference-style links allow you to refer to your links by names, which you define elsewhere in your document:

      I get 10 times more traffic from [Google][1] than from
      [Yahoo][2] or [MSN][3].
      
      [1]: http://google.com/        "Google"
      [2]: http://search.yahoo.com/  "Yahoo Search"
      [3]: http://search.msn.com/    "MSN Search"
      

      Output:

      <p>I get 10 times more traffic from <a href="http://google.com/"
      title="Google">Google</a> than from <a href="http://search.yahoo.com/"
      title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/"
      title="MSN Search">MSN</a>.</p>
      

      The title attribute is optional. Link names may contain letters, numbers and spaces, but are not case sensitive:

      I start my morning with a cup of coffee and
      [The New York Times][NY Times].
      
      [ny times]: http://www.nytimes.com/
      

      Output:

      <p>I start my morning with a cup of coffee and
      <a href="http://www.nytimes.com/">The New York Times</a>.</p>
      

      Images

      Image syntax is very much like link syntax.

      Inline (titles are optional):

      ![alt text](/path/to/img.jpg "Title")
      

      Reference-style:

      ![alt text][id]
      
      [id]: /path/to/img.jpg "Title"
      

      Both of the above examples produce the same output:

      <img src="/path/to/img.jpg" alt="alt text" title="Title" />
      

      Code

      In a regular paragraph, you can create code span by wrapping text in backtick quotes. Any ampersands (&) and angle brackets (< or >) will automatically be translated into HTML entities. This makes it easy to use Markdown to write about HTML example code:

      I strongly recommend against using any `<blink>` tags.
      
      I wish SmartyPants used named entities like `&mdash;`
      instead of decimal-encoded entites like `&#8212;`.
      

      Output:

      <p>I strongly recommend against using any
      <code>&lt;blink&gt;</code> tags.</p>
      
      <p>I wish SmartyPants used named entities like
      <code>&amp;mdash;</code> instead of decimal-encoded
      entites like <code>&amp;#8212;</code>.</p>
      

      To specify an entire block of pre-formatted code, indent every line of the block by 4 spaces or 1 tab. Just like with code spans, &, <, and > characters will be escaped automatically.

      Markdown:

      If you want your page to validate under XHTML 1.0 Strict,
      you've got to put paragraph tags in your blockquotes:
      
          <blockquote>
              <p>For example.</p>
          </blockquote>
      

      Output:

      <p>If you want your page to validate under XHTML 1.0 Strict,
      you've got to put paragraph tags in your blockquotes:</p>
      
      <pre><code>&lt;blockquote&gt;
          &lt;p&gt;For example.&lt;/p&gt;
      &lt;/blockquote&gt;
      </code></pre>
      
      mistune-0.8.4/tests/fixtures/normal/markdown_documentation_basics.text000066400000000000000000000176001335757225100265350ustar00rootroot00000000000000Markdown: Basics ================ Getting the Gist of Markdown's Formatting Syntax ------------------------------------------------ This page offers a brief overview of what it's like to use Markdown. The [syntax page] [s] provides complete, detailed documentation for every feature, but Markdown should be very easy to pick up simply by looking at a few examples of it in action. The examples on this page are written in a before/after style, showing example syntax and the HTML output produced by Markdown. It's also helpful to simply try Markdown out; the [Dingus] [d] is a web application that allows you type your own Markdown-formatted text and translate it to XHTML. **Note:** This document is itself written using Markdown; you can [see the source for it by adding '.text' to the URL] [src]. [s]: /projects/markdown/syntax "Markdown Syntax" [d]: /projects/markdown/dingus "Markdown Dingus" [src]: /projects/markdown/basics.text ## Paragraphs, Headers, Blockquotes ## A paragraph is simply one or more consecutive lines of text, separated by one or more blank lines. (A blank line is any line that looks like a blank line -- a line containing nothing spaces or tabs is considered blank.) Normal paragraphs should not be intended with spaces or tabs. Markdown offers two styles of headers: *Setext* and *atx*. Setext-style headers for `

      ` and `

      ` are created by "underlining" with equal signs (`=`) and hyphens (`-`), respectively. To create an atx-style header, you put 1-6 hash marks (`#`) at the beginning of the line -- the number of hashes equals the resulting HTML header level. Blockquotes are indicated using email-style '`>`' angle brackets. Markdown: A First Level Header ==================== A Second Level Header --------------------- Now is the time for all good men to come to the aid of their country. This is just a regular paragraph. The quick brown fox jumped over the lazy dog's back. ### Header 3 > This is a blockquote. > > This is the second paragraph in the blockquote. > > ## This is an H2 in a blockquote Output:

      A First Level Header

      A Second Level Header

      Now is the time for all good men to come to the aid of their country. This is just a regular paragraph.

      The quick brown fox jumped over the lazy dog's back.

      Header 3

      This is a blockquote.

      This is the second paragraph in the blockquote.

      This is an H2 in a blockquote

      ### Phrase Emphasis ### Markdown uses asterisks and underscores to indicate spans of emphasis. Markdown: Some of these words *are emphasized*. Some of these words _are emphasized also_. Use two asterisks for **strong emphasis**. Or, if you prefer, __use two underscores instead__. Output:

      Some of these words are emphasized. Some of these words are emphasized also.

      Use two asterisks for strong emphasis. Or, if you prefer, use two underscores instead.

      ## Lists ## Unordered (bulleted) lists use asterisks, pluses, and hyphens (`*`, `+`, and `-`) as list markers. These three markers are interchangable; this: * Candy. * Gum. * Booze. this: + Candy. + Gum. + Booze. and this: - Candy. - Gum. - Booze. all produce the same output:
      • Candy.
      • Gum.
      • Booze.
      Ordered (numbered) lists use regular numbers, followed by periods, as list markers: 1. Red 2. Green 3. Blue Output:
      1. Red
      2. Green
      3. Blue
      If you put blank lines between items, you'll get `

      ` tags for the list item text. You can create multi-paragraph list items by indenting the paragraphs by 4 spaces or 1 tab: * A list item. With multiple paragraphs. * Another item in the list. Output:

      • A list item.

        With multiple paragraphs.

      • Another item in the list.

      ### Links ### Markdown supports two styles for creating links: *inline* and *reference*. With both styles, you use square brackets to delimit the text you want to turn into a link. Inline-style links use parentheses immediately after the link text. For example: This is an [example link](http://example.com/). Output:

      This is an example link.

      Optionally, you may include a title attribute in the parentheses: This is an [example link](http://example.com/ "With a Title"). Output:

      This is an example link.

      Reference-style links allow you to refer to your links by names, which you define elsewhere in your document: I get 10 times more traffic from [Google][1] than from [Yahoo][2] or [MSN][3]. [1]: http://google.com/ "Google" [2]: http://search.yahoo.com/ "Yahoo Search" [3]: http://search.msn.com/ "MSN Search" Output:

      I get 10 times more traffic from Google than from Yahoo or MSN.

      The title attribute is optional. Link names may contain letters, numbers and spaces, but are *not* case sensitive: I start my morning with a cup of coffee and [The New York Times][NY Times]. [ny times]: http://www.nytimes.com/ Output:

      I start my morning with a cup of coffee and The New York Times.

      ### Images ### Image syntax is very much like link syntax. Inline (titles are optional): ![alt text](/path/to/img.jpg "Title") Reference-style: ![alt text][id] [id]: /path/to/img.jpg "Title" Both of the above examples produce the same output: alt text ### Code ### In a regular paragraph, you can create code span by wrapping text in backtick quotes. Any ampersands (`&`) and angle brackets (`<` or `>`) will automatically be translated into HTML entities. This makes it easy to use Markdown to write about HTML example code: I strongly recommend against using any `` tags. I wish SmartyPants used named entities like `—` instead of decimal-encoded entites like `—`. Output:

      I strongly recommend against using any <blink> tags.

      I wish SmartyPants used named entities like &mdash; instead of decimal-encoded entites like &#8212;.

      To specify an entire block of pre-formatted code, indent every line of the block by 4 spaces or 1 tab. Just like with code spans, `&`, `<`, and `>` characters will be escaped automatically. Markdown: If you want your page to validate under XHTML 1.0 Strict, you've got to put paragraph tags in your blockquotes:

      For example.

      Output:

      If you want your page to validate under XHTML 1.0 Strict, you've got to put paragraph tags in your blockquotes:

      <blockquote>
              <p>For example.</p>
          </blockquote>
          
      mistune-0.8.4/tests/fixtures/normal/markdown_documentation_syntax.html000066400000000000000000000760411335757225100266030ustar00rootroot00000000000000

      Markdown: Syntax

      Note: This document is itself written using Markdown; you can see the source for it by adding '.text' to the URL.


      Overview

      Philosophy

      Markdown is intended to be as easy-to-read and easy-to-write as is feasible.

      Readability, however, is emphasized above all else. A Markdown-formatted document should be publishable as-is, as plain text, without looking like it's been marked up with tags or formatting instructions. While Markdown's syntax has been influenced by several existing text-to-HTML filters -- including Setext, atx, Textile, reStructuredText, Grutatext, and EtText -- the single biggest source of inspiration for Markdown's syntax is the format of plain text email.

      To this end, Markdown's syntax is comprised entirely of punctuation characters, which punctuation characters have been carefully chosen so as to look like what they mean. E.g., asterisks around a word actually look like *emphasis*. Markdown lists look like, well, lists. Even blockquotes look like quoted passages of text, assuming you've ever used email.

      Inline HTML

      Markdown's syntax is intended for one purpose: to be used as a format for writing for the web.

      Markdown is not a replacement for HTML, or even close to it. Its syntax is very small, corresponding only to a very small subset of HTML tags. The idea is not to create a syntax that makes it easier to insert HTML tags. In my opinion, HTML tags are already easy to insert. The idea for Markdown is to make it easy to read, write, and edit prose. HTML is a publishing format; Markdown is a writing format. Thus, Markdown's formatting syntax only addresses issues that can be conveyed in plain text.

      For any markup that is not covered by Markdown's syntax, you simply use HTML itself. There's no need to preface it or delimit it to indicate that you're switching from Markdown to HTML; you just use the tags.

      The only restrictions are that block-level HTML elements -- e.g. <div>, <table>, <pre>, <p>, etc. -- must be separated from surrounding content by blank lines, and the start and end tags of the block should not be indented with tabs or spaces. Markdown is smart enough not to add extra (unwanted) <p> tags around HTML block-level tags.

      For example, to add an HTML table to a Markdown article:

      This is a regular paragraph.
      
      <table>
          <tr>
              <td>Foo</td>
          </tr>
      </table>
      
      This is another regular paragraph.
      

      Note that Markdown formatting syntax is not processed within block-level HTML tags. E.g., you can't use Markdown-style *emphasis* inside an HTML block.

      Span-level HTML tags -- e.g. <span>, <cite>, or <del> -- can be used anywhere in a Markdown paragraph, list item, or header. If you want, you can even use HTML tags instead of Markdown formatting; e.g. if you'd prefer to use HTML <a> or <img> tags instead of Markdown's link or image syntax, go right ahead.

      Unlike block-level HTML tags, Markdown syntax is processed within span-level tags.

      Automatic Escaping for Special Characters

      In HTML, there are two characters that demand special treatment: < and &. Left angle brackets are used to start tags; ampersands are used to denote HTML entities. If you want to use them as literal characters, you must escape them as entities, e.g. &lt;, and &amp;.

      Ampersands in particular are bedeviling for web writers. If you want to write about 'AT&T', you need to write 'AT&amp;T'. You even need to escape ampersands within URLs. Thus, if you want to link to:

      http://images.google.com/images?num=30&q=larry+bird
      

      you need to encode the URL as:

      http://images.google.com/images?num=30&amp;q=larry+bird
      

      in your anchor tag href attribute. Needless to say, this is easy to forget, and is probably the single most common source of HTML validation errors in otherwise well-marked-up web sites.

      Markdown allows you to use these characters naturally, taking care of all the necessary escaping for you. If you use an ampersand as part of an HTML entity, it remains unchanged; otherwise it will be translated into &amp;.

      So, if you want to include a copyright symbol in your article, you can write:

      &copy;
      

      and Markdown will leave it alone. But if you write:

      AT&T
      

      Markdown will translate it to:

      AT&amp;T
      

      Similarly, because Markdown supports inline HTML, if you use angle brackets as delimiters for HTML tags, Markdown will treat them as such. But if you write:

      4 < 5
      

      Markdown will translate it to:

      4 &lt; 5
      

      However, inside Markdown code spans and blocks, angle brackets and ampersands are always encoded automatically. This makes it easy to use Markdown to write about HTML code. (As opposed to raw HTML, which is a terrible format for writing about HTML syntax, because every single < and & in your example code needs to be escaped.)


      Block Elements

      Paragraphs and Line Breaks

      A paragraph is simply one or more consecutive lines of text, separated by one or more blank lines. (A blank line is any line that looks like a blank line -- a line containing nothing but spaces or tabs is considered blank.) Normal paragraphs should not be intended with spaces or tabs.

      The implication of the "one or more consecutive lines of text" rule is that Markdown supports "hard-wrapped" text paragraphs. This differs significantly from most other text-to-HTML formatters (including Movable Type's "Convert Line Breaks" option) which translate every line break character in a paragraph into a <br /> tag.

      When you do want to insert a <br /> break tag using Markdown, you end a line with two or more spaces, then type return.

      Yes, this takes a tad more effort to create a <br />, but a simplistic "every line break is a <br />" rule wouldn't work for Markdown. Markdown's email-style blockquoting and multi-paragraph list items work best -- and look better -- when you format them with hard breaks.

      Markdown supports two styles of headers, Setext and atx.

      Setext-style headers are "underlined" using equal signs (for first-level headers) and dashes (for second-level headers). For example:

      This is an H1
      =============
      
      This is an H2
      -------------
      

      Any number of underlining ='s or -'s will work.

      Atx-style headers use 1-6 hash characters at the start of the line, corresponding to header levels 1-6. For example:

      # This is an H1
      
      ## This is an H2
      
      ###### This is an H6
      

      Optionally, you may "close" atx-style headers. This is purely cosmetic -- you can use this if you think it looks better. The closing hashes don't even need to match the number of hashes used to open the header. (The number of opening hashes determines the header level.) :

      # This is an H1 #
      
      ## This is an H2 ##
      
      ### This is an H3 ######
      

      Blockquotes

      Markdown uses email-style > characters for blockquoting. If you're familiar with quoting passages of text in an email message, then you know how to create a blockquote in Markdown. It looks best if you hard wrap the text and put a > before every line:

      > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
      > consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
      > Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
      > 
      > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
      > id sem consectetuer libero luctus adipiscing.
      

      Markdown allows you to be lazy and only put the > before the first line of a hard-wrapped paragraph:

      > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
      consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
      Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
      
      > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
      id sem consectetuer libero luctus adipiscing.
      

      Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by adding additional levels of >:

      > This is the first level of quoting.
      >
      > > This is nested blockquote.
      >
      > Back to the first level.
      

      Blockquotes can contain other Markdown elements, including headers, lists, and code blocks:

      > ## This is a header.
      > 
      > 1.   This is the first list item.
      > 2.   This is the second list item.
      > 
      > Here's some example code:
      > 
      >     return shell_exec("echo $input | $markdown_script");
      

      Any decent text editor should make email-style quoting easy. For example, with BBEdit, you can make a selection and choose Increase Quote Level from the Text menu.

      Lists

      Markdown supports ordered (numbered) and unordered (bulleted) lists.

      Unordered lists use asterisks, pluses, and hyphens -- interchangably -- as list markers:

      *   Red
      *   Green
      *   Blue
      

      is equivalent to:

      +   Red
      +   Green
      +   Blue
      

      and:

      -   Red
      -   Green
      -   Blue
      

      Ordered lists use numbers followed by periods:

      1.  Bird
      2.  McHale
      3.  Parish
      

      It's important to note that the actual numbers you use to mark the list have no effect on the HTML output Markdown produces. The HTML Markdown produces from the above list is:

      <ol>
      <li>Bird</li>
      <li>McHale</li>
      <li>Parish</li>
      </ol>
      

      If you instead wrote the list in Markdown like this:

      1.  Bird
      1.  McHale
      1.  Parish
      

      or even:

      3. Bird
      1. McHale
      8. Parish
      

      you'd get the exact same HTML output. The point is, if you want to, you can use ordinal numbers in your ordered Markdown lists, so that the numbers in your source match the numbers in your published HTML. But if you want to be lazy, you don't have to.

      If you do use lazy list numbering, however, you should still start the list with the number 1. At some point in the future, Markdown may support starting ordered lists at an arbitrary number.

      List markers typically start at the left margin, but may be indented by up to three spaces. List markers must be followed by one or more spaces or a tab.

      To make lists look nice, you can wrap items with hanging indents:

      *   Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
          Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
          viverra nec, fringilla in, laoreet vitae, risus.
      *   Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
          Suspendisse id sem consectetuer libero luctus adipiscing.
      

      But if you want to be lazy, you don't have to:

      *   Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
      Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
      viverra nec, fringilla in, laoreet vitae, risus.
      *   Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
      Suspendisse id sem consectetuer libero luctus adipiscing.
      

      If list items are separated by blank lines, Markdown will wrap the items in <p> tags in the HTML output. For example, this input:

      *   Bird
      *   Magic
      

      will turn into:

      <ul>
      <li>Bird</li>
      <li>Magic</li>
      </ul>
      

      But this:

      *   Bird
      
      *   Magic
      

      will turn into:

      <ul>
      <li><p>Bird</p></li>
      <li><p>Magic</p></li>
      </ul>
      

      List items may consist of multiple paragraphs. Each subsequent paragraph in a list item must be intended by either 4 spaces or one tab:

      1.  This is a list item with two paragraphs. Lorem ipsum dolor
          sit amet, consectetuer adipiscing elit. Aliquam hendrerit
          mi posuere lectus.
      
          Vestibulum enim wisi, viverra nec, fringilla in, laoreet
          vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
          sit amet velit.
      
      2.  Suspendisse id sem consectetuer libero luctus adipiscing.
      

      It looks nice if you indent every line of the subsequent paragraphs, but here again, Markdown will allow you to be lazy:

      *   This is a list item with two paragraphs.
      
          This is the second paragraph in the list item. You're
      only required to indent the first line. Lorem ipsum dolor
      sit amet, consectetuer adipiscing elit.
      
      *   Another item in the same list.
      

      To put a blockquote within a list item, the blockquote's > delimiters need to be indented:

      *   A list item with a blockquote:
      
          > This is a blockquote
          > inside a list item.
      

      To put a code block within a list item, the code block needs to be indented twice -- 8 spaces or two tabs:

      *   A list item with a code block:
      
              <code goes here>
      

      It's worth noting that it's possible to trigger an ordered list by accident, by writing something like this:

      1986. What a great season.
      

      In other words, a number-period-space sequence at the beginning of a line. To avoid this, you can backslash-escape the period:

      1986\. What a great season.
      

      Code Blocks

      Pre-formatted code blocks are used for writing about programming or markup source code. Rather than forming normal paragraphs, the lines of a code block are interpreted literally. Markdown wraps a code block in both <pre> and <code> tags.

      To produce a code block in Markdown, simply indent every line of the block by at least 4 spaces or 1 tab. For example, given this input:

      This is a normal paragraph:
      
          This is a code block.
      

      Markdown will generate:

      <p>This is a normal paragraph:</p>
      
      <pre><code>This is a code block.
      </code></pre>
      

      One level of indentation -- 4 spaces or 1 tab -- is removed from each line of the code block. For example, this:

      Here is an example of AppleScript:
      
          tell application "Foo"
              beep
          end tell
      

      will turn into:

      <p>Here is an example of AppleScript:</p>
      
      <pre><code>tell application "Foo"
          beep
      end tell
      </code></pre>
      

      A code block continues until it reaches a line that is not indented (or the end of the article).

      Within a code block, ampersands (&) and angle brackets (< and >) are automatically converted into HTML entities. This makes it very easy to include example HTML source code using Markdown -- just paste it and indent it, and Markdown will handle the hassle of encoding the ampersands and angle brackets. For example, this:

          <div class="footer">
              &copy; 2004 Foo Corporation
          </div>
      

      will turn into:

      <pre><code>&lt;div class="footer"&gt;
          &amp;copy; 2004 Foo Corporation
      &lt;/div&gt;
      </code></pre>
      

      Regular Markdown syntax is not processed within code blocks. E.g., asterisks are just literal asterisks within a code block. This means it's also easy to use Markdown to write about Markdown's own syntax.

      Horizontal Rules

      You can produce a horizontal rule tag (<hr />) by placing three or more hyphens, asterisks, or underscores on a line by themselves. If you wish, you may use spaces between the hyphens or asterisks. Each of the following lines will produce a horizontal rule:

      * * *
      
      ***
      
      *****
      
      - - -
      
      ---------------------------------------
      
      _ _ _
      

      Span Elements

      Markdown supports two style of links: inline and reference.

      In both styles, the link text is delimited by [square brackets].

      To create an inline link, use a set of regular parentheses immediately after the link text's closing square bracket. Inside the parentheses, put the URL where you want the link to point, along with an optional title for the link, surrounded in quotes. For example:

      This is [an example](http://example.com/ "Title") inline link.
      
      [This link](http://example.net/) has no title attribute.
      

      Will produce:

      <p>This is <a href="http://example.com/" title="Title">
      an example</a> inline link.</p>
      
      <p><a href="http://example.net/">This link</a> has no
      title attribute.</p>
      

      If you're referring to a local resource on the same server, you can use relative paths:

      See my [About](/about/) page for details.
      

      Reference-style links use a second set of square brackets, inside which you place a label of your choosing to identify the link:

      This is [an example][id] reference-style link.
      

      You can optionally use a space to separate the sets of brackets:

      This is [an example] [id] reference-style link.
      

      Then, anywhere in the document, you define your link label like this, on a line by itself:

      [id]: http://example.com/  "Optional Title Here"
      

      That is:

      • Square brackets containing the link identifier (optionally indented from the left margin using up to three spaces);
      • followed by a colon;
      • followed by one or more spaces (or tabs);
      • followed by the URL for the link;
      • optionally followed by a title attribute for the link, enclosed in double or single quotes.

      The link URL may, optionally, be surrounded by angle brackets:

      [id]: <http://example.com/>  "Optional Title Here"
      

      You can put the title attribute on the next line and use extra spaces or tabs for padding, which tends to look better with longer URLs:

      [id]: http://example.com/longish/path/to/resource/here
          "Optional Title Here"
      

      Link definitions are only used for creating links during Markdown processing, and are stripped from your document in the HTML output.

      Link definition names may constist of letters, numbers, spaces, and punctuation -- but they are not case sensitive. E.g. these two links:

      [link text][a]
      [link text][A]
      

      are equivalent.

      The implicit link name shortcut allows you to omit the name of the link, in which case the link text itself is used as the name. Just use an empty set of square brackets -- e.g., to link the word "Google" to the google.com web site, you could simply write:

      [Google][]
      

      And then define the link:

      [Google]: http://google.com/
      

      Because link names may contain spaces, this shortcut even works for multiple words in the link text:

      Visit [Daring Fireball][] for more information.
      

      And then define the link:

      [Daring Fireball]: http://daringfireball.net/
      

      Link definitions can be placed anywhere in your Markdown document. I tend to put them immediately after each paragraph in which they're used, but if you want, you can put them all at the end of your document, sort of like footnotes.

      Here's an example of reference links in action:

      I get 10 times more traffic from [Google] [1] than from
      [Yahoo] [2] or [MSN] [3].
      
        [1]: http://google.com/        "Google"
        [2]: http://search.yahoo.com/  "Yahoo Search"
        [3]: http://search.msn.com/    "MSN Search"
      

      Using the implicit link name shortcut, you could instead write:

      I get 10 times more traffic from [Google][] than from
      [Yahoo][] or [MSN][].
      
        [google]: http://google.com/        "Google"
        [yahoo]:  http://search.yahoo.com/  "Yahoo Search"
        [msn]:    http://search.msn.com/    "MSN Search"
      

      Both of the above examples will produce the following HTML output:

      <p>I get 10 times more traffic from <a href="http://google.com/"
      title="Google">Google</a> than from
      <a href="http://search.yahoo.com/" title="Yahoo Search">Yahoo</a>
      or <a href="http://search.msn.com/" title="MSN Search">MSN</a>.</p>
      

      For comparison, here is the same paragraph written using Markdown's inline link style:

      I get 10 times more traffic from [Google](http://google.com/ "Google")
      than from [Yahoo](http://search.yahoo.com/ "Yahoo Search") or
      [MSN](http://search.msn.com/ "MSN Search").
      

      The point of reference-style links is not that they're easier to write. The point is that with reference-style links, your document source is vastly more readable. Compare the above examples: using reference-style links, the paragraph itself is only 81 characters long; with inline-style links, it's 176 characters; and as raw HTML, it's 234 characters. In the raw HTML, there's more markup than there is text.

      With Markdown's reference-style links, a source document much more closely resembles the final output, as rendered in a browser. By allowing you to move the markup-related metadata out of the paragraph, you can add links without interrupting the narrative flow of your prose.

      Emphasis

      Markdown treats asterisks (*) and underscores (_) as indicators of emphasis. Text wrapped with one * or _ will be wrapped with an HTML <em> tag; double *'s or _'s will be wrapped with an HTML <strong> tag. E.g., this input:

      *single asterisks*
      
      _single underscores_
      
      **double asterisks**
      
      __double underscores__
      

      will produce:

      <em>single asterisks</em>
      
      <em>single underscores</em>
      
      <strong>double asterisks</strong>
      
      <strong>double underscores</strong>
      

      You can use whichever style you prefer; the lone restriction is that the same character must be used to open and close an emphasis span.

      Emphasis can be used in the middle of a word:

      un*fucking*believable
      

      But if you surround an * or _ with spaces, it'll be treated as a literal asterisk or underscore.

      To produce a literal asterisk or underscore at a position where it would otherwise be used as an emphasis delimiter, you can backslash escape it:

      \*this text is surrounded by literal asterisks\*
      

      Code

      To indicate a span of code, wrap it with backtick quotes (`). Unlike a pre-formatted code block, a code span indicates code within a normal paragraph. For example:

      Use the `printf()` function.
      

      will produce:

      <p>Use the <code>printf()</code> function.</p>
      

      To include a literal backtick character within a code span, you can use multiple backticks as the opening and closing delimiters:

      ``There is a literal backtick (`) here.``
      

      which will produce this:

      <p><code>There is a literal backtick (`) here.</code></p>
      

      The backtick delimiters surrounding a code span may include spaces -- one after the opening, one before the closing. This allows you to place literal backtick characters at the beginning or end of a code span:

      A single backtick in a code span: `` ` ``
      
      A backtick-delimited string in a code span: `` `foo` ``
      

      will produce:

      <p>A single backtick in a code span: <code>`</code></p>
      
      <p>A backtick-delimited string in a code span: <code>`foo`</code></p>
      

      With a code span, ampersands and angle brackets are encoded as HTML entities automatically, which makes it easy to include example HTML tags. Markdown will turn this:

      Please don't use any `<blink>` tags.
      

      into:

      <p>Please don't use any <code>&lt;blink&gt;</code> tags.</p>
      

      You can write this:

      `&#8212;` is the decimal-encoded equivalent of `&mdash;`.
      

      to produce:

      <p><code>&amp;#8212;</code> is the decimal-encoded
      equivalent of <code>&amp;mdash;</code>.</p>
      

      Images

      Admittedly, it's fairly difficult to devise a "natural" syntax for placing images into a plain text document format.

      Markdown uses an image syntax that is intended to resemble the syntax for links, allowing for two styles: inline and reference.

      Inline image syntax looks like this:

      ![Alt text](/path/to/img.jpg)
      
      ![Alt text](/path/to/img.jpg "Optional title")
      

      That is:

      • An exclamation mark: !;
      • followed by a set of square brackets, containing the alt attribute text for the image;
      • followed by a set of parentheses, containing the URL or path to the image, and an optional title attribute enclosed in double or single quotes.

      Reference-style image syntax looks like this:

      ![Alt text][id]
      

      Where "id" is the name of a defined image reference. Image references are defined using syntax identical to link references:

      [id]: url/to/image  "Optional title attribute"
      

      As of this writing, Markdown has no syntax for specifying the dimensions of an image; if this is important to you, you can simply use regular HTML <img> tags.


      Miscellaneous

      Markdown supports a shortcut style for creating "automatic" links for URLs and email addresses: simply surround the URL or email address with angle brackets. What this means is that if you want to show the actual text of a URL or email address, and also have it be a clickable link, you can do this:

      <http://example.com/>
      

      Markdown will turn this into:

      <a href="http://example.com/">http://example.com/</a>
      

      Automatic links for email addresses work similarly, except that Markdown will also perform a bit of randomized decimal and hex entity-encoding to help obscure your address from address-harvesting spambots. For example, Markdown will turn this:

      <address@example.com>
      

      into something like this:

      <a href="&#x6D;&#x61;i&#x6C;&#x74;&#x6F;:&#x61;&#x64;&#x64;&#x72;&#x65;
      &#115;&#115;&#64;&#101;&#120;&#x61;&#109;&#x70;&#x6C;e&#x2E;&#99;&#111;
      &#109;">&#x61;&#x64;&#x64;&#x72;&#x65;&#115;&#115;&#64;&#101;&#120;&#x61;
      &#109;&#x70;&#x6C;e&#x2E;&#99;&#111;&#109;</a>
      

      which will render in a browser as a clickable link to "address@example.com".

      (This sort of entity-encoding trick will indeed fool many, if not most, address-harvesting bots, but it definitely won't fool all of them. It's better than nothing, but an address published in this way will probably eventually start receiving spam.)

      Backslash Escapes

      Markdown allows you to use backslash escapes to generate literal characters which would otherwise have special meaning in Markdown's formatting syntax. For example, if you wanted to surround a word with literal asterisks (instead of an HTML <em> tag), you can backslashes before the asterisks, like this:

      \*literal asterisks\*
      

      Markdown provides backslash escapes for the following characters:

      \   backslash
      `   backtick
      *   asterisk
      _   underscore
      {}  curly braces
      []  square brackets
      ()  parentheses
      #   hash mark
      +   plus sign
      -   minus sign (hyphen)
      .   dot
      !   exclamation mark
      
      mistune-0.8.4/tests/fixtures/normal/markdown_documentation_syntax.text000066400000000000000000000654441335757225100266300ustar00rootroot00000000000000Markdown: Syntax ================ * [Overview](#overview) * [Philosophy](#philosophy) * [Inline HTML](#html) * [Automatic Escaping for Special Characters](#autoescape) * [Block Elements](#block) * [Paragraphs and Line Breaks](#p) * [Headers](#header) * [Blockquotes](#blockquote) * [Lists](#list) * [Code Blocks](#precode) * [Horizontal Rules](#hr) * [Span Elements](#span) * [Links](#link) * [Emphasis](#em) * [Code](#code) * [Images](#img) * [Miscellaneous](#misc) * [Backslash Escapes](#backslash) * [Automatic Links](#autolink) **Note:** This document is itself written using Markdown; you can [see the source for it by adding '.text' to the URL][src]. [src]: /projects/markdown/syntax.text * * *

      Overview

      Philosophy

      Markdown is intended to be as easy-to-read and easy-to-write as is feasible. Readability, however, is emphasized above all else. A Markdown-formatted document should be publishable as-is, as plain text, without looking like it's been marked up with tags or formatting instructions. While Markdown's syntax has been influenced by several existing text-to-HTML filters -- including [Setext] [1], [atx] [2], [Textile] [3], [reStructuredText] [4], [Grutatext] [5], and [EtText] [6] -- the single biggest source of inspiration for Markdown's syntax is the format of plain text email. [1]: http://docutils.sourceforge.net/mirror/setext.html [2]: http://www.aaronsw.com/2002/atx/ [3]: http://textism.com/tools/textile/ [4]: http://docutils.sourceforge.net/rst.html [5]: http://www.triptico.com/software/grutatxt.html [6]: http://ettext.taint.org/doc/ To this end, Markdown's syntax is comprised entirely of punctuation characters, which punctuation characters have been carefully chosen so as to look like what they mean. E.g., asterisks around a word actually look like \*emphasis\*. Markdown lists look like, well, lists. Even blockquotes look like quoted passages of text, assuming you've ever used email.

      Inline HTML

      Markdown's syntax is intended for one purpose: to be used as a format for *writing* for the web. Markdown is not a replacement for HTML, or even close to it. Its syntax is very small, corresponding only to a very small subset of HTML tags. The idea is *not* to create a syntax that makes it easier to insert HTML tags. In my opinion, HTML tags are already easy to insert. The idea for Markdown is to make it easy to read, write, and edit prose. HTML is a *publishing* format; Markdown is a *writing* format. Thus, Markdown's formatting syntax only addresses issues that can be conveyed in plain text. For any markup that is not covered by Markdown's syntax, you simply use HTML itself. There's no need to preface it or delimit it to indicate that you're switching from Markdown to HTML; you just use the tags. The only restrictions are that block-level HTML elements -- e.g. `
      `, ``, `
      `, `

      `, etc. -- must be separated from surrounding content by blank lines, and the start and end tags of the block should not be indented with tabs or spaces. Markdown is smart enough not to add extra (unwanted) `

      ` tags around HTML block-level tags. For example, to add an HTML table to a Markdown article: This is a regular paragraph.

      Foo
      This is another regular paragraph. Note that Markdown formatting syntax is not processed within block-level HTML tags. E.g., you can't use Markdown-style `*emphasis*` inside an HTML block. Span-level HTML tags -- e.g. ``, ``, or `` -- can be used anywhere in a Markdown paragraph, list item, or header. If you want, you can even use HTML tags instead of Markdown formatting; e.g. if you'd prefer to use HTML `` or `` tags instead of Markdown's link or image syntax, go right ahead. Unlike block-level HTML tags, Markdown syntax *is* processed within span-level tags.

      Automatic Escaping for Special Characters

      In HTML, there are two characters that demand special treatment: `<` and `&`. Left angle brackets are used to start tags; ampersands are used to denote HTML entities. If you want to use them as literal characters, you must escape them as entities, e.g. `<`, and `&`. Ampersands in particular are bedeviling for web writers. If you want to write about 'AT&T', you need to write '`AT&T`'. You even need to escape ampersands within URLs. Thus, if you want to link to: http://images.google.com/images?num=30&q=larry+bird you need to encode the URL as: http://images.google.com/images?num=30&q=larry+bird in your anchor tag `href` attribute. Needless to say, this is easy to forget, and is probably the single most common source of HTML validation errors in otherwise well-marked-up web sites. Markdown allows you to use these characters naturally, taking care of all the necessary escaping for you. If you use an ampersand as part of an HTML entity, it remains unchanged; otherwise it will be translated into `&`. So, if you want to include a copyright symbol in your article, you can write: © and Markdown will leave it alone. But if you write: AT&T Markdown will translate it to: AT&T Similarly, because Markdown supports [inline HTML](#html), if you use angle brackets as delimiters for HTML tags, Markdown will treat them as such. But if you write: 4 < 5 Markdown will translate it to: 4 < 5 However, inside Markdown code spans and blocks, angle brackets and ampersands are *always* encoded automatically. This makes it easy to use Markdown to write about HTML code. (As opposed to raw HTML, which is a terrible format for writing about HTML syntax, because every single `<` and `&` in your example code needs to be escaped.) * * *

      Block Elements

      Paragraphs and Line Breaks

      A paragraph is simply one or more consecutive lines of text, separated by one or more blank lines. (A blank line is any line that looks like a blank line -- a line containing nothing but spaces or tabs is considered blank.) Normal paragraphs should not be intended with spaces or tabs. The implication of the "one or more consecutive lines of text" rule is that Markdown supports "hard-wrapped" text paragraphs. This differs significantly from most other text-to-HTML formatters (including Movable Type's "Convert Line Breaks" option) which translate every line break character in a paragraph into a `
      ` tag. When you *do* want to insert a `
      ` break tag using Markdown, you end a line with two or more spaces, then type return. Yes, this takes a tad more effort to create a `
      `, but a simplistic "every line break is a `
      `" rule wouldn't work for Markdown. Markdown's email-style [blockquoting][bq] and multi-paragraph [list items][l] work best -- and look better -- when you format them with hard breaks. [bq]: #blockquote [l]: #list Markdown supports two styles of headers, [Setext] [1] and [atx] [2]. Setext-style headers are "underlined" using equal signs (for first-level headers) and dashes (for second-level headers). For example: This is an H1 ============= This is an H2 ------------- Any number of underlining `=`'s or `-`'s will work. Atx-style headers use 1-6 hash characters at the start of the line, corresponding to header levels 1-6. For example: # This is an H1 ## This is an H2 ###### This is an H6 Optionally, you may "close" atx-style headers. This is purely cosmetic -- you can use this if you think it looks better. The closing hashes don't even need to match the number of hashes used to open the header. (The number of opening hashes determines the header level.) : # This is an H1 # ## This is an H2 ## ### This is an H3 ######

      Blockquotes

      Markdown uses email-style `>` characters for blockquoting. If you're familiar with quoting passages of text in an email message, then you know how to create a blockquote in Markdown. It looks best if you hard wrap the text and put a `>` before every line: > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, > consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. > Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus. > > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse > id sem consectetuer libero luctus adipiscing. Markdown allows you to be lazy and only put the `>` before the first line of a hard-wrapped paragraph: > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus. > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse id sem consectetuer libero luctus adipiscing. Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by adding additional levels of `>`: > This is the first level of quoting. > > > This is nested blockquote. > > Back to the first level. Blockquotes can contain other Markdown elements, including headers, lists, and code blocks: > ## This is a header. > > 1. This is the first list item. > 2. This is the second list item. > > Here's some example code: > > return shell_exec("echo $input | $markdown_script"); Any decent text editor should make email-style quoting easy. For example, with BBEdit, you can make a selection and choose Increase Quote Level from the Text menu.

      Lists

      Markdown supports ordered (numbered) and unordered (bulleted) lists. Unordered lists use asterisks, pluses, and hyphens -- interchangably -- as list markers: * Red * Green * Blue is equivalent to: + Red + Green + Blue and: - Red - Green - Blue Ordered lists use numbers followed by periods: 1. Bird 2. McHale 3. Parish It's important to note that the actual numbers you use to mark the list have no effect on the HTML output Markdown produces. The HTML Markdown produces from the above list is:
      1. Bird
      2. McHale
      3. Parish
      If you instead wrote the list in Markdown like this: 1. Bird 1. McHale 1. Parish or even: 3. Bird 1. McHale 8. Parish you'd get the exact same HTML output. The point is, if you want to, you can use ordinal numbers in your ordered Markdown lists, so that the numbers in your source match the numbers in your published HTML. But if you want to be lazy, you don't have to. If you do use lazy list numbering, however, you should still start the list with the number 1. At some point in the future, Markdown may support starting ordered lists at an arbitrary number. List markers typically start at the left margin, but may be indented by up to three spaces. List markers must be followed by one or more spaces or a tab. To make lists look nice, you can wrap items with hanging indents: * Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus. * Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse id sem consectetuer libero luctus adipiscing. But if you want to be lazy, you don't have to: * Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus. * Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse id sem consectetuer libero luctus adipiscing. If list items are separated by blank lines, Markdown will wrap the items in `

      ` tags in the HTML output. For example, this input: * Bird * Magic will turn into:

      • Bird
      • Magic
      But this: * Bird * Magic will turn into:
      • Bird

      • Magic

      List items may consist of multiple paragraphs. Each subsequent paragraph in a list item must be intended by either 4 spaces or one tab: 1. This is a list item with two paragraphs. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus. Donec sit amet nisl. Aliquam semper ipsum sit amet velit. 2. Suspendisse id sem consectetuer libero luctus adipiscing. It looks nice if you indent every line of the subsequent paragraphs, but here again, Markdown will allow you to be lazy: * This is a list item with two paragraphs. This is the second paragraph in the list item. You're only required to indent the first line. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. * Another item in the same list. To put a blockquote within a list item, the blockquote's `>` delimiters need to be indented: * A list item with a blockquote: > This is a blockquote > inside a list item. To put a code block within a list item, the code block needs to be indented *twice* -- 8 spaces or two tabs: * A list item with a code block: It's worth noting that it's possible to trigger an ordered list by accident, by writing something like this: 1986. What a great season. In other words, a *number-period-space* sequence at the beginning of a line. To avoid this, you can backslash-escape the period: 1986\. What a great season.

      Code Blocks

      Pre-formatted code blocks are used for writing about programming or markup source code. Rather than forming normal paragraphs, the lines of a code block are interpreted literally. Markdown wraps a code block in both `
      ` and `` tags.
      
      To produce a code block in Markdown, simply indent every line of the
      block by at least 4 spaces or 1 tab. For example, given this input:
      
          This is a normal paragraph:
      
              This is a code block.
      
      Markdown will generate:
      
          

      This is a normal paragraph:

      This is a code block.
          
      One level of indentation -- 4 spaces or 1 tab -- is removed from each line of the code block. For example, this: Here is an example of AppleScript: tell application "Foo" beep end tell will turn into:

      Here is an example of AppleScript:

      tell application "Foo"
              beep
          end tell
          
      A code block continues until it reaches a line that is not indented (or the end of the article). Within a code block, ampersands (`&`) and angle brackets (`<` and `>`) are automatically converted into HTML entities. This makes it very easy to include example HTML source code using Markdown -- just paste it and indent it, and Markdown will handle the hassle of encoding the ampersands and angle brackets. For example, this: will turn into:
      <div class="footer">
              &copy; 2004 Foo Corporation
          </div>
          
      Regular Markdown syntax is not processed within code blocks. E.g., asterisks are just literal asterisks within a code block. This means it's also easy to use Markdown to write about Markdown's own syntax.

      Horizontal Rules

      You can produce a horizontal rule tag (`
      `) by placing three or more hyphens, asterisks, or underscores on a line by themselves. If you wish, you may use spaces between the hyphens or asterisks. Each of the following lines will produce a horizontal rule: * * * *** ***** - - - --------------------------------------- _ _ _ * * *

      Span Elements

      Markdown supports two style of links: *inline* and *reference*. In both styles, the link text is delimited by [square brackets]. To create an inline link, use a set of regular parentheses immediately after the link text's closing square bracket. Inside the parentheses, put the URL where you want the link to point, along with an *optional* title for the link, surrounded in quotes. For example: This is [an example](http://example.com/ "Title") inline link. [This link](http://example.net/) has no title attribute. Will produce:

      This is an example inline link.

      This link has no title attribute.

      If you're referring to a local resource on the same server, you can use relative paths: See my [About](/about/) page for details. Reference-style links use a second set of square brackets, inside which you place a label of your choosing to identify the link: This is [an example][id] reference-style link. You can optionally use a space to separate the sets of brackets: This is [an example] [id] reference-style link. Then, anywhere in the document, you define your link label like this, on a line by itself: [id]: http://example.com/ "Optional Title Here" That is: * Square brackets containing the link identifier (optionally indented from the left margin using up to three spaces); * followed by a colon; * followed by one or more spaces (or tabs); * followed by the URL for the link; * optionally followed by a title attribute for the link, enclosed in double or single quotes. The link URL may, optionally, be surrounded by angle brackets: [id]: "Optional Title Here" You can put the title attribute on the next line and use extra spaces or tabs for padding, which tends to look better with longer URLs: [id]: http://example.com/longish/path/to/resource/here "Optional Title Here" Link definitions are only used for creating links during Markdown processing, and are stripped from your document in the HTML output. Link definition names may constist of letters, numbers, spaces, and punctuation -- but they are *not* case sensitive. E.g. these two links: [link text][a] [link text][A] are equivalent. The *implicit link name* shortcut allows you to omit the name of the link, in which case the link text itself is used as the name. Just use an empty set of square brackets -- e.g., to link the word "Google" to the google.com web site, you could simply write: [Google][] And then define the link: [Google]: http://google.com/ Because link names may contain spaces, this shortcut even works for multiple words in the link text: Visit [Daring Fireball][] for more information. And then define the link: [Daring Fireball]: http://daringfireball.net/ Link definitions can be placed anywhere in your Markdown document. I tend to put them immediately after each paragraph in which they're used, but if you want, you can put them all at the end of your document, sort of like footnotes. Here's an example of reference links in action: I get 10 times more traffic from [Google] [1] than from [Yahoo] [2] or [MSN] [3]. [1]: http://google.com/ "Google" [2]: http://search.yahoo.com/ "Yahoo Search" [3]: http://search.msn.com/ "MSN Search" Using the implicit link name shortcut, you could instead write: I get 10 times more traffic from [Google][] than from [Yahoo][] or [MSN][]. [google]: http://google.com/ "Google" [yahoo]: http://search.yahoo.com/ "Yahoo Search" [msn]: http://search.msn.com/ "MSN Search" Both of the above examples will produce the following HTML output:

      I get 10 times more traffic from Google than from Yahoo or MSN.

      For comparison, here is the same paragraph written using Markdown's inline link style: I get 10 times more traffic from [Google](http://google.com/ "Google") than from [Yahoo](http://search.yahoo.com/ "Yahoo Search") or [MSN](http://search.msn.com/ "MSN Search"). The point of reference-style links is not that they're easier to write. The point is that with reference-style links, your document source is vastly more readable. Compare the above examples: using reference-style links, the paragraph itself is only 81 characters long; with inline-style links, it's 176 characters; and as raw HTML, it's 234 characters. In the raw HTML, there's more markup than there is text. With Markdown's reference-style links, a source document much more closely resembles the final output, as rendered in a browser. By allowing you to move the markup-related metadata out of the paragraph, you can add links without interrupting the narrative flow of your prose.

      Emphasis

      Markdown treats asterisks (`*`) and underscores (`_`) as indicators of emphasis. Text wrapped with one `*` or `_` will be wrapped with an HTML `` tag; double `*`'s or `_`'s will be wrapped with an HTML `` tag. E.g., this input: *single asterisks* _single underscores_ **double asterisks** __double underscores__ will produce: single asterisks single underscores double asterisks double underscores You can use whichever style you prefer; the lone restriction is that the same character must be used to open and close an emphasis span. Emphasis can be used in the middle of a word: un*fucking*believable But if you surround an `*` or `_` with spaces, it'll be treated as a literal asterisk or underscore. To produce a literal asterisk or underscore at a position where it would otherwise be used as an emphasis delimiter, you can backslash escape it: \*this text is surrounded by literal asterisks\*

      Code

      To indicate a span of code, wrap it with backtick quotes (`` ` ``). Unlike a pre-formatted code block, a code span indicates code within a normal paragraph. For example: Use the `printf()` function. will produce:

      Use the printf() function.

      To include a literal backtick character within a code span, you can use multiple backticks as the opening and closing delimiters: ``There is a literal backtick (`) here.`` which will produce this:

      There is a literal backtick (`) here.

      The backtick delimiters surrounding a code span may include spaces -- one after the opening, one before the closing. This allows you to place literal backtick characters at the beginning or end of a code span: A single backtick in a code span: `` ` `` A backtick-delimited string in a code span: `` `foo` `` will produce:

      A single backtick in a code span: `

      A backtick-delimited string in a code span: `foo`

      With a code span, ampersands and angle brackets are encoded as HTML entities automatically, which makes it easy to include example HTML tags. Markdown will turn this: Please don't use any `` tags. into:

      Please don't use any <blink> tags.

      You can write this: `—` is the decimal-encoded equivalent of `—`. to produce:

      &#8212; is the decimal-encoded equivalent of &mdash;.

      Images

      Admittedly, it's fairly difficult to devise a "natural" syntax for placing images into a plain text document format. Markdown uses an image syntax that is intended to resemble the syntax for links, allowing for two styles: *inline* and *reference*. Inline image syntax looks like this: ![Alt text](/path/to/img.jpg) ![Alt text](/path/to/img.jpg "Optional title") That is: * An exclamation mark: `!`; * followed by a set of square brackets, containing the `alt` attribute text for the image; * followed by a set of parentheses, containing the URL or path to the image, and an optional `title` attribute enclosed in double or single quotes. Reference-style image syntax looks like this: ![Alt text][id] Where "id" is the name of a defined image reference. Image references are defined using syntax identical to link references: [id]: url/to/image "Optional title attribute" As of this writing, Markdown has no syntax for specifying the dimensions of an image; if this is important to you, you can simply use regular HTML `` tags. * * *

      Miscellaneous

      Markdown supports a shortcut style for creating "automatic" links for URLs and email addresses: simply surround the URL or email address with angle brackets. What this means is that if you want to show the actual text of a URL or email address, and also have it be a clickable link, you can do this: Markdown will turn this into: http://example.com/ Automatic links for email addresses work similarly, except that Markdown will also perform a bit of randomized decimal and hex entity-encoding to help obscure your address from address-harvesting spambots. For example, Markdown will turn this: into something like this: address@exa mple.com which will render in a browser as a clickable link to "address@example.com". (This sort of entity-encoding trick will indeed fool many, if not most, address-harvesting bots, but it definitely won't fool all of them. It's better than nothing, but an address published in this way will probably eventually start receiving spam.)

      Backslash Escapes

      Markdown allows you to use backslash escapes to generate literal characters which would otherwise have special meaning in Markdown's formatting syntax. For example, if you wanted to surround a word with literal asterisks (instead of an HTML `` tag), you can backslashes before the asterisks, like this: \*literal asterisks\* Markdown provides backslash escapes for the following characters: \ backslash ` backtick * asterisk _ underscore {} curly braces [] square brackets () parentheses # hash mark + plus sign - minus sign (hyphen) . dot ! exclamation mark mistune-0.8.4/tests/fixtures/normal/nested_blockquotes.html000066400000000000000000000001511335757225100243040ustar00rootroot00000000000000

      foo

      bar

      foo

      mistune-0.8.4/tests/fixtures/normal/nested_blockquotes.text000066400000000000000000000000301335757225100243200ustar00rootroot00000000000000> foo > > > bar > > foo mistune-0.8.4/tests/fixtures/normal/ordered_and_unordered_lists.html000066400000000000000000000032411335757225100261450ustar00rootroot00000000000000

      Unordered

      Asterisks tight:

      • asterisk 1
      • asterisk 2
      • asterisk 3

      Asterisks loose:

      • asterisk 1

      • asterisk 2

      • asterisk 3


      Pluses tight:

      • Plus 1
      • Plus 2
      • Plus 3

      Pluses loose:

      • Plus 1

      • Plus 2

      • Plus 3


      Minuses tight:

      • Minus 1
      • Minus 2
      • Minus 3

      Minuses loose:

      • Minus 1

      • Minus 2

      • Minus 3

      Ordered

      Tight:

      1. First
      2. Second
      3. Third

      and:

      1. One
      2. Two
      3. Three

      Loose using tabs:

      1. First

      2. Second

      3. Third

      and using spaces:

      1. One

      2. Two

      3. Three

      Multiple paragraphs:

      1. Item 1, graf one.

        Item 2. graf two. The quick brown fox jumped over the lazy dog's back.

      2. Item 2.

      3. Item 3.

      Nested

      • Tab
        • Tab
          • Tab

      Here's another:

      1. First
      2. Second:
        • Fee
        • Fie
        • Foe
      3. Third

      Same thing but with paragraphs:

      1. First

      2. Second:

        • Fee
        • Fie
        • Foe
      3. Third

      This was an error in Markdown 1.0.1:

      • this

        • sub

        that

      mistune-0.8.4/tests/fixtures/normal/ordered_and_unordered_lists.text000066400000000000000000000016071335757225100261710ustar00rootroot00000000000000## Unordered Asterisks tight: * asterisk 1 * asterisk 2 * asterisk 3 Asterisks loose: * asterisk 1 * asterisk 2 * asterisk 3 * * * Pluses tight: + Plus 1 + Plus 2 + Plus 3 Pluses loose: + Plus 1 + Plus 2 + Plus 3 * * * Minuses tight: - Minus 1 - Minus 2 - Minus 3 Minuses loose: - Minus 1 - Minus 2 - Minus 3 ## Ordered Tight: 1. First 2. Second 3. Third and: 1. One 2. Two 3. Three Loose using tabs: 1. First 2. Second 3. Third and using spaces: 1. One 2. Two 3. Three Multiple paragraphs: 1. Item 1, graf one. Item 2. graf two. The quick brown fox jumped over the lazy dog's back. 2. Item 2. 3. Item 3. ## Nested * Tab * Tab * Tab Here's another: 1. First 2. Second: * Fee * Fie * Foe 3. Third Same thing but with paragraphs: 1. First 2. Second: * Fee * Fie * Foe 3. Third This was an error in Markdown 1.0.1: * this * sub that mistune-0.8.4/tests/fixtures/normal/strong_and_em_together.html000066400000000000000000000003271335757225100251340ustar00rootroot00000000000000

      This is strong and em.

      So is this word.

      This is strong and em.

      So is this word.

      mistune-0.8.4/tests/fixtures/normal/strong_and_em_together.text000066400000000000000000000001531335757225100251510ustar00rootroot00000000000000***This is strong and em.*** So is ***this*** word. ___This is strong and em.___ So is ___this___ word. mistune-0.8.4/tests/fixtures/normal/tabs.html000066400000000000000000000006671335757225100213540ustar00rootroot00000000000000
      • this is a list item indented with tabs

      • this is a list item indented with spaces

      Code:

      this code block is indented by one tab
      

      And:

          this code block is indented by two tabs
      

      And:

      +   this is an example list item
          indented with tabs
      
      +   this is an example list item
          indented with spaces
      
      mistune-0.8.4/tests/fixtures/normal/tabs.text000066400000000000000000000004671335757225100213720ustar00rootroot00000000000000+ this is a list item indented with tabs + this is a list item indented with spaces Code: this code block is indented by one tab And: this code block is indented by two tabs And: + this is an example list item indented with tabs + this is an example list item indented with spaces mistune-0.8.4/tests/fixtures/normal/tidyness.html000066400000000000000000000002051335757225100222510ustar00rootroot00000000000000

      A list within a blockquote:

      • asterisk 1
      • asterisk 2
      • asterisk 3
      mistune-0.8.4/tests/fixtures/normal/tidyness.text000066400000000000000000000001161335757225100222720ustar00rootroot00000000000000> A list within a blockquote: > > * asterisk 1 > * asterisk 2 > * asterisk 3 mistune-0.8.4/tests/test_cases.py000066400000000000000000000022561335757225100170770ustar00rootroot00000000000000 import os import re import mistune root = os.path.dirname(__file__) known = [] m = mistune.Markdown() def render(folder, name): filepath = os.path.join(folder, name + '.text') with open(filepath) as f: content = f.read() html = m.parse(content) filepath = os.path.join(folder, name + '.html') with open(filepath) as f: result = f.read() html = re.sub(r'\s', '', html) result = re.sub(r'\s', '', result) for i, s in enumerate(html): if s != result[i]: begin = max(i - 30, 0) msg = '\n\n%s\n------Not Equal(%d)------\n%s' % ( html[begin:i+30], i, result[begin:i+30] ) raise ValueError(msg) assert html == result def listdir(folder): folder = os.path.join(root, 'fixtures', folder) files = os.listdir(folder) files = filter(lambda o: o.endswith('.text'), files) names = map(lambda o: o[:-5], files) return folder, names def test_extra(): folder, names = listdir('extra') for key in names: yield render, folder, key def test_normal(): folder, names = listdir('normal') for key in names: yield render, folder, key mistune-0.8.4/tests/test_extra.py000066400000000000000000000111161335757225100171170ustar00rootroot00000000000000import mistune def test_escape(): ret = mistune.markdown('
      **foo**
      ', escape=True) assert '>' in ret ret = mistune.markdown('this **foo** is bold', escape=True) assert '>' in ret def test_linebreak(): ret = mistune.markdown('this **foo** \nis me') assert '
      ' not in ret ret = mistune.markdown('this **foo** \nis me', hard_wrap=True) assert '
      ' in ret def test_safe_links(): attack_vectors = ( # "standard" javascript pseudo protocol ('javascript:alert`1`', ''), # bypass attempt ('jAvAsCrIpT:alert`1`', ''), # bypass with newline ('javasc\nript:alert`1`', ''), # javascript pseudo protocol with entities ('javascript:alert`1`', 'javascript&colon;alert`1`'), # javascript pseudo protocol with prefix (dangerous in Chrome) ('\x1Ajavascript:alert`1`', ''), # vbscript-URI (dangerous in Internet Explorer) ('vbscript:msgbox', ''), # breaking out of the attribute ('"<>', '"<>'), ) for vector, expected in attack_vectors: # image assert 'src="%s"' % expected in mistune.markdown('![atk](%s)' % vector) # link assert 'href="%s"' % expected in mistune.markdown('[atk](%s)' % vector) def test_skip_style(): ret = mistune.markdown( 'foo\n', skip_style=True ) assert ret == '

      foo

      \n' def test_use_xhtml(): ret = mistune.markdown('foo\n\n----\n\nbar') assert '
      ' in ret ret = mistune.markdown('foo\n\n----\n\nbar', use_xhtml=True) assert '
      ' in ret ret = mistune.markdown('foo \nbar', use_xhtml=True) assert '
      ' in ret ret = mistune.markdown('![foo](bar "title")', use_xhtml=True) assert 'foo' in ret def test_parse_inline_html(): ret = mistune.markdown( '
      **foo**
      ', parse_inline_html=True, escape=False ) assert '' not in ret ret = mistune.markdown( '**foo**', parse_inline_html=True, escape=False ) assert '' in ret ret = mistune.markdown( '**foo**', parse_inline_html=True, escape=False ) assert '' in ret ret = mistune.markdown( '**foo**', parse_inline_html=True, escape=False ) assert '' in ret ret = mistune.markdown( 'http://lepture.com', parse_inline_html=True, escape=False ) assert 'href' not in ret def test_block_html(): ret = mistune.markdown( '
      ', escape=False ) assert '
      ' in ret def test_parse_block_html(): ret = mistune.markdown( '
      **foo**
      ', parse_block_html=True, escape=False ) assert '
      ' in ret ret = mistune.markdown( '
      **foo**
      ', parse_block_html=True, escape=False ) assert '
      ' in ret ret = mistune.markdown( '
      **foo**
      ', parse_block_html=True, escape=False ) assert '
      ' in ret ret = mistune.markdown( '**foo**', parse_block_html=True, escape=False ) assert '' not in ret def test_parse_nested_html(): ret = mistune.markdown( '', parse_block_html=True, escape=False ) assert '
      ' in ret assert '' not in ret ret = mistune.markdown( '', parse_block_html=True, parse_inline_html=True, escape=False ) assert '
      ' in ret def test_trigger_more_cases(): markdown = mistune.Markdown( inline=mistune.InlineLexer, block=mistune.BlockLexer, skip_html=True ) ret = markdown.render('foo[^foo]\n\n[^foo]: foo\n\n[^foo]: bar\n') assert 'bar' not in ret def test_not_escape_block_tags(): text = '

      heading

      text' assert text in mistune.markdown(text, escape=False) def test_not_escape_inline_tags(): text = '
      ' assert text in mistune.markdown(text, escape=False) # space between = text = 'test' assert text in mistune.markdown(text, escape=False) def test_hard_wrap_renderer(): text = 'foo\nnewline' renderer = mistune.Renderer(hard_wrap=True) func = mistune.Markdown(renderer=renderer) assert '
      ' in func(text) mistune-0.8.4/tests/test_subclassing.py000066400000000000000000000126351335757225100203200ustar00rootroot00000000000000# coding: utf-8 import os import re import copy import mistune root = os.path.dirname(__file__) class MathBlockGrammar(mistune.BlockGrammar): block_math = re.compile(r'^\$\$(.*?)\$\$', re.DOTALL) latex_environment = re.compile( r"^\\begin\{([a-z]*\*?)\}(.*?)\\end\{\1\}", re.DOTALL ) class MathBlockLexer(mistune.BlockLexer): default_rules = ['block_math', 'latex_environment'] + \ mistune.BlockLexer.default_rules def __init__(self, rules=None, **kwargs): if rules is None: rules = MathBlockGrammar() super(MathBlockLexer, self).__init__(rules, **kwargs) def parse_block_math(self, m): """Parse a $$math$$ block""" self.tokens.append({ 'type': 'block_math', 'text': m.group(1) }) def parse_latex_environment(self, m): self.tokens.append({ 'type': 'latex_environment', 'name': m.group(1), 'text': m.group(2) }) class MathInlineGrammar(mistune.InlineGrammar): math = re.compile(r'^\$(.+?)\$') text = re.compile(r'^[\s\S]+?(?=[\\%s' % (link, alt) def test_custom_lexer(): markdown = mistune.Markdown(inline=WikiInlineLexer) ret = markdown('[[Link Text|Wiki Link]]') assert '