semsynth.jsonld_to_rdfa

jsonld_to_rdfa.py Generate static HTML with RDFa from nested compact JSON-LD.

Features: - Supports compact JSON-LD with @context, @type, @id. - Infers @vocab and prefixes; defaults to schema.org. - Hyperlinks all absolute IRIs (including @id and property values). - Recursively renders nested objects and arrays. - Detects repeating lists of similar objects and renders them as tables. - No third-party dependencies.

Functions

ensure_ns(v)

extract_vocab_and_prefixes(context)

is_iri(v)

main()

normalize_jsonld_payload(payload)

Ensure mappings carry the canonical JSON-LD context.

render_cell(prop, value, vocab, prefixes, depth)

Cell-friendly rendering (no leading label).

render_iri(prop, iri)

render_literal(prop, value)

render_object(obj, vocab, prefixes, depth)

render_property(prop, value, vocab, ...)

Render a property value in RDFa.

render_rdfa(root, context, title)

repeating_headers(lst)

Return a stable list of shared keys for a list of dicts (ignoring @-keys).

tag(name[, attrs, content, self_close])

Minimal HTML tag builder.

to_list(x)

types_to_iris(types, vocab)

Classes

Any(*args, **kwargs)

Special type indicating an unconstrained type.

Path(*args, **kwargs)

PurePath subclass that can make system calls.

semsynth.jsonld_to_rdfa.ensure_ns(v: str) str
semsynth.jsonld_to_rdfa.extract_vocab_and_prefixes(context: Any) Tuple[str, Dict[str, str]]
semsynth.jsonld_to_rdfa.is_iri(v: Any) bool
semsynth.jsonld_to_rdfa.main() None
semsynth.jsonld_to_rdfa.render_cell(prop: str, value: str | int | float | bool | dict | list | None, vocab: str, prefixes: Dict[str, str], depth: int) str

Cell-friendly rendering (no leading label).

semsynth.jsonld_to_rdfa.render_iri(prop: str, iri: str) str
semsynth.jsonld_to_rdfa.render_literal(prop: str, value: str | int | float | bool) str
semsynth.jsonld_to_rdfa.render_object(obj: Dict[str, Any], vocab: str, prefixes: Dict[str, str], depth: int) str
semsynth.jsonld_to_rdfa.render_property(prop: str, value: str | int | float | bool | dict | list | None, vocab: str, prefixes: Dict[str, str], depth: int) str

Render a property value in RDFa. Handles dict, list, and literals. Recursive.

semsynth.jsonld_to_rdfa.render_rdfa(root: str | int | float | bool | dict | list | None, context: Any, title: str) str
semsynth.jsonld_to_rdfa.repeating_headers(lst: List[dict]) List[str]

Return a stable list of shared keys for a list of dicts (ignoring @-keys).

semsynth.jsonld_to_rdfa.tag(name: str, attrs: Dict[str, str | None] | None = None, content: str = '', self_close: bool = False) str

Minimal HTML tag builder. Escapes attribute values; content is trusted to be already-escaped as needed.

semsynth.jsonld_to_rdfa.to_list(x: Any) List[Any]
semsynth.jsonld_to_rdfa.types_to_iris(types: str | List[str], vocab: str) List[str]