Skip to content

Commit 3a83932

Browse files
authored
only remove src from img #93 (#99)
1 parent 0e27d53 commit 3a83932

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

txt2stix/utils.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ def __init__(self, remove_links: bool=False, remove_images: bool=False):
1616

1717
def image(self, token: dict[str, dict], state: mistune.BlockState) -> str:
1818
if self.remove_images:
19-
return ''
19+
token['attrs']['url'] = ''
2020
return super().image(token, state)
2121

2222
def link(self, token: dict[str, dict], state: mistune.BlockState) -> str:
2323
if self.remove_links and token.get('type') != 'image':
24-
return self.render_children(token, state)
24+
token['attrs']['url'] = ''
2525
return super().link(token, state)
2626

2727
def codespan(self, token: dict[str, dict], state: mistune.BlockState) -> str:
@@ -40,7 +40,7 @@ def inline_html(self, token: Dict[str, dict], state: mistune.BlockState) -> str:
4040
del a['href']
4141
if self.remove_images:
4242
for img in soup.find_all('img'):
43-
img.decompose()
43+
del img['src']
4444
return soup.decode()
4545

4646
import tldextract

0 commit comments

Comments
 (0)