Files
python-markdownify/tests/test_args.py
2025-01-27 11:55:32 -05:00

35 lines
1.2 KiB
Python

"""
Test whitelisting/blacklisting of specific tags.
"""
from markdownify import markdownify, LSTRIP, RSTRIP, STRIP
from .utils import 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'
def test_strip_document():
assert markdownify("<p>Hello</p>") == "Hello" # test default of STRIP
assert markdownify("<p>Hello</p>", strip_document=LSTRIP) == "Hello\n\n"
assert markdownify("<p>Hello</p>", strip_document=RSTRIP) == "\n\nHello"
assert markdownify("<p>Hello</p>", strip_document=STRIP) == "Hello"
assert markdownify("<p>Hello</p>", strip_document=None) == "\n\nHello\n\n"