/usr/lib/python2.7/dist-packages/mistune-0.8.3.egg-info/PKG-INFO is in python-mistune 0.8.3-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | Metadata-Version: 1.1
Name: mistune
Version: 0.8.3
Summary: The fastest markdown parser in pure Python
Home-page: https://github.com/lepture/mistune
Author: Hsiaoming Yang
Author-email: me@lepture.com
License: BSD
Description-Content-Type: UNKNOWN
Description: Mistune
=======
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://typlog.com/donate?amount=10&reason=lepture%2Fmistune
: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.6+, Python 3.3+ 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 <https://github.com/lepture/mistune/issues/1>`_.
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: <p>I am using <strong>mistune markdown parser</strong></p>
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 ``<br>`` tag
* **use_xhtml**: if set to *True*, all tags will be in xhtml, for example: ``<hr />``.
* **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<pre><code>%s</code></pre>\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 '<a href="%s">%s</a>' % (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
Platform: any
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Text Processing :: Markup
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|