diff --git a/.changeset/fair-snails-occur.md b/.changeset/fair-snails-occur.md new file mode 100644 index 0000000..0bdb32b --- /dev/null +++ b/.changeset/fair-snails-occur.md @@ -0,0 +1,5 @@ +--- +"oxa-types": minor +--- + +Add Emphasis node type diff --git a/docs/schema/emphasis.md b/docs/schema/emphasis.md new file mode 100644 index 0000000..581683d --- /dev/null +++ b/docs/schema/emphasis.md @@ -0,0 +1,28 @@ +(oxa:emphasis)= + +## Emphasis + + +Emphasized content (typically italicized). + + +__type__: _string_, ("Emphasis") + +: The type discriminator for Emphasis nodes. + +__id__: __string__ + +: A unique identifier for the node. + +__classes__: __array__ ("string") + +: A list of class names for styling or semantics. + +__data__: __object__ + +: Arbitrary key-value data attached to the node. + +__children__: __array__ ("Inline") + +: The inline content to emphasize. +: See @oxa:inline diff --git a/docs/schema/inline.md b/docs/schema/inline.md index bb56078..02a505d 100644 --- a/docs/schema/inline.md +++ b/docs/schema/inline.md @@ -6,4 +6,4 @@ Union of all inline content types. -Union of: @oxa:text, @oxa:strong +Union of: @oxa:text, @oxa:emphasis, @oxa:strong diff --git a/packages/oxa-types-py/src/oxa_types/__init__.py b/packages/oxa-types-py/src/oxa_types/__init__.py index f02db3c..254ca85 100644 --- a/packages/oxa-types-py/src/oxa_types/__init__.py +++ b/packages/oxa-types-py/src/oxa_types/__init__.py @@ -36,6 +36,24 @@ class Document(BaseModel): children: list["Block"] = Field(description="The block content of the document.") +class Emphasis(BaseModel): + """Emphasized content (typically italicized).""" + + model_config = ConfigDict(strict=True) + + type: Literal["Emphasis"] = "Emphasis" + id: str | None = Field( + default=None, description="A unique identifier for the node." + ) + classes: list[str] | None = Field( + default=None, description="A list of class names for styling or semantics." + ) + data: dict[str, Any] | None = Field( + default=None, description="Arbitrary key-value data attached to the node." + ) + children: list["Inline"] = Field(description="The inline content to emphasize.") + + class Heading(BaseModel): """A heading with a level and inline content.""" @@ -114,11 +132,12 @@ class Text(BaseModel): # Union of all inline content types. -Inline = Annotated[Union[Text, Strong], Field(discriminator="type")] +Inline = Annotated[Union[Text, Emphasis, Strong], Field(discriminator="type")] # Rebuild models to resolve forward references Document.model_rebuild() +Emphasis.model_rebuild() Heading.model_rebuild() Paragraph.model_rebuild() Strong.model_rebuild() @@ -128,6 +147,7 @@ class Text(BaseModel): __all__ = [ "Block", "Document", + "Emphasis", "Heading", "Inline", "Paragraph", diff --git a/packages/oxa-types-rs/src/lib.rs b/packages/oxa-types-rs/src/lib.rs index 0e2064a..ca3d749 100644 --- a/packages/oxa-types-rs/src/lib.rs +++ b/packages/oxa-types-rs/src/lib.rs @@ -33,6 +33,24 @@ pub struct Document { pub children: Vec, } +/// Emphasized content (typically italicized). +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +pub struct Emphasis { + /// The type discriminator for Emphasis nodes. + pub r#type: MustBe!("Emphasis"), + /// A unique identifier for the node. + #[serde(skip_serializing_if = "Option::is_none")] + pub id: Option, + /// A list of class names for styling or semantics. + #[serde(skip_serializing_if = "Option::is_none")] + pub classes: Option>, + /// Arbitrary key-value data attached to the node. + #[serde(skip_serializing_if = "Option::is_none")] + pub data: Option, + /// The inline content to emphasize. + pub children: Vec, +} + /// A heading with a level and inline content. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct Heading { @@ -120,5 +138,6 @@ pub enum Block { #[serde(untagged)] pub enum Inline { Text(Text), + Emphasis(Emphasis), Strong(Strong), } diff --git a/packages/oxa-types-ts/src/index.ts b/packages/oxa-types-ts/src/index.ts index 85fe797..e2f2b80 100644 --- a/packages/oxa-types-ts/src/index.ts +++ b/packages/oxa-types-ts/src/index.ts @@ -39,6 +39,32 @@ export interface Document { children: Block[]; } +/** + * Emphasized content (typically italicized). + */ +export interface Emphasis { + /** + * The type discriminator for Emphasis nodes. + */ + type: "Emphasis"; + /** + * A unique identifier for the node. + */ + id?: string; + /** + * A list of class names for styling or semantics. + */ + classes?: string[]; + /** + * Arbitrary key-value data attached to the node. + */ + data?: Record; + /** + * The inline content to emphasize. + */ + children: Inline[]; +} + /** * A heading with a level and inline content. */ @@ -155,4 +181,4 @@ export type Block = Heading | Paragraph; /** * Union of all inline content types. */ -export type Inline = Text | Strong; +export type Inline = Text | Emphasis | Strong; diff --git a/schema/Emphasis.yaml b/schema/Emphasis.yaml new file mode 100644 index 0000000..c4613e8 --- /dev/null +++ b/schema/Emphasis.yaml @@ -0,0 +1,29 @@ +$schema: "http://json-schema.org/draft-07/schema#" +$id: Emphasis +title: Emphasis +description: Emphasized content (typically italicized). +type: object +properties: + type: + description: The type discriminator for Emphasis nodes. + enum: [Emphasis] + id: + description: A unique identifier for the node. + type: string + classes: + description: A list of class names for styling or semantics. + type: array + items: + type: string + data: + description: Arbitrary key-value data attached to the node. + type: object + additionalProperties: true + children: + description: The inline content to emphasize. + type: array + items: + $ref: "./Inline.yaml" +required: + - type + - children diff --git a/schema/Inline.yaml b/schema/Inline.yaml index 83f3e93..b2bb034 100644 --- a/schema/Inline.yaml +++ b/schema/Inline.yaml @@ -4,4 +4,5 @@ title: Inline description: Union of all inline content types. anyOf: - $ref: "./Text.yaml" + - $ref: "./Emphasis.yaml" - $ref: "./Strong.yaml" diff --git a/schema/schema.json b/schema/schema.json index 16f9f21..538361a 100644 --- a/schema/schema.json +++ b/schema/schema.json @@ -64,6 +64,41 @@ }, "required": ["type", "children"] }, + "Emphasis": { + "title": "Emphasis", + "description": "Emphasized content (typically italicized).", + "type": "object", + "properties": { + "type": { + "description": "The type discriminator for Emphasis nodes.", + "enum": ["Emphasis"] + }, + "id": { + "description": "A unique identifier for the node.", + "type": "string" + }, + "classes": { + "description": "A list of class names for styling or semantics.", + "type": "array", + "items": { + "type": "string" + } + }, + "data": { + "description": "Arbitrary key-value data attached to the node.", + "type": "object", + "additionalProperties": true + }, + "children": { + "description": "The inline content to emphasize.", + "type": "array", + "items": { + "$ref": "#/definitions/Inline" + } + } + }, + "required": ["type", "children"] + }, "Heading": { "title": "Heading", "description": "A heading with a level and inline content.", @@ -112,6 +147,9 @@ { "$ref": "#/definitions/Text" }, + { + "$ref": "#/definitions/Emphasis" + }, { "$ref": "#/definitions/Strong" }