Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5563723cbc | ||
|
|
a9c13a56da | ||
|
|
7bdeb15b18 | ||
|
|
87c8f3bd5e | ||
|
|
0211ac6619 | ||
|
|
2515e9e107 | ||
|
|
ece61a5b1f | ||
|
|
f46fb8ebbb | ||
|
|
e521fd402f | ||
|
|
fd6f8db132 | ||
|
|
c2f32b8049 | ||
|
|
b92428466d | ||
|
|
7f75b0bbce |
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
*.pyc
|
||||||
|
*.egg
|
||||||
|
.DS_Store
|
||||||
|
/.env
|
||||||
|
/dist
|
||||||
|
/MANIFEST
|
||||||
|
/venv
|
||||||
1
MANIFEST.in
Normal file
1
MANIFEST.in
Normal file
@@ -0,0 +1 @@
|
|||||||
|
include README.rst
|
||||||
41
README.rst
41
README.rst
@@ -0,0 +1,41 @@
|
|||||||
|
Installation
|
||||||
|
============
|
||||||
|
|
||||||
|
``pip install markdownify``
|
||||||
|
|
||||||
|
|
||||||
|
Usage
|
||||||
|
=====
|
||||||
|
|
||||||
|
Convert some HTML to Markdown:
|
||||||
|
|
||||||
|
.. code:: python
|
||||||
|
|
||||||
|
from markdownify import markdownify as md
|
||||||
|
md('<b>Yay</b> <a href="http://github.com">GitHub</a>') # > '**Yay** [GitHub](http://github.com)'
|
||||||
|
|
||||||
|
Specify tags to exclude (blacklist):
|
||||||
|
|
||||||
|
.. code:: python
|
||||||
|
|
||||||
|
from markdownify import markdownify as md
|
||||||
|
md('<b>Yay</b> <a href="http://github.com">GitHub</a>', strip=['a']) # > '**Yay** GitHub'
|
||||||
|
|
||||||
|
\...or specify the tags you want to include (whitelist):
|
||||||
|
|
||||||
|
.. code:: python
|
||||||
|
|
||||||
|
from markdownify import markdownify as md
|
||||||
|
md('<b>Yay</b> <a href="http://github.com">GitHub</a>', convert=['b']) # > '**Yay** GitHub'
|
||||||
|
|
||||||
|
|
||||||
|
Development
|
||||||
|
===========
|
||||||
|
|
||||||
|
To run tests:
|
||||||
|
|
||||||
|
``python setup.py test``
|
||||||
|
|
||||||
|
To lint:
|
||||||
|
|
||||||
|
``python setup.py lint``
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
from lxml.html.soupparser import fromstring
|
from bs4 import BeautifulSoup, NavigableString
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
convert_heading_re = re.compile(r'convert_h(\d+)')
|
convert_heading_re = re.compile(r'convert_h(\d+)')
|
||||||
line_beginning_re = re.compile(r'^', re.MULTILINE)
|
line_beginning_re = re.compile(r'^', re.MULTILINE)
|
||||||
whitespace_re = re.compile(r'[\r\n\s\t ]+')
|
whitespace_re = re.compile(r'[\r\n\s\t ]+')
|
||||||
|
FRAGMENT_ID = '__MARKDOWNIFY_WRAPPER__'
|
||||||
|
wrapped = '<div id="%s">%%s</div>' % FRAGMENT_ID
|
||||||
|
|
||||||
|
|
||||||
def escape(text):
|
def escape(text):
|
||||||
@@ -17,26 +19,32 @@ class MarkdownConverter(object):
|
|||||||
def __init__(self, tags_to_strip=None, tags_to_convert=None):
|
def __init__(self, tags_to_strip=None, tags_to_convert=None):
|
||||||
if tags_to_strip is not None and tags_to_convert is not None:
|
if tags_to_strip is not None and tags_to_convert is not None:
|
||||||
raise ValueError('You may specify either tags to strip or tags to'
|
raise ValueError('You may specify either tags to strip or tags to'
|
||||||
' convert, but not both.')
|
' convert, but not both.')
|
||||||
self.tags_to_strip = tags_to_strip
|
self.tags_to_strip = tags_to_strip
|
||||||
self.tags_to_convert = tags_to_convert
|
self.tags_to_convert = tags_to_convert
|
||||||
|
|
||||||
def convert(self, html):
|
def convert(self, html):
|
||||||
soup = fromstring(html)
|
# We want to take advantage of the html5 parsing, but we don't actually
|
||||||
return self.process_tag(soup)
|
# want a full document. Therefore, we'll mark our fragment with an id,
|
||||||
|
# create the document, and extract the element with the id.
|
||||||
|
html = wrapped % html
|
||||||
|
soup = BeautifulSoup(html)
|
||||||
|
return self.process_tag(soup.find(id=FRAGMENT_ID), children_only=True)
|
||||||
|
|
||||||
def process_tag(self, node):
|
def process_tag(self, node, children_only=False):
|
||||||
text = self.process_text(node.text)
|
text = ''
|
||||||
|
|
||||||
# Convert the children first
|
# Convert the children first
|
||||||
for el in node.findall('*'):
|
for el in node.children:
|
||||||
text += self.process_tag(el)
|
if isinstance(el, NavigableString):
|
||||||
|
text += self.process_text(unicode(el))
|
||||||
|
else:
|
||||||
|
text += self.process_tag(el)
|
||||||
|
|
||||||
convert_fn = getattr(self, 'convert_%s' % node.tag, None)
|
if not children_only:
|
||||||
if convert_fn and self.should_convert_tag(node.tag):
|
convert_fn = getattr(self, 'convert_%s' % node.name, None)
|
||||||
text = convert_fn(node, text)
|
if convert_fn and self.should_convert_tag(node.name):
|
||||||
|
text = convert_fn(node, text)
|
||||||
text += self.process_text(node.tail)
|
|
||||||
|
|
||||||
return text
|
return text
|
||||||
|
|
||||||
@@ -102,8 +110,8 @@ class MarkdownConverter(object):
|
|||||||
return self.convert_em(el, text)
|
return self.convert_em(el, text)
|
||||||
|
|
||||||
def convert_li(self, el, text):
|
def convert_li(self, el, text):
|
||||||
parent = el.getparent()
|
parent = el.parent
|
||||||
if parent is not None and parent.tag == 'ol':
|
if parent is not None and parent.name == 'ol':
|
||||||
bullet = '%s.' % (parent.index(el) + 1)
|
bullet = '%s.' % (parent.index(el) + 1)
|
||||||
else:
|
else:
|
||||||
bullet = '*'
|
bullet = '*'
|
||||||
|
|||||||
8
markdownify/pkgmeta.py
Normal file
8
markdownify/pkgmeta.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
pkgmeta = dict(
|
||||||
|
__title__='markdownify',
|
||||||
|
__author__='Matthew Tretter',
|
||||||
|
__version__='0.3.0',
|
||||||
|
)
|
||||||
|
|
||||||
|
globals().update(pkgmeta)
|
||||||
|
__all__ = pkgmeta.keys()
|
||||||
@@ -1 +0,0 @@
|
|||||||
__version__ = '0.1.0'
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
from nose.core import run, collector
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
run()
|
|
||||||
73
setup.py
73
setup.py
@@ -2,31 +2,80 @@
|
|||||||
import codecs
|
import codecs
|
||||||
import os
|
import os
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
from setuptools.command.test import test as TestCommand, Command
|
||||||
|
|
||||||
|
|
||||||
read = lambda filepath: codecs.open(filepath, 'r', 'utf-8').read()
|
read = lambda filepath: codecs.open(filepath, 'r', 'utf-8').read()
|
||||||
execfile(os.path.join(os.path.dirname(__file__), 'markdownify', 'version.py'))
|
|
||||||
|
|
||||||
|
pkgmeta = {}
|
||||||
|
execfile(os.path.join(os.path.dirname(__file__), 'markdownify', 'pkgmeta.py'),
|
||||||
|
pkgmeta)
|
||||||
|
|
||||||
|
|
||||||
|
class PyTest(TestCommand):
|
||||||
|
def finalize_options(self):
|
||||||
|
TestCommand.finalize_options(self)
|
||||||
|
self.test_args = ['tests', '-s']
|
||||||
|
self.test_suite = True
|
||||||
|
|
||||||
|
def run_tests(self):
|
||||||
|
import pytest
|
||||||
|
errno = pytest.main(self.test_args)
|
||||||
|
raise SystemExit(errno)
|
||||||
|
|
||||||
|
|
||||||
|
class LintCommand(Command):
|
||||||
|
"""
|
||||||
|
A copy of flake8's Flake8Command
|
||||||
|
|
||||||
|
"""
|
||||||
|
description = "Run flake8 on modules registered in setuptools"
|
||||||
|
user_options = []
|
||||||
|
|
||||||
|
def initialize_options(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def finalize_options(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def distribution_files(self):
|
||||||
|
if self.distribution.packages:
|
||||||
|
for package in self.distribution.packages:
|
||||||
|
yield package.replace(".", os.path.sep)
|
||||||
|
|
||||||
|
if self.distribution.py_modules:
|
||||||
|
for filename in self.distribution.py_modules:
|
||||||
|
yield "%s.py" % filename
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
from flake8.engine import get_style_guide
|
||||||
|
flake8_style = get_style_guide(config_file='setup.cfg')
|
||||||
|
paths = self.distribution_files()
|
||||||
|
report = flake8_style.check_files(paths)
|
||||||
|
raise SystemExit(report.total_errors > 0)
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='python-markdownify',
|
name='markdownify',
|
||||||
description='Convert HTML to markdown.',
|
description='Convert HTML to markdown.',
|
||||||
long_description=read(os.path.join(os.path.dirname(__file__), 'README.rst')),
|
long_description=read(os.path.join(os.path.dirname(__file__), 'README.rst')),
|
||||||
version=__version__,
|
version=pkgmeta['__version__'],
|
||||||
author='Matthew Tretter',
|
author=pkgmeta['__author__'],
|
||||||
author_email='matthew@exanimo.com',
|
author_email='m@tthewwithanm.com',
|
||||||
url='http://github.com/matthewwithanm/python-markdownify',
|
url='http://github.com/matthewwithanm/python-markdownify',
|
||||||
download_url='http://github.com/matthewwithanm/python-markdownify/tarball/master',
|
download_url='http://github.com/matthewwithanm/python-markdownify/tarball/master',
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
|
setup_requires=[
|
||||||
|
'flake8',
|
||||||
|
],
|
||||||
tests_require=[
|
tests_require=[
|
||||||
'nose',
|
'pytest',
|
||||||
'unittest2',
|
|
||||||
],
|
],
|
||||||
install_requires=[
|
install_requires=[
|
||||||
'lxml',
|
'beautifulsoup4',
|
||||||
'BeautifulSoup',
|
|
||||||
],
|
],
|
||||||
classifiers=[
|
classifiers=[
|
||||||
'Environment :: Web Environment',
|
'Environment :: Web Environment',
|
||||||
@@ -39,6 +88,8 @@ setup(
|
|||||||
'Programming Language :: Python :: 2.7',
|
'Programming Language :: Python :: 2.7',
|
||||||
'Topic :: Utilities'
|
'Topic :: Utilities'
|
||||||
],
|
],
|
||||||
setup_requires=[],
|
cmdclass={
|
||||||
test_suite='runtests.collector',
|
'test': PyTest,
|
||||||
|
'lint': LintCommand,
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
123
tests.py
123
tests.py
@@ -1,123 +0,0 @@
|
|||||||
import unittest
|
|
||||||
from markdownify import markdownify as md
|
|
||||||
|
|
||||||
|
|
||||||
class BasicTests(unittest.TestCase):
|
|
||||||
|
|
||||||
def test_single_tag(self):
|
|
||||||
self.assertEqual(md('<span>Hello</span>'), 'Hello')
|
|
||||||
|
|
||||||
def test_soup(self):
|
|
||||||
self.assertEqual(md('<div><span>Hello</div></span>'), 'Hello')
|
|
||||||
|
|
||||||
def test_whitespace(self):
|
|
||||||
self.assertEqual(md(' a b \n\n c '), ' a b c ')
|
|
||||||
|
|
||||||
|
|
||||||
class ArgTests(unittest.TestCase):
|
|
||||||
|
|
||||||
def test_strip(self):
|
|
||||||
self.assertEqual(
|
|
||||||
md('<a href="https://github.com/matthewwithanm">Some Text</a>', strip=['a']),
|
|
||||||
'Some Text')
|
|
||||||
|
|
||||||
def test_do_not_strip(self):
|
|
||||||
self.assertEqual(
|
|
||||||
md('<a href="https://github.com/matthewwithanm">Some Text</a>', strip=[]),
|
|
||||||
'[Some Text](https://github.com/matthewwithanm)')
|
|
||||||
|
|
||||||
def test_convert(self):
|
|
||||||
self.assertEqual(
|
|
||||||
md('<a href="https://github.com/matthewwithanm">Some Text</a>', convert=['a']),
|
|
||||||
'[Some Text](https://github.com/matthewwithanm)')
|
|
||||||
|
|
||||||
def test_do_not_convert(self):
|
|
||||||
self.assertEqual(
|
|
||||||
md('<a href="https://github.com/matthewwithanm">Some Text</a>', convert=[]),
|
|
||||||
'Some Text')
|
|
||||||
|
|
||||||
|
|
||||||
class EscapeTests(unittest.TestCase):
|
|
||||||
|
|
||||||
def test_underscore(self):
|
|
||||||
self.assertEqual(md('_hey_dude_'), '\_hey\_dude\_')
|
|
||||||
|
|
||||||
def test_xml_entities(self):
|
|
||||||
self.assertEqual(md('&'), '&')
|
|
||||||
|
|
||||||
def test_named_entities(self):
|
|
||||||
self.assertEqual(md('»'), u'\xbb')
|
|
||||||
|
|
||||||
def test_hexadecimal_entities(self):
|
|
||||||
# This looks to be a bug in BeautifulSoup (fixed in bs4) that we have to work around.
|
|
||||||
self.assertEqual(md('''), '\x27')
|
|
||||||
|
|
||||||
def test_single_escaping_entities(self):
|
|
||||||
self.assertEqual(md('&amp;'), '&')
|
|
||||||
|
|
||||||
|
|
||||||
class ConversionTests(unittest.TestCase):
|
|
||||||
|
|
||||||
def test_a(self):
|
|
||||||
self.assertEqual(
|
|
||||||
md('<a href="http://google.com">Google</a>'),
|
|
||||||
'[Google](http://google.com)'
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_a_with_title(self):
|
|
||||||
self.assertEqual(
|
|
||||||
md('<a href="http://google.com" title="The "Goog"">Google</a>'),
|
|
||||||
r'[Google](http://google.com "The \"Goog\"")'
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_b(self):
|
|
||||||
self.assertEqual(md('<b>Hello</b>'), '**Hello**')
|
|
||||||
|
|
||||||
def test_blockquote(self):
|
|
||||||
self.assertEqual(md('<blockquote>Hello</blockquote>').strip(), '> Hello')
|
|
||||||
|
|
||||||
def test_nested_blockquote(self):
|
|
||||||
self.assertEqual(
|
|
||||||
md('<blockquote>And she was like <blockquote>Hello</blockquote></blockquote>').strip(),
|
|
||||||
'> And she was like \n> > Hello'
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_br(self):
|
|
||||||
self.assertEqual(md('a<br />b<br />c'), 'a \nb \nc')
|
|
||||||
|
|
||||||
def test_em(self):
|
|
||||||
self.assertEqual(md('<em>Hello</em>'), '*Hello*')
|
|
||||||
|
|
||||||
def test_h1(self):
|
|
||||||
self.assertEqual(md('<h1>Hello</h1>'), 'Hello\n=====\n\n')
|
|
||||||
|
|
||||||
def test_h2(self):
|
|
||||||
self.assertEqual(md('<h2>Hello</h2>'), 'Hello\n-----\n\n')
|
|
||||||
|
|
||||||
def test_hn(self):
|
|
||||||
self.assertEqual(md('<h3>Hello</h3>'), '### Hello\n\n')
|
|
||||||
self.assertEqual(md('<h6>Hello</h6>'), '###### Hello\n\n')
|
|
||||||
|
|
||||||
def test_i(self):
|
|
||||||
self.assertEqual(md('<i>Hello</i>'), '*Hello*')
|
|
||||||
|
|
||||||
def test_ol(self):
|
|
||||||
self.assertEqual(md('<ol><li>a</li><li>b</li></ol>'), '1. a\n2. b\n')
|
|
||||||
|
|
||||||
def test_p(self):
|
|
||||||
self.assertEqual(md('<p>hello</p>'), 'hello\n\n')
|
|
||||||
|
|
||||||
def test_strong(self):
|
|
||||||
self.assertEqual(md('<strong>Hello</strong>'), '**Hello**')
|
|
||||||
|
|
||||||
def test_ul(self):
|
|
||||||
self.assertEqual(md('<ul><li>a</li><li>b</li></ul>'), '* a\n* b\n')
|
|
||||||
|
|
||||||
|
|
||||||
class AdvancedTests(unittest.TestCase):
|
|
||||||
|
|
||||||
def test_nested(self):
|
|
||||||
self.assertEqual(
|
|
||||||
md('<p>This is an <a href="http://example.com/">example link</a>.</p>'),
|
|
||||||
'This is an [example link](http://example.com/).\n\n'
|
|
||||||
)
|
|
||||||
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
6
tests/test_advanced.py
Normal file
6
tests/test_advanced.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
from markdownify import markdownify as md
|
||||||
|
|
||||||
|
|
||||||
|
def test_nested():
|
||||||
|
text = md('<p>This is an <a href="http://example.com/">example link</a>.</p>')
|
||||||
|
assert text == 'This is an [example link](http://example.com/).\n\n'
|
||||||
25
tests/test_args.py
Normal file
25
tests/test_args.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
"""
|
||||||
|
Test whitelisting/blacklisting of specific tags.
|
||||||
|
|
||||||
|
"""
|
||||||
|
from markdownify import markdownify as md
|
||||||
|
|
||||||
|
|
||||||
|
def test_strip():
|
||||||
|
text = md('<a href="https://github.com/matthewwithanm">Some Text</a>', strip=['a'])
|
||||||
|
assert text == 'Some Text'
|
||||||
|
|
||||||
|
|
||||||
|
def test_do_not_strip():
|
||||||
|
text = md('<a href="https://github.com/matthewwithanm">Some Text</a>', strip=[])
|
||||||
|
assert text == '[Some Text](https://github.com/matthewwithanm)'
|
||||||
|
|
||||||
|
|
||||||
|
def test_convert():
|
||||||
|
text = md('<a href="https://github.com/matthewwithanm">Some Text</a>', convert=['a'])
|
||||||
|
assert text == '[Some Text](https://github.com/matthewwithanm)'
|
||||||
|
|
||||||
|
|
||||||
|
def test_do_not_convert():
|
||||||
|
text = md('<a href="https://github.com/matthewwithanm">Some Text</a>', convert=[])
|
||||||
|
assert text == 'Some Text'
|
||||||
13
tests/test_basic.py
Normal file
13
tests/test_basic.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
from markdownify import markdownify as md
|
||||||
|
|
||||||
|
|
||||||
|
def test_single_tag():
|
||||||
|
assert md('<span>Hello</span>') == 'Hello'
|
||||||
|
|
||||||
|
|
||||||
|
def test_soup():
|
||||||
|
assert md('<div><span>Hello</div></span>') == 'Hello'
|
||||||
|
|
||||||
|
|
||||||
|
def test_whitespace():
|
||||||
|
assert md(' a b \n\n c ') == ' a b c '
|
||||||
64
tests/test_conversions.py
Normal file
64
tests/test_conversions.py
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
from markdownify import markdownify as md
|
||||||
|
|
||||||
|
|
||||||
|
def test_a():
|
||||||
|
assert md('<a href="http://google.com">Google</a>') == '[Google](http://google.com)'
|
||||||
|
|
||||||
|
|
||||||
|
def test_a_with_title():
|
||||||
|
text = md('<a href="http://google.com" title="The "Goog"">Google</a>')
|
||||||
|
assert text == r'[Google](http://google.com "The \"Goog\"")'
|
||||||
|
|
||||||
|
|
||||||
|
def test_b():
|
||||||
|
assert md('<b>Hello</b>') == '**Hello**'
|
||||||
|
|
||||||
|
|
||||||
|
def test_blockquote():
|
||||||
|
assert md('<blockquote>Hello</blockquote>').strip() == '> Hello'
|
||||||
|
|
||||||
|
|
||||||
|
def test_nested_blockquote():
|
||||||
|
text = md('<blockquote>And she was like <blockquote>Hello</blockquote></blockquote>').strip()
|
||||||
|
assert text == '> And she was like \n> > Hello'
|
||||||
|
|
||||||
|
|
||||||
|
def test_br():
|
||||||
|
assert md('a<br />b<br />c') == 'a \nb \nc'
|
||||||
|
|
||||||
|
|
||||||
|
def test_em():
|
||||||
|
assert md('<em>Hello</em>') == '*Hello*'
|
||||||
|
|
||||||
|
|
||||||
|
def test_h1():
|
||||||
|
assert md('<h1>Hello</h1>') == 'Hello\n=====\n\n'
|
||||||
|
|
||||||
|
|
||||||
|
def test_h2():
|
||||||
|
assert md('<h2>Hello</h2>') == 'Hello\n-----\n\n'
|
||||||
|
|
||||||
|
|
||||||
|
def test_hn():
|
||||||
|
assert md('<h3>Hello</h3>') == '### Hello\n\n'
|
||||||
|
assert md('<h6>Hello</h6>') == '###### Hello\n\n'
|
||||||
|
|
||||||
|
|
||||||
|
def test_i():
|
||||||
|
assert md('<i>Hello</i>') == '*Hello*'
|
||||||
|
|
||||||
|
|
||||||
|
def test_ol():
|
||||||
|
assert md('<ol><li>a</li><li>b</li></ol>') == '1. a\n2. b\n'
|
||||||
|
|
||||||
|
|
||||||
|
def test_p():
|
||||||
|
assert md('<p>hello</p>') == 'hello\n\n'
|
||||||
|
|
||||||
|
|
||||||
|
def test_strong():
|
||||||
|
assert md('<strong>Hello</strong>') == '**Hello**'
|
||||||
|
|
||||||
|
|
||||||
|
def test_ul():
|
||||||
|
assert md('<ul><li>a</li><li>b</li></ul>') == '* a\n* b\n'
|
||||||
22
tests/test_escaping.py
Normal file
22
tests/test_escaping.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
from markdownify import markdownify as md
|
||||||
|
|
||||||
|
|
||||||
|
def test_underscore():
|
||||||
|
assert md('_hey_dude_') == '\_hey\_dude\_'
|
||||||
|
|
||||||
|
|
||||||
|
def test_xml_entities():
|
||||||
|
assert md('&') == '&'
|
||||||
|
|
||||||
|
|
||||||
|
def test_named_entities():
|
||||||
|
assert md('»') == u'\xbb'
|
||||||
|
|
||||||
|
|
||||||
|
def test_hexadecimal_entities():
|
||||||
|
# This looks to be a bug in BeautifulSoup (fixed in bs4) that we have to work around.
|
||||||
|
assert md(''') == '\x27'
|
||||||
|
|
||||||
|
|
||||||
|
def test_single_escaping_entities():
|
||||||
|
assert md('&amp;') == '&'
|
||||||
Reference in New Issue
Block a user