switon / llm-html
Main-content extraction that turns noisy HTML into LLM-ready markdown or plain text for Switon Framework
v1.0.0
2026-08-22 14:29 UTC
Requires
- php: >=8.3
- ext-dom: *
- ext-libxml: *
- ext-mbstring: *
- switon/core: ^1.0
Requires (Dev)
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^12.0
- switon/testing: ^1.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Turn noisy HTML into LLM-ready markdown or plain text: drop chrome, keep the main copy, and leave fetching to the caller.
Highlights
- Markdown or plain text from the same kept region.
- Main copy first: prefer an article,
main, or a trusted content id, and fall back to the body. - Non-HTML passthrough: markdown, JSON, and plain text stay unchanged.
- No HTTP: pair it with the fetcher that already has the page.
Installation
composer require switon/llm-html
Quick Start
use Switon\Core\Attribute\Autowired; use Switon\LlmHtml\LlmHtmlInterface; class PageReader { #[Autowired] protected LlmHtmlInterface $llmHtml; public function read(string $html): string { $page = $this->llmHtml->convert($html); return $page->content; } }
convert($html, 'text') returns the same region as tag-stripped prose. The result's title, cleanup, and format say what was kept.
Docs: https://github.com/switon-php/llm-html/blob/main/docs/README.md
License
MIT.