Skip to content

Commit

Permalink
only remove src from img #93 (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
fqrious authored Nov 25, 2024
1 parent 0e27d53 commit 3a83932
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions txt2stix/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ def __init__(self, remove_links: bool=False, remove_images: bool=False):

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

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

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

import tldextract
Expand Down

0 comments on commit 3a83932

Please sign in to comment.