Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,28 @@ interface Strikethrough extends Parent {

**Strikethrough** represents a piece of text that has been stricken.

### `Subscript`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: If I'm not mistaken the json schemas will need to be updated.
For context, the C&M team will allow publishing of content tree next year and those schemas will be our source of truth for validation.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JSON schemas get automatically generated as part of the build step

I think what's missing (and why the JSON schemas haven't been updated yet) is that the new types need to be included as things that can be "Phrasing" - https://github.com/Financial-Times/content-tree/pull/57/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R130

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just added Subscript and Superscript to the Phrasing types, and re-built the schema 👍


```ts
interface Subscript extends Parent {
type: "subscript"
children: Phrasing[]
}
```

**Subscript** represents a piece of text that has a lowered baseline.

### `Superscript`

```ts
interface Superscript extends Parent {
type: "superscript"
children: Phrasing[]
}
```

**Superscript** represents a piece of text with a raised baseline.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☝️ Add support for new subscript (<sub>) and superscript (<sup>) formatted text to Content Tree.

### `Link`

```ts
Expand Down
32 changes: 32 additions & 0 deletions content-tree.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ export declare namespace ContentTree {
type: "strikethrough";
children: Phrasing[];
}
interface Subscript extends Parent {
type: "subscript";
children: Phrasing[];
}
interface Superscript extends Parent {
type: "superscript";
children: Phrasing[];
}
interface Link extends Parent {
type: "link";
url: string;
Expand Down Expand Up @@ -322,6 +330,14 @@ export declare namespace ContentTree {
type: "strikethrough";
children: Phrasing[];
}
interface Subscript extends Parent {
type: "subscript";
children: Phrasing[];
}
interface Superscript extends Parent {
type: "superscript";
children: Phrasing[];
}
interface Link extends Parent {
type: "link";
url: string;
Expand Down Expand Up @@ -596,6 +612,14 @@ export declare namespace ContentTree {
type: "strikethrough";
children: Phrasing[];
}
interface Subscript extends Parent {
type: "subscript";
children: Phrasing[];
}
interface Superscript extends Parent {
type: "superscript";
children: Phrasing[];
}
interface Link extends Parent {
type: "link";
url: string;
Expand Down Expand Up @@ -857,6 +881,14 @@ export declare namespace ContentTree {
type: "strikethrough";
children: Phrasing[];
}
interface Subscript extends Parent {
type: "subscript";
children: Phrasing[];
}
interface Superscript extends Parent {
type: "superscript";
children: Phrasing[];
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☝️ All changes in this file are autogenerated from changes to README.md.

interface Link extends Parent {
type: "link";
url: string;
Expand Down
16 changes: 16 additions & 0 deletions libraries/from-bodyxml/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,22 @@ export let defaultTransformers = {
type: "strikethrough",
}
},
/**
* @type {Transformer<ContentTree.transit.Subscript>}
*/
sub(sub) {
return {
type: "subscript",
}
},
/**
* @type {Transformer<ContentTree.transit.Superscript>}
*/
sup(sup) {
return {
type: "superscript",
}
},
/**
* @type {Transformer<ContentTree.transit.Break>}
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/bodyxml-to-content-tree/input/kitchen-snippet.xml

Large diffs are not rendered by default.

32 changes: 27 additions & 5 deletions tests/bodyxml-to-content-tree/output/kitchen-snippet.json
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,16 @@
},
{
"type": "text",
"value": " is a graduate, but he is working in a manual occupation. It dealt with social alienation, the claustrophobia and frustrations of a provincial life on low incomes.[citation needed]"
"value": " is a graduate, but he is working in a manual occupation. It dealt with social alienation, the claustrophobia and frustrations of a provincial life on low incomes."
},
{
"type": "superscript",
"children": [
{
"type": "text",
"value": "[citation needed]"
}
]
}
]
},
Expand All @@ -645,10 +654,23 @@
"children": [
{
"type": "text",
"value": "The impact of this work inspired Arnold Wesker and Shelagh Delaney, among numerous others, to write plays of their own.[citation needed] The English Stage Company at the Royal Court Theatre, headed by George Devine and Theatre Workshop organised by Joan Littlewood were particularly prominent in bringing these plays to public attention. Critic John Heilpern wrote that Look Back in Anger expressed such “immensity of feeling and class hatred” that it altered the course of English theatre. The term “Angry theatre” was coined by critic John Russell Taylor."
}
]
},
"value": "The impact of this work inspired Arnold Wesker and Shelagh Delaney, among numerous others, to write plays of their own."
},
{
"type": "superscript",
"children": [
{
"type": "text",
"value": "[citation needed]"
}
]
},
{
"type": "text",
"value": " The English Stage Company at the Royal Court Theatre, headed by George Devine and Theatre Workshop organised by Joan Littlewood were particularly prominent in bringing these plays to public attention. Critic John Heilpern wrote that Look Back in Anger expressed such “immensity of feeling and class hatred” that it altered the course of English theatre. The term “Angry theatre” was coined by critic John Russell Taylor."
}
]
},
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☝️ Add some test data for superscript text. 👇

{
"type": "image-set",
"id": "52b9ebb3-24db-4768-8894-77f200702bb0"
Expand Down
32 changes: 27 additions & 5 deletions tests/content-tree-to-string/input/kitchen-snippet-full.json
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,16 @@
},
{
"type": "text",
"value": " is a graduate, but he is working in a manual occupation. It dealt with social alienation, the claustrophobia and frustrations of a provincial life on low incomes.[citation needed]"
"value": " is a graduate, but he is working in a manual occupation. It dealt with social alienation, the claustrophobia and frustrations of a provincial life on low incomes."
},
{
"type": "superscript",
"children": [
{
"type": "text",
"value": "[citation needed]"
}
]
}
]
},
Expand All @@ -685,10 +694,23 @@
"children": [
{
"type": "text",
"value": "The impact of this work inspired Arnold Wesker and Shelagh Delaney, among numerous others, to write plays of their own.[citation needed] The English Stage Company at the Royal Court Theatre, headed by George Devine and Theatre Workshop organised by Joan Littlewood were particularly prominent in bringing these plays to public attention. Critic John Heilpern wrote that Look Back in Anger expressed such “immensity of feeling and class hatred” that it altered the course of English theatre. The term “Angry theatre” was coined by critic John Russell Taylor."
}
]
},
"value": "The impact of this work inspired Arnold Wesker and Shelagh Delaney, among numerous others, to write plays of their own."
},
{
"type": "superscript",
"children": [
{
"type": "text",
"value": "[citation needed]"
}
]
},
{
"type": "text",
"value": " The English Stage Company at the Royal Court Theatre, headed by George Devine and Theatre Workshop organised by Joan Littlewood were particularly prominent in bringing these plays to public attention. Critic John Heilpern wrote that Look Back in Anger expressed such “immensity of feeling and class hatred” that it altered the course of English theatre. The term “Angry theatre” was coined by critic John Russell Taylor."
}
]
},
{
"type": "image-set",
"id": "52b9ebb3-24db-4768-8894-77f200702bb0",
Expand Down
32 changes: 27 additions & 5 deletions tests/content-tree-to-string/input/kitchen-snippet-transit.json
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,16 @@
},
{
"type": "text",
"value": " is a graduate, but he is working in a manual occupation. It dealt with social alienation, the claustrophobia and frustrations of a provincial life on low incomes.[citation needed]"
"value": " is a graduate, but he is working in a manual occupation. It dealt with social alienation, the claustrophobia and frustrations of a provincial life on low incomes."
},
{
"type": "superscript",
"children": [
{
"type": "text",
"value": "[citation needed]"
}
]
}
]
},
Expand All @@ -645,10 +654,23 @@
"children": [
{
"type": "text",
"value": "The impact of this work inspired Arnold Wesker and Shelagh Delaney, among numerous others, to write plays of their own.[citation needed] The English Stage Company at the Royal Court Theatre, headed by George Devine and Theatre Workshop organised by Joan Littlewood were particularly prominent in bringing these plays to public attention. Critic John Heilpern wrote that Look Back in Anger expressed such “immensity of feeling and class hatred” that it altered the course of English theatre. The term “Angry theatre” was coined by critic John Russell Taylor."
}
]
},
"value": "The impact of this work inspired Arnold Wesker and Shelagh Delaney, among numerous others, to write plays of their own."
},
{
"type": "superscript",
"children": [
{
"type": "text",
"value": "[citation needed]"
}
]
},
{
"type": "text",
"value": " The English Stage Company at the Royal Court Theatre, headed by George Devine and Theatre Workshop organised by Joan Littlewood were particularly prominent in bringing these plays to public attention. Critic John Heilpern wrote that Look Back in Anger expressed such “immensity of feeling and class hatred” that it altered the course of English theatre. The term “Angry theatre” was coined by critic John Russell Taylor."
}
]
},
{
"type": "image-set",
"id": "52b9ebb3-24db-4768-8894-77f200702bb0"
Expand Down
Loading