adjunct.ogp¶
An intensely pragmatic implementation of the Open Graph Protocol.
This follows the specification rather than attempting to implement RDFa.
Theory of Operation¶
The metadata consists of a list of properties. A property may be unstructured (a string) or structured (a list of properties). A property may appear more than once. Properties has the form "ns:name", while a metadata field to be attached to a property (thus making it structured) has the form "ns:name:meta".
Metadata should be implemented as a multimap, but I'll be treating it as a map.
Example of prefix with multiple entries:
If this is present: vocab="http://www.w3.org/2011/rdfa-context/rdfa-1.1",
an initial context is set up consisting of the namespaces given on that page.
Property
dataclass
¶
find(props, type_, value=None)
¶
Find Open Graph properties by type and optional value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
props
|
Sequence[Property]
|
A sequence of |
required |
type_
|
str
|
The property type to search for. |
required |
value
|
str | None
|
An optional property value to match. |
None
|
Returns:
| Type | Description |
|---|---|
Iterable[Property]
|
An iterable of |
parse(properties)
¶
to_meta(props)
¶
Convert Open Graph properties to HTML meta tags.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
props
|
Property | Sequence[Property]
|
A single |
required |
Returns:
| Type | Description |
|---|---|
str
|
A string containing HTML meta tags representing the Open Graph properties. |