feat: add "markdown" field type to extraction strategy schema (#1708)#1881
Open
hafezparast wants to merge 1 commit intounclecode:mainfrom
Open
feat: add "markdown" field type to extraction strategy schema (#1708)#1881hafezparast wants to merge 1 commit intounclecode:mainfrom
hafezparast wants to merge 1 commit intounclecode:mainfrom
Conversation
…lecode#1708) Add "markdown" as a new field type in the extraction schema type pipeline. When used, the selected element's HTML is converted to markdown via CustomHTML2Text, preserving formatting (bold, links, lists) without returning raw HTML tags. Works across all strategy subclasses (CSS, lxml, XPath) and in pipelines (e.g., ["markdown", "regex"]). Closes unclecode#1708 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
"markdown"as a new field type inJsonElementExtractionStrategy's type pipelineJsonCssExtractionStrategy,JsonLxmlExtractionStrategy,JsonXPathExtractionStrategy["markdown", "regex"]works naturallyCloses #1708
Changes
crawl4ai/extraction_strategy.py: 8 lines — addelif step == "markdown"branch +CustomHTML2Textimporttests/test_markdown_field_type_1708.py: 16 tests covering CSS/lxml/XPath strategies, pipeline chaining, edge cases, JSON serializationUsage
Before (only options):
"text"Best seller - Our most popular widget with advanced features."html"<p><strong>Best seller</strong> - Our most popular widget with <em>advanced features</em>.</p>After (new option):
"markdown"**Best seller** - Our most popular widget with _advanced features_.Also works in pipelines:
Test plan
pytest tests/test_markdown_field_type_1708.py -v)pytest tests/test_pr_1290_1668.py -v)🤖 Generated with Claude Code