wedding-site-backend/test/test_img_replace.py

14 lines
317 B
Python
Raw Permalink Normal View History

2024-02-17 17:56:17 +00:00
import markdown
from bs4 import BeautifulSoup
md_input = """This is an image of a tree: ![tree image](tree_img)
"""
def test_image_replace():
soup = BeautifulSoup(markdown.markdown(md_input), features="html.parser")
for img in soup.find_all('img'):
img["src"] = "blah"
print(soup.prettify())