Reading markings
Pushery\AiContentMarking\MarkingReader finds the markings a rendered page carries. It is the
check for your own test suite: render the page that shows a generated text, and assert that the
marking arrived.
use Pushery\AiContentMarking\MarkingReader;
$html = $this->get('/products/linen-shirt')->getContent();
expect(app(MarkingReader::class)->marksGenerativeAi($html))->toBeTrue();
Pair it with the opposite case. A page that shows no generated text should carry no marking, and an assertion that only ever sees marked pages cannot tell a working check from one that finds something everywhere:
expect(app(MarkingReader::class)->read($this->get('/about')->getContent()))->toBe([]);
What it finds
read() returns a Marking for every link element whose itemprop names digitalSourceType
and whose href is a term of the IPTC vocabulary, either as its IPTC URI or as the schema.org
member that matches it. That is the form MarkedText::html() and Marking::wrap() write, and the
form any other system writing the same microdata uses. The markings come back in document order,
each with its term. Generator and moment are not part of the HTML form, so they stay null here.
marksGenerativeAi() answers whether one of them says generative AI created or edited content.
A link with another property, a link whose address lies outside the vocabulary, a withdrawn
term and a meta element are no marking.
How it reads
The reader reads tags, not a DOM. Attributes count in any order and in each quoting HTML allows,
and character references in an address are decoded. What a browser never renders as an element is
skipped: comments, and the contents of script, style, template and textarea.
It scans a document of at most 2 MiB. A larger one throws a LengthException instead of being
read in part, because a marking past the end of the part would read as no marking at all. The
ceiling is ai-content-marking.reader.max_bytes in the configuration. A
reader you construct yourself takes it as its argument:
$reader = new MarkingReader(maxBytes: 8 * 1024 * 1024);