Skip to content

Commit fd3c12d

Browse files
author
Katie Fenn
committed
Add support for subscript and superscript
- The Spark team are working on a piece of work to add support to subscript and superscript to Spark - This commit contains changes to Content Tree to add support for subscript and superscript text, via the <sup> and <sub> tags
1 parent 056af70 commit fd3c12d

File tree

7 files changed

+152
-16
lines changed

7 files changed

+152
-16
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,28 @@ interface Strikethrough extends Parent {
283283

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

286+
### `Subscript`
287+
288+
```ts
289+
interface Subscript extends Parent {
290+
type: "subscript"
291+
children: Phrasing[]
292+
}
293+
```
294+
295+
**Subscript** represents a piece of text that has a lowered baseline.
296+
297+
### `Superscript`
298+
299+
```ts
300+
interface Superscript extends Parent {
301+
type: "superscript"
302+
children: Phrasing[]
303+
}
304+
```
305+
306+
**Superscript** represents a piece of text with a raised baseline.
307+
286308
### `Link`
287309

288310
```ts

content-tree.d.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ export declare namespace ContentTree {
4949
type: "strikethrough";
5050
children: Phrasing[];
5151
}
52+
interface Subscript extends Parent {
53+
type: "subscript";
54+
children: Phrasing[];
55+
}
56+
interface Superscript extends Parent {
57+
type: "superscript";
58+
children: Phrasing[];
59+
}
5260
interface Link extends Parent {
5361
type: "link";
5462
url: string;
@@ -322,6 +330,14 @@ export declare namespace ContentTree {
322330
type: "strikethrough";
323331
children: Phrasing[];
324332
}
333+
interface Subscript extends Parent {
334+
type: "subscript";
335+
children: Phrasing[];
336+
}
337+
interface Superscript extends Parent {
338+
type: "superscript";
339+
children: Phrasing[];
340+
}
325341
interface Link extends Parent {
326342
type: "link";
327343
url: string;
@@ -596,6 +612,14 @@ export declare namespace ContentTree {
596612
type: "strikethrough";
597613
children: Phrasing[];
598614
}
615+
interface Subscript extends Parent {
616+
type: "subscript";
617+
children: Phrasing[];
618+
}
619+
interface Superscript extends Parent {
620+
type: "superscript";
621+
children: Phrasing[];
622+
}
599623
interface Link extends Parent {
600624
type: "link";
601625
url: string;
@@ -857,6 +881,14 @@ export declare namespace ContentTree {
857881
type: "strikethrough";
858882
children: Phrasing[];
859883
}
884+
interface Subscript extends Parent {
885+
type: "subscript";
886+
children: Phrasing[];
887+
}
888+
interface Superscript extends Parent {
889+
type: "superscript";
890+
children: Phrasing[];
891+
}
860892
interface Link extends Parent {
861893
type: "link";
862894
url: string;

libraries/from-bodyxml/index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,22 @@ export let defaultTransformers = {
8888
type: "strikethrough",
8989
}
9090
},
91+
/**
92+
* @type {Transformer<ContentTree.transit.Subscript>}
93+
*/
94+
sub(sub) {
95+
return {
96+
type: "subscript",
97+
}
98+
},
99+
/**
100+
* @type {Transformer<ContentTree.transit.Superscript>}
101+
*/
102+
sup(sup) {
103+
return {
104+
type: "superscript",
105+
}
106+
},
91107
/**
92108
* @type {Transformer<ContentTree.transit.Break>}
93109
*/

tests/bodyxml-to-content-tree/input/kitchen-snippet.xml

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

tests/bodyxml-to-content-tree/output/kitchen-snippet.json

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,16 @@
632632
},
633633
{
634634
"type": "text",
635-
"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]"
635+
"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."
636+
},
637+
{
638+
"type": "superscript",
639+
"children": [
640+
{
641+
"type": "text",
642+
"value": "[citation needed]"
643+
}
644+
]
636645
}
637646
]
638647
},
@@ -645,10 +654,23 @@
645654
"children": [
646655
{
647656
"type": "text",
648-
"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."
649-
}
650-
]
651-
},
657+
"value": "The impact of this work inspired Arnold Wesker and Shelagh Delaney, among numerous others, to write plays of their own."
658+
},
659+
{
660+
"type": "superscript",
661+
"children": [
662+
{
663+
"type": "text",
664+
"value": "[citation needed]"
665+
}
666+
]
667+
},
668+
{
669+
"type": "text",
670+
"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."
671+
}
672+
]
673+
},
652674
{
653675
"type": "image-set",
654676
"id": "52b9ebb3-24db-4768-8894-77f200702bb0"

tests/content-tree-to-string/input/kitchen-snippet-full.json

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,16 @@
672672
},
673673
{
674674
"type": "text",
675-
"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]"
675+
"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."
676+
},
677+
{
678+
"type": "superscript",
679+
"children": [
680+
{
681+
"type": "text",
682+
"value": "[citation needed]"
683+
}
684+
]
676685
}
677686
]
678687
},
@@ -685,10 +694,23 @@
685694
"children": [
686695
{
687696
"type": "text",
688-
"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."
689-
}
690-
]
691-
},
697+
"value": "The impact of this work inspired Arnold Wesker and Shelagh Delaney, among numerous others, to write plays of their own."
698+
},
699+
{
700+
"type": "superscript",
701+
"children": [
702+
{
703+
"type": "text",
704+
"value": "[citation needed]"
705+
}
706+
]
707+
},
708+
{
709+
"type": "text",
710+
"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."
711+
}
712+
]
713+
},
692714
{
693715
"type": "image-set",
694716
"id": "52b9ebb3-24db-4768-8894-77f200702bb0",

tests/content-tree-to-string/input/kitchen-snippet-transit.json

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,16 @@
632632
},
633633
{
634634
"type": "text",
635-
"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]"
635+
"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."
636+
},
637+
{
638+
"type": "superscript",
639+
"children": [
640+
{
641+
"type": "text",
642+
"value": "[citation needed]"
643+
}
644+
]
636645
}
637646
]
638647
},
@@ -645,10 +654,23 @@
645654
"children": [
646655
{
647656
"type": "text",
648-
"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."
649-
}
650-
]
651-
},
657+
"value": "The impact of this work inspired Arnold Wesker and Shelagh Delaney, among numerous others, to write plays of their own."
658+
},
659+
{
660+
"type": "superscript",
661+
"children": [
662+
{
663+
"type": "text",
664+
"value": "[citation needed]"
665+
}
666+
]
667+
},
668+
{
669+
"type": "text",
670+
"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."
671+
}
672+
]
673+
},
652674
{
653675
"type": "image-set",
654676
"id": "52b9ebb3-24db-4768-8894-77f200702bb0"

0 commit comments

Comments
 (0)