{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://schemas.asciidoc.org/asg/1-0-0/draft-01",
"title": "AsciiDoc Abstract Semantic Graph (ASG)",
"description": "A structured representation of the semantics in an AsciiDoc document, primarily used for validating the compliance of an AsciiDoc processor.",
"type": "object",
"required": ["name", "type"],
"defaults": { "blocks": [] },
"additionalProperties": false,
"properties": {
"name": {
"type": "string",
"const": "document"
},
"type": {
"type": "string",
"const": "block"
},
"attributes": {
"type": "object",
"additionalProperties": false,
"patternProperties": {
"^[a-zA-Z0-9_][-a-zA-Z0-9_]*$": {
"oneOf": [
{ "type": "string" },
{ "type": "null" }
]
}
}
},
"header": {
"type": "object",
"additionalProperties": false,
"properties": {
"title": { "$ref": "#/$defs/inlines" },
"authors": {
"type": "array",
"items": { "$ref": "#/$defs/author" },
"minItems": 1
},
"location": { "$ref": "#/$defs/location" }
}
},
"blocks": { "$ref": "#/$defs/sectionBody" },
"location": { "$ref": "#/$defs/location" }
},
"if": {
"required": ["header"]
},
"then": {
"required": ["attributes"]
},
"$defs": {
"abstractBlock": {
"type": "object",
"required": ["type"],
"properties": {
"type": {
"type": "string",
"const": "block"
},
"id": {
"type": "string"
},
"title": { "$ref": "#/$defs/inlines" },
"reftext": { "$ref": "#/$defs/inlines" },
"metadata": { "$ref": "#/$defs/blockMetadata" },
"location": { "$ref": "#/$defs/location" }
}
},
"abstractHeading": {
"type": "object",
"allOf": [{ "$ref": "#/$defs/abstractBlock" }],
"required": ["title", "level"],
"properties": {
"level": {
"type": "integer",
"minimum": 0
}
}
},
"abstractListItem": {
"type": "object",
"allOf": [{ "$ref": "#/$defs/abstractBlock" }],
"required": ["marker"],
"defaults": { "blocks": [] },
"properties": {
"marker": {
"type": "string"
},
"principal": { "$ref": "#/$defs/inlines" },
"blocks": { "$ref": "#/$defs/nonSectionBlockBody" }
}
},
"sectionBody": {
"type": "array",
"items": {
"type": "object",
"oneOf": [
{ "$ref": "#/$defs/block" },
{ "$ref": "#/$defs/section" }
]
}
},
"nonSectionBlockBody": {
"type": "array",
"items": { "$ref": "#/$defs/block" }
},
"section": {
"type": "object",
"allOf": [{ "$ref": "#/$defs/abstractHeading" }],
"unevaluatedProperties": false,
"required": ["name"],
"defaults": { "blocks": [] },
"properties": {
"name": {
"type": "string",
"const": "section"
},
"blocks": { "$ref": "#/$defs/sectionBody" }
}
},
"block": {
"type": "object",
"discriminator": { "propertyName": "name" },
"oneOf": [
{ "$ref": "#/$defs/list" },
{ "$ref": "#/$defs/dlist" },
{ "$ref": "#/$defs/discreteHeading" },
{ "$ref": "#/$defs/break" },
{ "$ref": "#/$defs/blockMacro" },
{ "$ref": "#/$defs/leafBlock" },
{ "$ref": "#/$defs/parentBlock" }
]
},
"list": {
"type": "object",
"allOf": [{ "$ref": "#/$defs/abstractBlock" }],
"unevaluatedProperties": false,
"required": ["name", "marker", "variant", "items"],
"properties": {
"name": {
"type": "string",
"const": "list"
},
"marker": {
"type": "string"
},
"variant": {
"type": "string",
"enum": ["callout", "ordered", "unordered"]
},
"items": {
"type": "array",
"items": { "$ref": "#/$defs/listItem" },
"minItems": 1
}
}
},
"dlist": {
"type": "object",
"allOf": [{ "$ref": "#/$defs/abstractBlock" }],
"unevaluatedProperties": false,
"required": ["name", "marker", "items"],
"properties": {
"name": {
"type": "string",
"const": "dlist"
},
"marker": {
"type": "string"
},
"items": {
"type": "array",
"items": { "$ref": "#/$defs/dlistItem" },
"minItems": 1
}
}
},
"listItem": {
"type": "object",
"allOf": [{ "$ref": "#/$defs/abstractListItem" }],
"unevaluatedProperties": false,
"required": ["name", "principal"],
"properties": {
"name": {
"type": "string",
"const": "listItem"
}
}
},
"dlistItem": {
"type": "object",
"allOf": [{ "$ref": "#/$defs/abstractListItem" }],
"unevaluatedProperties": false,
"required": ["name", "terms"],
"properties": {
"name": {
"type": "string",
"const": "dlistItem"
},
"terms": {
"type": "array",
"items": { "$ref": "#/$defs/inlines" },
"minItems": 1
}
}
},
"discreteHeading": {
"type": "object",
"allOf": [{ "$ref": "#/$defs/abstractHeading" }],
"unevaluatedProperties": false,
"required": ["name"],
"properties": {
"name": {
"type": "string",
"const": "heading"
}
}
},
"break": {
"type": "object",
"allOf": [{ "$ref": "#/$defs/abstractBlock" }],
"unevaluatedProperties": false,
"required": ["name", "variant"],
"properties": {
"name": {
"type": "string",
"const": "break"
},
"variant": {
"type": "string",
"enum": ["page", "thematic"]
}
}
},
"blockMacro": {
"type": "object",
"allOf": [{ "$ref": "#/$defs/abstractBlock" }],
"unevaluatedProperties": false,
"required": ["name", "form"],
"properties": {
"name": {
"type": "string",
"enum": ["audio", "video", "image", "toc"]
},
"form": {
"type": "string",
"const": "macro"
},
"target": {
"type": "string"
}
}
},
"leafBlock": {
"type": "object",
"allOf": [
{ "$ref": "#/$defs/abstractBlock" },
{
"if": {
"required": ["form"],
"properties": { "form": { "const": "delimited" } }
},
"then": {
"required": ["delimiter"],
"properties": {
"delimiter": {
"type": "string"
}
}
}
}
],
"unevaluatedProperties": false,
"required": ["name"],
"defaults": { "inlines": [] },
"properties": {
"name": {
"type": "string",
"enum": ["listing", "literal", "paragraph", "pass", "stem", "verse"]
},
"form": {
"type": "string",
"enum": ["delimited", "indented", "paragraph"]
},
"inlines": { "$ref": "#/$defs/inlines" }
}
},
"parentBlock": {
"type": "object",
"allOf": [
{ "$ref": "#/$defs/abstractBlock" },
{
"if": {
"required": ["name"],
"properties": { "name": { "const": "admonition" } }
},
"then": {
"required": ["variant"],
"properties": {
"variant": {
"type": "string",
"enum": ["caution", "important", "note", "tip", "warning"]
}
}
}
}
],
"unevaluatedProperties": false,
"required": ["name", "form", "delimiter"],
"defaults": { "blocks": [] },
"properties": {
"name": {
"type": "string",
"enum": ["admonition", "example", "sidebar", "open", "quote"]
},
"form": {
"type": "string",
"const": "delimited"
},
"delimiter": {
"type": "string"
},
"blocks": { "$ref": "#/$defs/nonSectionBlockBody" }
}
},
"blockMetadata": {
"type": "object",
"defaults": { "attributes": {}, "options": [], "roles": [] },
"additionalProperties": false,
"properties": {
"attributes": {
"type": "object",
"additionalProperties": false,
"patternProperties": {
"^(?:[a-zA-Z_][a-zA-Z0-9_-]*|\\$[1-9][0-9]*)$": {
"type": "string"
}
}
},
"options": {
"type": "array",
"items": {
"type": "string"
}
},
"roles": {
"type": "array",
"items": {
"type": "string"
}
},
"location": { "$ref": "#/$defs/location" }
}
},
"inlines": {
"type": "array",
"items": { "$ref": "#/$defs/inline" }
},
"inline": {
"type": "object",
"discriminator": { "propertyName": "name" },
"oneOf": [
{ "$ref": "#/$defs/inlineSpan" },
{ "$ref": "#/$defs/inlineRef" },
{ "$ref": "#/$defs/inlineLiteral" }
]
},
"abstractParentInline": {
"type": "object",
"required": ["type", "inlines"],
"properties": {
"type": {
"type": "string",
"const": "inline"
},
"inlines": { "$ref": "#/$defs/inlines" },
"location": { "$ref": "#/$defs/location" }
}
},
"inlineSpan": {
"type": "object",
"allOf": [{ "$ref": "#/$defs/abstractParentInline" }],
"unevaluatedProperties": false,
"required": ["name", "variant", "form"],
"properties": {
"name": {
"type": "string",
"const": "span"
},
"variant": {
"type": "string",
"enum": ["strong", "emphasis", "code", "mark"]
},
"form": {
"type": "string",
"enum": ["constrained", "unconstrained"]
}
}
},
"inlineRef": {
"type": "object",
"allOf": [{ "$ref": "#/$defs/abstractParentInline" }],
"unevaluatedProperties": false,
"required": ["name", "variant", "target"],
"properties": {
"name": {
"type": "string",
"const": "ref"
},
"variant": {
"type": "string",
"enum": ["link", "xref"]
},
"target": {
"type": "string"
}
}
},
"inlineLiteral": {
"type": "object",
"required": ["name", "type", "value"],
"additionalProperties": false,
"properties": {
"name": {
"type": "string",
"enum": ["text", "charref", "raw"]
},
"type": {
"type": "string",
"const": "string"
},
"value": {
"type": "string"
},
"location": { "$ref": "#/$defs/location" }
}
},
"author": {
"type": "object",
"additionalProperties": false,
"properties": {
"fullname": {
"type": "string"
},
"initials": {
"type": "string"
},
"firstname": {
"type": "string"
},
"middlename": {
"type": "string"
},
"lastname": {
"type": "string"
},
"address": {
"type": "string"
}
}
},
"location": {
"type": "array",
"prefixItems": [
{ "$ref": "#/$defs/locationBoundary" },
{ "$ref": "#/$defs/locationBoundary" }
],
"minItems": 2,
"maxItems": 2
},
"locationBoundary": {
"type": "object",
"required": ["line", "col"],
"additionalProperties": false,
"properties": {
"line": {
"type": "integer",
"minimum": 1
},
"col": {
"type": "integer",
"minimum": 0
},
"file": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1
}
}
}
}
}