Skip to content

TypeError is shown if html has wrong h tag #142

Closed

Description

@vokiput

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'

Activity

  1. Repository owner deleted a comment from masooddahmedd on Aug 26, 2024
  2. Repository owner deleted a comment from masooddahmedd on Aug 26, 2024
  3. Ronak-Ronu commented on Sep 26, 2024

    @Ronak-Ronu

    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}")
  4. AlexVonB commented on Nov 24, 2024

    @AlexVonB
    Collaborator

    Thanks for finding this!

  5. added a commit that references this issue on Nov 24, 2024
    3466061
  6. added a commit that references this issue on May 21, 2025
    1cf3266
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions