Skip to content

Commit 528eee3

Browse files
authored
RND-548: add subscript and superscript support (#3110)
1 parent 168a4fa commit 528eee3

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

Diff for: .changeset/hungry-candles-sing.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"gitbook": patch
3+
---
4+
5+
Add superscript and subscript text rendering

Diff for: packages/gitbook/src/components/DocumentView/Text.tsx

+12-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import type {
55
DocumentMarkItalic,
66
DocumentMarkKeyboard,
77
DocumentMarkStrikethrough,
8+
DocumentMarkSubscript,
9+
DocumentMarkSuperscript,
810
DocumentText,
911
DocumentTextMark,
1012
} from '@gitbook/api';
@@ -47,10 +49,8 @@ const MARK_STYLES = {
4749
strikethrough: Strikethrough,
4850
color: Color,
4951
keyboard: Keyboard,
50-
51-
// TODO: add support for these marks
52-
subscript: null,
53-
superscript: null,
52+
superscript: Superscript,
53+
subscript: Subscript,
5454
};
5555

5656
interface MarkedLeafProps<Mark extends DocumentTextMark> {
@@ -78,6 +78,14 @@ function Keyboard(props: MarkedLeafProps<DocumentMarkKeyboard>) {
7878
);
7979
}
8080

81+
function Superscript(props: MarkedLeafProps<DocumentMarkSuperscript>) {
82+
return <sup>{props.children}</sup>;
83+
}
84+
85+
function Subscript(props: MarkedLeafProps<DocumentMarkSubscript>) {
86+
return <sub>{props.children}</sub>;
87+
}
88+
8189
function Code(props: MarkedLeafProps<DocumentMarkCode>) {
8290
return (
8391
<code

0 commit comments

Comments
 (0)