Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c9b029756 | ||
|
|
25d68b4265 | ||
|
|
5561106991 | ||
|
|
1b3136ad04 | ||
|
|
987a2a9cae | ||
|
|
a4461161bc | ||
|
|
04711027e6 | ||
|
|
28d7a22da3 | ||
|
|
8b882ca3c9 |
18
README.rst
18
README.rst
@@ -1,3 +1,21 @@
|
||||
|build| |version| |license| |downloads|
|
||||
|
||||
.. |build| image:: https://img.shields.io/github/workflow/status/matthewwithanm/python-markdownify/Python%20application/develop
|
||||
:alt: GitHub Workflow Status
|
||||
:target: https://github.com/matthewwithanm/python-markdownify/actions?query=workflow%3A%22Python+application%22
|
||||
|
||||
.. |version| image:: https://img.shields.io/pypi/v/markdownify
|
||||
:alt: Pypi version
|
||||
:target: https://pypi.org/project/markdownify/
|
||||
|
||||
.. |license| image:: https://img.shields.io/pypi/l/markdownify
|
||||
:alt: License
|
||||
:target: https://github.com/matthewwithanm/python-markdownify/blob/develop/LICENSE
|
||||
|
||||
.. |downloads| image:: https://pepy.tech/badge/markdownify
|
||||
:alt: Pypi Downloads
|
||||
:target: https://pepy.tech/project/markdownify
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
|
||||
@@ -6,8 +6,6 @@ import six
|
||||
convert_heading_re = re.compile(r'convert_h(\d+)')
|
||||
line_beginning_re = re.compile(r'^', re.MULTILINE)
|
||||
whitespace_re = re.compile(r'[\r\n\s\t ]+')
|
||||
FRAGMENT_ID = '__MARKDOWNIFY_WRAPPER__'
|
||||
wrapped = '<div id="%s">%%s</div>' % FRAGMENT_ID
|
||||
|
||||
|
||||
# Heading styles
|
||||
@@ -62,12 +60,8 @@ class MarkdownConverter(object):
|
||||
' convert, but not both.')
|
||||
|
||||
def convert(self, html):
|
||||
# We want to take advantage of the html5 parsing, but we don't actually
|
||||
# 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, 'html.parser')
|
||||
return self.process_tag(soup.find(id=FRAGMENT_ID), children_only=True)
|
||||
return self.process_tag(soup, children_only=True)
|
||||
|
||||
def process_tag(self, node, children_only=False):
|
||||
text = ''
|
||||
|
||||
2
setup.py
2
setup.py
@@ -10,7 +10,7 @@ read = lambda filepath: codecs.open(filepath, 'r', 'utf-8').read()
|
||||
pkgmeta = {
|
||||
'__title__': 'markdownify',
|
||||
'__author__': 'Matthew Tretter',
|
||||
'__version__': '0.5.2',
|
||||
'__version__': '0.5.3',
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -157,3 +157,7 @@ def test_bullets():
|
||||
def test_img():
|
||||
assert md('<img src="/path/to/img.jpg" alt="Alt text" title="Optional title" />') == ''
|
||||
assert md('<img src="/path/to/img.jpg" alt="Alt text" />') == ''
|
||||
|
||||
|
||||
def test_div():
|
||||
assert md('Hello</div> World') == 'Hello World'
|
||||
|
||||
Reference in New Issue
Block a user