Search by

switon / llm-html

switon

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

This package is auto-updated.

Last update: 2026-11-23 14:47:03 UTC


README

Build Status PHP 8.3+

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.