HTML::...Turtle(3pm)
β¨ NAME β¨
HTML::Embedded::Turtle β embedding RDF in HTML the crazy way π
Okay bestie, the manual page here is HTML::...Turtle(3pm) and it's genuinely unhinged in the best way, let's GO π¦
πΈ SYNOPSIS πΈ
use HTML::Embedded::Turtle;
my $het = HTML::Embedded::Turtle->new($html, $base_uri);
foreach my $graph ($het->endorsements)
{
my $model = $het->graph($graph);
# $model is an RDF::Trine::Model. Do something with it.
}
No cap, that's literally the whole vibe. β¨
π DESCRIPTION π
So here's the tea π: RDF can be embedded in (X)HTML using simple <script> tags. This is described at <http://esw.w3.org/N3inHTML>. This gives you a file format that can contain multiple (optionally named) graphs. The document as a whole can "endorse" a graph by including:
<link rel="meta" href="#foo" />
Where "#foo" is a fragment identifier pointing to a graph.
<script type="text/turtle" id="foo"> ... </script>
The rel="meta" stuff is parsed using an RDFa parser, so equivalent RDFa works too. π
This module parses HTML files containing graphs like these, and allows you to access them each individually; as a union of all graphs on the page; or as a union of just the endorsed graphs.
Despite the module name, this module supports a variety of <script type>s: text/turtle, application/turtle, application/x-turtle text/plain (N-Triples), text/n3 (Notation 3), application/x-rdf+json (RDF/JSON), application/json (RDF/JSON), and application/rdf+xml (RDF/XML). it's giving multilingual icon π
The deprecated attribute language is also supported:
<script language="Turtle" id="foo"> ... </script>
Languages supported are (case insensitive): "Turtle", "NTriples", "RDFJSON", "RDFXML" and "Notation3".
π Constructor π
HTML::Embedded::Turtle->new($markup, $base_uri, \%opts)
Create a new object. $markup is the HTML or XHTML markup to parse; $base_uri is the base URI to use for relative references.
Options include:
markupβ Choose which parser to use:'html'or'xml'. The former choosesHTML::HTML5::Parser, which can handle tag soup; the latter choosesXML::LibXML, which cannot. Defaults to'html'. π vs π§, pick your fighter.rdfa_optionsβ A set of options to be parsed toRDF::RDFa::Parserwhen looking for endorsements. SeeRDF::RDFa::Parser::Config. The default is probably sensible. (trust the default bestie, it knows what it's doing)
π Public Methods π
union_graph
A union graph of all graphs found in the document, as an RDF::Trine::Model. Note that the returned model contains quads. π₯
endorsed_union_graph
A union graph of only the endorsed graphs, as an RDF::Trine::Model. Note that the returned model contains quads.
graph($name)
A single graph from the page. β¨
graphs
all_graphs
A hashref where the keys are graph names and the values are RDF::Trine::Models. Some graph names will be URIs, and others may be blank nodes (e.g. "_:foobar").
"graphs" and "all_graphs" are aliases for each other. π«Ά
endorsed_graphs
Like "all_graphs", but only returns endorsed graphs. Note that all endorsed graphs will have graph names that are URIs.
endorsements
Returns a list of URIs which are the names of endorsed graphs. Note that the presence of a URI $x in this list does not imply that "$het->graph($x)" will be defined. π yes this is a jumpscare, no it's not a bug, it's just how it is.
dom
Returns the page DOM. πΈ
uri
Returns the page URI. β
π BUGS π
Please report any bugs to <http://rt.cpan.org/>.
Please forgive me in advance for inflicting this module upon you. π the author is being so real for this honestly
π SEE ALSO π
RDF::RDFa::Parser, RDF::Trine, RDF::TriN3.
π AUTHOR π
Toby Inkster <tobyink@cpan.org>.
π COPYRIGHT AND LICENSE π
Copyright (C) 2010-2011, 2013 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
π¦ DISCLAIMER OF WARRANTIES π¦
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
periodt. no warranty bestie, that's the deal. π
This page is perl v5.32.1, dated 2021-09-11, and it's the HTML::...Turtle(3pm) manual page from User Contributed Perl Documentation. bye ily, go embed some RDF πβ¨
π¦ where this page comes from
- debian bookworm: libhtml-embedded-turtle-perl 0.404-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libhtml-embedded-turtle-perl 0.404-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libhtml-embedded-turtle-perl 0.404-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libhtml-embedded-turtle-perl 0.404-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libhtml-embedded-turtle-perl 0.404-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libhtml-embedded-turtle-perl 0.404-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms