Skip to content

Commit

Permalink
Remove parse_html option
Browse files Browse the repository at this point in the history
  • Loading branch information
lepture committed Jul 13, 2015
1 parent 29ad717 commit 4273635
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 31 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Expand Up @@ -9,6 +9,7 @@ Version 0.7
Release date not decided.

* 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


Expand Down
1 change: 0 additions & 1 deletion README.rst
Expand Up @@ -85,7 +85,6 @@ configure them with ``mistune.Renderer``:
* **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.
* **use_xhtml**: if set to *True*, all tags will be in xhtml, for example: ``<hr />``.
* **parse_html**: parse text in block and inline level html.
* **parse_block_html**: parse text only in block level html.
* **parse_inline_html**: parse text only in inline level html.

Expand Down
7 changes: 2 additions & 5 deletions mistune.py
Expand Up @@ -510,8 +510,7 @@ def __init__(self, renderer, rules=None, **kwargs):
self._in_footnote = False

kwargs.update(self.renderer.options)
_to_parse = kwargs.get('parse_html') or kwargs.get('parse_inline_html')
self._parse_inline_html = _to_parse
self._parse_inline_html = kwargs.get('parse_inline_html')

def __call__(self, text, rules=None):
return self.output(text, rules)
Expand Down Expand Up @@ -945,8 +944,7 @@ def __init__(self, renderer=None, inline=None, block=None, **kwargs):
self.tokens = []

# detect if it should parse text in block html
_to_parse = kwargs.get('parse_html') or kwargs.get('parse_block_html')
self._parse_block_html = _to_parse
self._parse_block_html = kwargs.get('parse_block_html')

def __call__(self, text):
return self.parse(text)
Expand Down Expand Up @@ -1136,7 +1134,6 @@ def markdown(text, escape=True, **kwargs):
: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 has GFM line breaks feature.
:param parse_html: parse text in block and inline level html.
:param parse_block_html: parse text only in block level html.
:param parse_inline_html: parse text only in inline level html.
"""
Expand Down
25 changes: 0 additions & 25 deletions tests/test_extra.py
Expand Up @@ -44,31 +44,6 @@ def test_use_xhtml():
assert '<img src="bar" alt="foo" title="title" />' in ret


def test_parse_html():
ret = mistune.markdown('<div>**foo**</div>', escape=False)
assert '<strong>' not in ret
ret = mistune.markdown(
'<div>**foo**</div>', parse_html=True, escape=False
)
assert '<strong>' in ret

ret = mistune.markdown('<span>**foo**</span>', escape=False)
assert '<strong>' not in ret
ret = mistune.markdown(
'<span>**foo**</span>', parse_html=True, escape=False
)
assert '<strong>' in ret

ret = mistune.markdown(
'<span>http://example.com</span>', parse_html=True, escape=False
)
assert 'href' in ret
ret = mistune.markdown(
'<a>http://example.com</a>', parse_html=True, escape=False
)
assert 'href' not in ret


def test_parse_inline_html():
ret = mistune.markdown(
'<div>**foo**</div>', parse_inline_html=True, escape=False
Expand Down

0 comments on commit 4273635

Please sign in to comment.