diff --git a/README.rst b/README.rst
index 9a06912..7fa0b19 100644
--- a/README.rst
+++ b/README.rst
@@ -32,14 +32,14 @@ Convert some HTML to Markdown:
from markdownify import markdownify as md
md('Yay GitHub') # > '**Yay** [GitHub](http://github.com)'
-Specify tags to exclude (blacklist):
+Specify tags to exclude:
.. code:: python
from markdownify import markdownify as md
md('Yay GitHub', strip=['a']) # > '**Yay** GitHub'
-\...or specify the tags you want to include (whitelist):
+\...or specify the tags you want to include:
.. code:: python
@@ -53,11 +53,11 @@ Options
Markdownify supports the following options:
strip
- A list of tags to strip (blacklist). This option can't be used with the
+ A list of tags to strip. This option can't be used with the
``convert`` option.
convert
- A list of tags to convert (whitelist). This option can't be used with the
+ A list of tags to convert. This option can't be used with the
``strip`` option.
autolinks
@@ -110,6 +110,18 @@ Options may be specified as kwargs to the ``markdownify`` function, or as a
nested ``Options`` class in ``MarkdownConverter`` subclasses.
+Converting BeautifulSoup objects
+================================
+
+.. code:: python
+
+ from markdownify import MarkdownConverter
+
+ # Create shorthand method for conversion
+ def md(soup, **options):
+ return ImageBlockConverter(**options).convert_soup(soup)
+
+
Creating Custom Converters
==========================
diff --git a/markdownify/__init__.py b/markdownify/__init__.py
index 098c784..82262d4 100644
--- a/markdownify/__init__.py
+++ b/markdownify/__init__.py
@@ -96,6 +96,9 @@ class MarkdownConverter(object):
def convert(self, html):
soup = BeautifulSoup(html, 'html.parser')
+ return self.convert_soup(soup)
+
+ def convert_soup(self, soup):
return self.process_tag(soup, convert_as_inline=False, children_only=True)
def process_tag(self, node, convert_as_inline, children_only=False):
diff --git a/setup.py b/setup.py
index 895ed62..3e5d27b 100644
--- a/setup.py
+++ b/setup.py
@@ -10,7 +10,7 @@ read = lambda filepath: codecs.open(filepath, 'r', 'utf-8').read()
pkgmeta = {
'__title__': 'markdownify',
'__author__': 'Matthew Tretter',
- '__version__': '0.10.2',
+ '__version__': '0.10.3',
}
diff --git a/tests/test_custom_converter.py b/tests/test_custom_converter.py
index c7944ab..a3e33ac 100644
--- a/tests/test_custom_converter.py
+++ b/tests/test_custom_converter.py
@@ -1,4 +1,5 @@
from markdownify import MarkdownConverter
+from bs4 import BeautifulSoup
class ImageBlockConverter(MarkdownConverter):
@@ -16,3 +17,9 @@ def test_img():
assert md('
') == '\n\n'
assert md('
') == '\n\n'
+
+
+def test_soup():
+ html = 'test'
+ soup = BeautifulSoup(html, 'html.parser')
+ assert MarkdownConverter().convert_soup(soup) == '**test**'