Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError is shown if html has wrong h tag #142

Open
vokiput opened this issue Aug 26, 2024 · 1 comment
Open

TypeError is shown if html has wrong h tag #142

vokiput opened this issue Aug 26, 2024 · 1 comment

Comments

@vokiput
Copy link

vokiput commented Aug 26, 2024

markdownify in ./.venv/lib/python3.8/site-packages (0.13.1)

The issue is found with atheris library

Code to reproduce
markdownify("<hn>")

The error is:

Traceback (most recent call last):
  File "/home/redacted/code/other/atheris/pythonProject/test_unit_009-1.py", line 26, in <module>
    markdownify("<hn>")
  File "/home/redacted/code/other/atheris/pythonProject/.venv/lib/python3.8/site-packages/markdownify/__init__.py", line 433, in markdownify
    return MarkdownConverter(**options).convert(html)
  File "/home/redacted/code/other/atheris/pythonProject/.venv/lib/python3.8/site-packages/markdownify/__init__.py", line 105, in convert
    return self.convert_soup(soup)
  File "/home/redacted/code/other/atheris/pythonProject/.venv/lib/python3.8/site-packages/markdownify/__init__.py", line 108, in convert_soup
    return self.process_tag(soup, convert_as_inline=False, children_only=True)
  File "/home/redacted/code/other/atheris/pythonProject/.venv/lib/python3.8/site-packages/markdownify/__init__.py", line 151, in process_tag
    text += self.process_tag(el, convert_children_as_inline)
  File "/home/redacted/code/other/atheris/pythonProject/.venv/lib/python3.8/site-packages/markdownify/__init__.py", line 156, in process_tag
    text = convert_fn(node, text, convert_as_inline)
TypeError: convert_hn() missing 1 required positional argument: 'convert_as_inline'

Repository owner deleted a comment from masooddahmedd Aug 26, 2024
Repository owner deleted a comment from masooddahmedd Aug 26, 2024
@Ronak-Ronu
Copy link

Implement error handling to catch this specific TypeError. For example:

html_input = "<hn>Title</hn>"

try:
    markdown_output = md(html_input)
except TypeError as e:
    print(f"Error: {e}")
    print(f"Offending HTML: {html_input}")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@vokiput @Ronak-Ronu and others