From eee14c8d504ff59bfa06c08f9e6eae75e5e07708 Mon Sep 17 00:00:00 2001 From: Arjun Gadhia Date: Wed, 29 Apr 2026 09:58:57 +0100 Subject: [PATCH 1/3] fix: allow headings in Card --- SPEC.md | 2 +- content-tree.d.ts | 8 ++++---- schemas/body-tree.schema.json | 3 +++ schemas/content-tree.schema.json | 3 +++ schemas/transit-tree.schema.json | 3 +++ 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/SPEC.md b/SPEC.md index 0dbe8ff..d35a5f5 100644 --- a/SPEC.md +++ b/SPEC.md @@ -961,7 +961,7 @@ interface InNumbers extends Parent { ```ts /** Allowed children for a card */ -type CardChildren = ImageSet | Exclude +type CardChildren = ImageSet | FormattingBlock /** * A card describes a subject with images and text */ diff --git a/content-tree.d.ts b/content-tree.d.ts index 986e984..27a2ed7 100644 --- a/content-tree.d.ts +++ b/content-tree.d.ts @@ -407,7 +407,7 @@ export declare namespace ContentTree { } /** Allowed children for a card */ - type CardChildren = ImageSet | Exclude; + type CardChildren = ImageSet | FormattingBlock; /** * A card describes a subject with images and text */ @@ -848,7 +848,7 @@ export declare namespace ContentTree { } /** Allowed children for a card */ - type CardChildren = ImageSet | Exclude; + type CardChildren = ImageSet | FormattingBlock; /** * A card describes a subject with images and text */ @@ -1263,7 +1263,7 @@ export declare namespace ContentTree { } /** Allowed children for a card */ - type CardChildren = ImageSet | Exclude; + type CardChildren = ImageSet | FormattingBlock; /** * A card describes a subject with images and text */ @@ -1705,7 +1705,7 @@ export declare namespace ContentTree { } /** Allowed children for a card */ - type CardChildren = ImageSet | Exclude; + type CardChildren = ImageSet | FormattingBlock; /** * A card describes a subject with images and text */ diff --git a/schemas/body-tree.schema.json b/schemas/body-tree.schema.json index 3c80752..4ed176d 100644 --- a/schemas/body-tree.schema.json +++ b/schemas/body-tree.schema.json @@ -228,6 +228,9 @@ { "$ref": "#/definitions/ContentTree.transit.Paragraph" }, + { + "$ref": "#/definitions/ContentTree.transit.Heading" + }, { "$ref": "#/definitions/ContentTree.transit.List" }, diff --git a/schemas/content-tree.schema.json b/schemas/content-tree.schema.json index 6263e05..8bd98ad 100644 --- a/schemas/content-tree.schema.json +++ b/schemas/content-tree.schema.json @@ -265,6 +265,9 @@ { "$ref": "#/definitions/ContentTree.full.Paragraph" }, + { + "$ref": "#/definitions/ContentTree.full.Heading" + }, { "$ref": "#/definitions/ContentTree.full.List" }, diff --git a/schemas/transit-tree.schema.json b/schemas/transit-tree.schema.json index a786c2a..8f35943 100644 --- a/schemas/transit-tree.schema.json +++ b/schemas/transit-tree.schema.json @@ -253,6 +253,9 @@ { "$ref": "#/definitions/ContentTree.transit.Paragraph" }, + { + "$ref": "#/definitions/ContentTree.transit.Heading" + }, { "$ref": "#/definitions/ContentTree.transit.List" }, From 48324164284ea7d677d3ae04f147f9a0a7d3923a Mon Sep 17 00:00:00 2001 From: Arjun Gadhia Date: Wed, 29 Apr 2026 10:23:14 +0100 Subject: [PATCH 2/3] Add go struct and tests for heading in infobox --- content_tree.go | 15 ++++++++++++++ .../input/simple-body-section-infobox.xml | 2 +- .../output/simple-body-section-infobox.json | 20 +++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/content_tree.go b/content_tree.go index 2f408a7..09fea04 100644 --- a/content_tree.go +++ b/content_tree.go @@ -3430,6 +3430,7 @@ type CardChild struct { *Blockquote *ThematicBreak *Text + *Heading *ImageSet } @@ -3449,6 +3450,8 @@ func (n *CardChild) GetEmbedded() Node { return n.ThematicBreak case n.Text != nil: return n.Text + case n.Heading != nil: + return n.Heading case n.ImageSet != nil: return n.ImageSet default: @@ -3468,6 +3471,8 @@ func (n *CardChild) GetChildren() []Node { return n.ThematicBreak.GetChildren() case n.Text != nil: return n.Text.GetChildren() + case n.Heading != nil: + return n.Heading.GetChildren() case n.ImageSet != nil: return n.ImageSet.GetChildren() default: @@ -3513,6 +3518,12 @@ func (n *CardChild) UnmarshalJSON(data []byte) error { return err } n.Text = &v + case HeadingType: + var v Heading + if err := json.Unmarshal(data, &v); err != nil { + return err + } + n.Heading = &v case ImageSetType: var v ImageSet if err := json.Unmarshal(data, &v); err != nil { @@ -3537,6 +3548,8 @@ func (n *CardChild) MarshalJSON() ([]byte, error) { return json.Marshal(n.ThematicBreak) case n.Text != nil: return json.Marshal(n.Text) + case n.Heading != nil: + return json.Marshal(n.Heading) case n.ImageSet != nil: return json.Marshal(n.ImageSet) default: @@ -3556,6 +3569,8 @@ func makeCardChild(n Node) (*CardChild, error) { return &CardChild{ThematicBreak: n.(*ThematicBreak)}, nil case TextType: return &CardChild{Text: n.(*Text)}, nil + case HeadingType: + return &CardChild{Heading: n.(*Heading)}, nil case ImageSetType: return &CardChild{ImageSet: n.(*ImageSet)}, nil default: diff --git a/tests/bodyxml-to-content-tree/input/simple-body-section-infobox.xml b/tests/bodyxml-to-content-tree/input/simple-body-section-infobox.xml index 4d2127f..bd71738 100644 --- a/tests/bodyxml-to-content-tree/input/simple-body-section-infobox.xml +++ b/tests/bodyxml-to-content-tree/input/simple-body-section-infobox.xml @@ -1 +1 @@ -

Title

paragraph

  • para inside list

para inside blockquote

text
+

Title

paragraph

  • para inside list

para inside blockquote

text

Heading (subheading)

Heading (label)

diff --git a/tests/bodyxml-to-content-tree/output/simple-body-section-infobox.json b/tests/bodyxml-to-content-tree/output/simple-body-section-infobox.json index c827a48..aeb7fb2 100644 --- a/tests/bodyxml-to-content-tree/output/simple-body-section-infobox.json +++ b/tests/bodyxml-to-content-tree/output/simple-body-section-infobox.json @@ -61,6 +61,26 @@ { "type":"thematic-break" }, + { + "type": "heading", + "children":[ + { + "type": "text", + "value": "Heading (subheading)" + } + ], + "level": "subheading" + }, + { + "type": "heading", + "children":[ + { + "type": "text", + "value": "Heading (label)" + } + ], + "level": "label" + }, { "type":"image-set", "id":"23925844-4d8d-11ea-0bc6-d44b54b3bebc" From 38b05289418c9cd3d8c9b8863eb0c9b3b55fbf88 Mon Sep 17 00:00:00 2001 From: Arjun Gadhia Date: Wed, 29 Apr 2026 10:28:02 +0100 Subject: [PATCH 3/3] Bump version to 0.12.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ddee959..761e7ed 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@financial-times/content-tree", "description": "content tree format", - "version": "0.11.0", + "version": "0.12.0", "publishConfig": { "access": "public" },