Skip to content

fix(utils): use a parser name BeautifulSoup knows in format_html - #2553

Open
HhH666-ux wants to merge 1 commit into
unclecode:developfrom
HhH666-ux:fix/format-html-parser
Open

HhH666-ux wants to merge 1 commit into
unclecode:developfrom
HhH666-ux:fix/format-html-parser

Conversation

@HhH666-ux

Copy link
Copy Markdown

Summary

Fixes #2551.

format_html() now parses with "lxml" instead of the invalid feature string "lxml.parser", so it returns prettified HTML instead of raising FeatureNotFound on every call.

List of files changed and why

  • crawl4ai/utils.py - one-line parser fix, matching the BeautifulSoup(..., "lxml") call sites already used in this package.
  • tests/test_format_html_parser.py - regression tests proving the function returns prettified markup for plain and table HTML.

How Has This Been Tested?

python -m pytest tests/test_format_html_parser.py -q
2 passed

Before the change the same calls raised:

bs4.exceptions.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml.parser.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added/updated unit tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

`format_html` passed the feature string "lxml.parser" to BeautifulSoup, which
is not a valid tree builder name, so every call raised FeatureNotFound. Use
"lxml", matching the other BeautifulSoup call sites in this package.
@ntohidi
ntohidi changed the base branch from main to develop November 13, 2026 10:44
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

Successfully merging this pull request may close these issues.

format_html() always raises FeatureNotFound because of the 'lxml.parser' tree builder name

1 participant