@hozo/typography 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +1 -1
  3. package/dist/code/meta.d.ts +14 -0
  4. package/dist/code/meta.d.ts.map +1 -0
  5. package/dist/code/meta.js +62 -0
  6. package/dist/code/meta.js.map +1 -0
  7. package/dist/code/model.d.ts +66 -0
  8. package/dist/code/model.d.ts.map +1 -0
  9. package/dist/code/model.js +139 -0
  10. package/dist/code/model.js.map +1 -0
  11. package/dist/code/reuse.d.ts +22 -0
  12. package/dist/code/reuse.d.ts.map +1 -0
  13. package/dist/code/reuse.js +54 -0
  14. package/dist/code/reuse.js.map +1 -0
  15. package/dist/code/shiki.d.ts +12 -0
  16. package/dist/code/shiki.d.ts.map +1 -0
  17. package/dist/code/shiki.js +28 -0
  18. package/dist/code/shiki.js.map +1 -0
  19. package/dist/code-lines.d.ts +34 -0
  20. package/dist/code-lines.d.ts.map +1 -0
  21. package/dist/code-lines.js +192 -0
  22. package/dist/code-lines.js.map +1 -0
  23. package/dist/code-lines.native.d.ts +54 -0
  24. package/dist/code-lines.native.d.ts.map +1 -0
  25. package/dist/code-lines.native.js +114 -0
  26. package/dist/code-lines.native.js.map +1 -0
  27. package/dist/index.d.ts +3 -41
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +3 -69
  30. package/dist/index.js.map +1 -1
  31. package/dist/index.native.d.ts +3 -82
  32. package/dist/index.native.d.ts.map +1 -1
  33. package/dist/index.native.js +3 -140
  34. package/dist/index.native.js.map +1 -1
  35. package/dist/text.d.ts +43 -0
  36. package/dist/text.d.ts.map +1 -0
  37. package/dist/text.js +75 -0
  38. package/dist/text.js.map +1 -0
  39. package/dist/text.native.d.ts +84 -0
  40. package/dist/text.native.d.ts.map +1 -0
  41. package/dist/text.native.js +144 -0
  42. package/dist/text.native.js.map +1 -0
  43. package/package.json +30 -4
  44. package/src/code/meta.ts +69 -0
  45. package/src/code/model.ts +189 -0
  46. package/src/code/reuse.ts +70 -0
  47. package/src/code/shiki.ts +38 -0
  48. package/src/code-lines.native.tsx +191 -0
  49. package/src/code-lines.tsx +310 -0
  50. package/src/index.native.tsx +4 -245
  51. package/src/index.tsx +4 -164
  52. package/src/text.native.tsx +250 -0
  53. package/src/text.tsx +179 -0
package/src/index.tsx CHANGED
@@ -1,165 +1,5 @@
1
- import { Link, type LinkProps, Text, type TextProps } from '@hozo/primitives'
2
- import type { CSSProperties, ReactNode } from 'react'
1
+ // Keep data-driven code rendering out of apps that only use semantic text.
3
2
 
4
- export { Link, type LinkProps, Text, type TextProps }
5
-
6
- export interface TypographyUniversalProps {
7
- className?: string
8
- children?: ReactNode
9
- style?: CSSProperties
10
- testID?: string
11
- nativeID?: string
12
- accessibilityLabel?: string
13
- accessibilityHint?: string
14
- 'aria-hidden'?: boolean
15
- }
16
-
17
- export type SemanticTextProps = TypographyUniversalProps
18
-
19
- export interface HeadingProps extends TypographyUniversalProps {
20
- level?: 1 | 2 | 3 | 4 | 5 | 6
21
- }
22
-
23
- function domProps(props: Omit<TypographyUniversalProps, 'style' | 'className' | 'children'>) {
24
- return {
25
- 'data-testid': props.testID,
26
- id: props.nativeID,
27
- 'aria-label': props.accessibilityLabel,
28
- 'aria-description': props.accessibilityHint,
29
- 'aria-hidden': props['aria-hidden'],
30
- }
31
- }
32
-
33
- export function Paragraph({ className, children, style, ...props }: SemanticTextProps) {
34
- return (
35
- <p className={className} style={style} {...domProps(props)}>
36
- {children}
37
- </p>
38
- )
39
- }
40
-
41
- export function Heading({ level = 1, className, children, style, ...props }: HeadingProps) {
42
- const Tag = `h${Math.min(6, Math.max(1, level))}` as 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'
43
- return (
44
- <Tag className={className} style={style} {...domProps(props)}>
45
- {children}
46
- </Tag>
47
- )
48
- }
49
-
50
- export function Strong({ className, children, style, ...props }: TypographyUniversalProps) {
51
- return (
52
- <strong className={className} style={style} {...domProps(props)}>
53
- {children}
54
- </strong>
55
- )
56
- }
57
-
58
- export function Emphasis({ className, children, style, ...props }: TypographyUniversalProps) {
59
- return (
60
- <em className={className} style={style} {...domProps(props)}>
61
- {children}
62
- </em>
63
- )
64
- }
65
-
66
- export function Underline({ className, children, style, ...props }: TypographyUniversalProps) {
67
- return (
68
- <u className={className} style={style} {...domProps(props)}>
69
- {children}
70
- </u>
71
- )
72
- }
73
-
74
- export function Strikethrough({ className, children, style, ...props }: TypographyUniversalProps) {
75
- return (
76
- <s className={className} style={style} {...domProps(props)}>
77
- {children}
78
- </s>
79
- )
80
- }
81
-
82
- export const Del = Strikethrough
83
-
84
- export function Sub({ className, children, style, ...props }: TypographyUniversalProps) {
85
- return (
86
- <sub className={className} style={style} {...domProps(props)}>
87
- {children}
88
- </sub>
89
- )
90
- }
91
-
92
- export function Sup({ className, children, style, ...props }: TypographyUniversalProps) {
93
- return (
94
- <sup className={className} style={style} {...domProps(props)}>
95
- {children}
96
- </sup>
97
- )
98
- }
99
-
100
- export function Code({ className, children, style, ...props }: TypographyUniversalProps) {
101
- return (
102
- <code className={className} style={style} {...domProps(props)}>
103
- {children}
104
- </code>
105
- )
106
- }
107
-
108
- /**
109
- * A block whose spaces and line breaks are the content, a code sample above
110
- * all. Holds phrasing content -- put a `Code` inside for code, as `<pre><code>`
111
- * is written by hand.
112
- */
113
- export function Preformatted({ className, children, style, ...props }: TypographyUniversalProps) {
114
- return (
115
- <pre className={className} style={style} {...domProps(props)}>
116
- {children}
117
- </pre>
118
- )
119
- }
120
-
121
- export function Small({ className, children, style, ...props }: TypographyUniversalProps) {
122
- return (
123
- <small className={className} style={style} {...domProps(props)}>
124
- {children}
125
- </small>
126
- )
127
- }
128
-
129
- export function Mark({ className, children, style, ...props }: TypographyUniversalProps) {
130
- return (
131
- <mark className={className} style={style} {...domProps(props)}>
132
- {children}
133
- </mark>
134
- )
135
- }
136
-
137
- export function NoBreak({ className, children, style, ...props }: TypographyUniversalProps) {
138
- return (
139
- <span className={className} style={{ whiteSpace: 'nowrap', ...style }} {...domProps(props)}>
140
- {children}
141
- </span>
142
- )
143
- }
144
-
145
- export function Ruby({ className, children, style, ...props }: TypographyUniversalProps) {
146
- return (
147
- <ruby className={className} style={style} {...domProps(props)}>
148
- {children}
149
- </ruby>
150
- )
151
- }
152
-
153
- export function RubyText({ className, children, style, ...props }: TypographyUniversalProps) {
154
- return (
155
- <rt className={className} style={style} {...domProps(props)}>
156
- {children}
157
- </rt>
158
- )
159
- }
160
-
161
- // Both spellings, the way `TermList` reads both. The member keeps the
162
- // full name rather than shortening to `Text`: a flat export has to be
163
- // readable on its own, and a `<Text>` that meant the annotation would
164
- // not be. The compiler recognises the pair in `hozo_parser`.
165
- Ruby.RubyText = RubyText
3
+ export type { CodeLine, CodeMark, CodeRange, CodeToken } from './code/model.ts'
4
+ export { CodeLines, type CodeLinesProps } from './code-lines.tsx'
5
+ export * from './text.tsx'
@@ -0,0 +1,250 @@
1
+ import { HozoTextSizeContext } from '@hozo/engine'
2
+ import { hozoPreflight } from '@hozo/engine/project'
3
+ import { Link, Text } from '@hozo/primitives'
4
+ import React, { type ComponentProps, type ReactNode, useContext } from 'react'
5
+ // The components rather than their names. These files used to render
6
+ // `React.createElement('View')`, and React Native resolves a string tag
7
+ // through its view config registry, where the registered names are
8
+ // `RCTView` and `RCTText` -- never `View` or `Text`. Every one of these
9
+ // would have thrown "View config getter callback for component `View`
10
+ // must be a function" on the first render. Nothing caught it because
11
+ // nothing imported these files: the tests next to them render the Web
12
+ // half through `react-dom/server`.
13
+ import type { AccessibilityRole, StyleProp, TextStyle } from 'react-native'
14
+ import { HozoRuby, HozoRubyText } from './ruby.native.tsx'
15
+ import { BARE_TEXT_SIZE_RATIOS, TEXT_SIZE_RATIOS } from './text-size.ts'
16
+
17
+ export { BARE_TEXT_SIZE_RATIOS, TEXT_SIZE_RATIOS } from './text-size.ts'
18
+ export { Link, Text }
19
+
20
+ export interface TypographyNativeProps {
21
+ /**
22
+ * Tailwind classes, read by the compiler and gone by runtime.
23
+ *
24
+ * The Web half of this file has always declared it; this half never
25
+ * did, and nothing noticed because the `react-native` export condition
26
+ * carried no `types`, so a React Native app was type-checked against
27
+ * the Web declarations instead. Uncompiled, the prop is simply ignored
28
+ * here -- which is what the fallback components are for.
29
+ */
30
+ className?: string
31
+ children?: ReactNode
32
+ /**
33
+ * React Native's own types rather than `any` and `string`.
34
+ *
35
+ * The Web half of this file says `CSSProperties`. This half agreed with
36
+ * anything, so a Web-only style reached a native `Text` in silence --
37
+ * the same erasure `@hozo/tailwind-conformance` exists to catch one
38
+ * layer down.
39
+ */
40
+ style?: StyleProp<TextStyle>
41
+ testID?: string
42
+ nativeID?: string
43
+ accessibilityLabel?: string
44
+ accessibilityHint?: string
45
+ accessibilityRole?: AccessibilityRole
46
+ accessible?: boolean
47
+ numberOfLines?: number
48
+ ellipsizeMode?: 'head' | 'middle' | 'tail' | 'clip'
49
+ }
50
+
51
+ // The public concept keeps one name across platform entry points even
52
+ // though its style field uses React Native's own type here.
53
+ export type TypographyUniversalProps = TypographyNativeProps
54
+
55
+ export type TextProps = TypographyNativeProps
56
+ export type SemanticTextProps = TypographyNativeProps
57
+
58
+ export interface HeadingProps extends TypographyNativeProps {
59
+ level?: 1 | 2 | 3 | 4 | 5 | 6
60
+ }
61
+
62
+ /** Native declaration for the Link value re-exported from primitives. */
63
+ export interface LinkProps extends TypographyNativeProps {
64
+ href: string
65
+ external?: boolean
66
+ replace?: boolean
67
+ prefetch?: boolean
68
+ target?: string
69
+ rel?: string
70
+ download?: boolean | string
71
+ onPress?: (event: { defaultPrevented?: boolean }) => void
72
+ }
73
+
74
+ /**
75
+ * The size the text around this is drawn at.
76
+ *
77
+ * `@hozo/engine`'s, not one of this package's own. The compiler emits
78
+ * `HozoTextSize` for an element whose size it could not read, and that
79
+ * publishes into this context -- so a compiled ancestor and one of the
80
+ * components below, rendered uncompiled, agree about the base. Two
81
+ * contexts would have been two answers.
82
+ *
83
+ * React Native offers nothing to build this on. Its `fontSize` is a
84
+ * number of points with no relative unit, a nested `Text` inherits
85
+ * visually but cannot read what it inherited, and the only ancestor
86
+ * context the platform exposes -- `TextAncestorContext` -- is a boolean
87
+ * saying whether there is a `Text` above at all.
88
+ *
89
+ * The default is React Native's own, and the constants this replaced --
90
+ * 11, 11, 12 -- are exactly the ratios applied to it.
91
+ */
92
+ const TextSize = HozoTextSizeContext
93
+ const NativeText = Text as unknown as React.ComponentType<TypographyNativeProps>
94
+
95
+ function relative(ratio: number, base: number) {
96
+ return Math.round(base * ratio)
97
+ }
98
+
99
+ export function Paragraph(props: SemanticTextProps) {
100
+ return <NativeText {...props} />
101
+ }
102
+
103
+ export function Heading({
104
+ level = 1,
105
+ accessibilityRole = 'header',
106
+ style,
107
+ ...props
108
+ }: HeadingProps) {
109
+ // Preflight resets headings to inherited size and weight. Without it,
110
+ // reproduce the browser's heading defaults that Native does not have.
111
+ const base = useContext(TextSize)
112
+ const ratio = BARE_TEXT_SIZE_RATIOS.heading[Math.min(6, Math.max(1, level)) - 1] as number
113
+ const defaultStyle = hozoPreflight
114
+ ? undefined
115
+ : { fontSize: relative(ratio, base), fontWeight: 'bold' as const }
116
+ return (
117
+ <NativeText accessibilityRole={accessibilityRole} style={[defaultStyle, style]} {...props} />
118
+ )
119
+ }
120
+
121
+ export function Strong({ style, ...props }: TypographyNativeProps) {
122
+ return <NativeText style={[{ fontWeight: 'bold' }, style]} {...props} />
123
+ }
124
+
125
+ export function Emphasis({ style, ...props }: TypographyNativeProps) {
126
+ return <NativeText style={[{ fontStyle: 'italic' }, style]} {...props} />
127
+ }
128
+
129
+ export function Underline({ style, ...props }: TypographyNativeProps) {
130
+ return <NativeText style={[{ textDecorationLine: 'underline' }, style]} {...props} />
131
+ }
132
+
133
+ export function Strikethrough({ style, ...props }: TypographyNativeProps) {
134
+ return <NativeText style={[{ textDecorationLine: 'line-through' }, style]} {...props} />
135
+ }
136
+
137
+ export function Ins({ style, ...props }: TypographyNativeProps) {
138
+ return <NativeText style={[{ textDecorationLine: 'underline' }, style]} {...props} />
139
+ }
140
+
141
+ export const Del = Strikethrough
142
+
143
+ export function Sub({ style, ...props }: TypographyNativeProps) {
144
+ const base = useContext(TextSize)
145
+ const ratios = hozoPreflight ? TEXT_SIZE_RATIOS : BARE_TEXT_SIZE_RATIOS
146
+ return <NativeText style={[{ fontSize: relative(ratios.sub, base) }, style]} {...props} />
147
+ }
148
+
149
+ export function Sup({ style, ...props }: TypographyNativeProps) {
150
+ const base = useContext(TextSize)
151
+ const ratios = hozoPreflight ? TEXT_SIZE_RATIOS : BARE_TEXT_SIZE_RATIOS
152
+ return <NativeText style={[{ fontSize: relative(ratios.sup, base) }, style]} {...props} />
153
+ }
154
+
155
+ export function Code({ style, ...props }: TypographyNativeProps) {
156
+ return <NativeText style={[{ fontFamily: 'monospace' }, style]} {...props} />
157
+ }
158
+
159
+ // A `Text` keeps spaces and line breaks as written already; what `<pre>`
160
+ // adds on the Web that a `Text` lacks is the monospace face.
161
+ export function Preformatted({ style, ...props }: TypographyNativeProps) {
162
+ return <NativeText style={[{ fontFamily: 'monospace' }, style]} {...props} />
163
+ }
164
+
165
+ export function Small({ style, ...props }: TypographyNativeProps) {
166
+ const base = useContext(TextSize)
167
+ const ratios = hozoPreflight ? TEXT_SIZE_RATIOS : BARE_TEXT_SIZE_RATIOS
168
+ return (
169
+ <NativeText
170
+ style={[{ fontSize: relative(ratios.small, base), opacity: 0.8 }, style]}
171
+ {...props}
172
+ />
173
+ )
174
+ }
175
+
176
+ export function Mark({ style, ...props }: TypographyNativeProps) {
177
+ return <NativeText style={[{ backgroundColor: '#fef08a' }, style]} {...props} />
178
+ }
179
+
180
+ /** Recursively replaces normal spaces with Unicode non-breaking spaces (\u00A0) */
181
+ function replaceSpacesWithNbsp(node: ReactNode): ReactNode {
182
+ if (typeof node === 'string') {
183
+ return node.replace(/ /g, '\u00A0')
184
+ }
185
+ if (Array.isArray(node)) {
186
+ return React.Children.map(node, replaceSpacesWithNbsp)
187
+ }
188
+ if (React.isValidElement(node)) {
189
+ const element = node as React.ReactElement<{ children?: ReactNode }>
190
+ if (element.props?.children) {
191
+ return React.cloneElement(element, {
192
+ children: replaceSpacesWithNbsp(element.props.children),
193
+ })
194
+ }
195
+ }
196
+ return node
197
+ }
198
+
199
+ export function NoBreak({ children, ...props }: TypographyNativeProps) {
200
+ return <NativeText {...props}>{replaceSpacesWithNbsp(children)}</NativeText>
201
+ }
202
+
203
+ /**
204
+ * A Native style handed over as if it were a Web one -- a resolver's
205
+ * limit rather than a claim about the value.
206
+ *
207
+ * A package resolves `@hozo/engine`'s types through the Web entry
208
+ * whichever platform it is building for, because `exports` carries a
209
+ * single `types` and this package compiles both halves in one `tsc` run.
210
+ * So these are seen with `style?: CSSProperties` here while the module
211
+ * Metro loads takes `StyleProp<TextStyle>`. `@hozo/semantics` has the
212
+ * same line for the same reason.
213
+ */
214
+ const asWeb = (style: TypographyNativeProps['style']) =>
215
+ style as unknown as ComponentProps<typeof HozoRuby>['style']
216
+ /**
217
+ * Ruby, sharing the pair the Native backend emits.
218
+ *
219
+ * React Native flattens nested `Text` into one accessibility node, so a
220
+ * screen reader read the base and then the reading: 「漢字かんじ」. The
221
+ * `accessible={false}` that used to be on the annotation could not stop
222
+ * it -- the flattening happens above, and the parent's label is built
223
+ * from the text it contains whatever the children say about themselves.
224
+ */
225
+ export function Ruby({ children, accessibilityLabel, style, ...props }: TypographyNativeProps) {
226
+ return (
227
+ <HozoRuby accessibilityLabel={accessibilityLabel} style={asWeb(style)} {...props}>
228
+ {children}
229
+ </HozoRuby>
230
+ )
231
+ }
232
+
233
+ export function RubyText({ style, children, ...props }: TypographyNativeProps) {
234
+ // Half the size of the text it annotates, against the size `Text`
235
+ // published; `fontSize: '0.65em'` was here and React Native ignored it.
236
+ const base = useContext(TextSize)
237
+ return (
238
+ <HozoRubyText
239
+ style={asWeb([{ fontSize: relative(TEXT_SIZE_RATIOS.rubyText, base), opacity: 0.85 }, style])}
240
+ {...props}
241
+ >
242
+ {children}
243
+ </HozoRubyText>
244
+ )
245
+ }
246
+ // Both spellings, the way `TermList` reads both. The member keeps the
247
+ // full name rather than shortening to `Text`: a flat export has to be
248
+ // readable on its own, and a `<Text>` that meant the annotation would
249
+ // not be. The compiler recognises the pair in `hozo_parser`.
250
+ Ruby.RubyText = RubyText
package/src/text.tsx ADDED
@@ -0,0 +1,179 @@
1
+ import { Link, type LinkProps, Text, type TextProps } from '@hozo/primitives'
2
+ import type { CSSProperties, ReactNode } from 'react'
3
+
4
+ export { Link, type LinkProps, Text, type TextProps }
5
+
6
+ export interface TypographyUniversalProps {
7
+ className?: string
8
+ children?: ReactNode
9
+ style?: CSSProperties
10
+ testID?: string
11
+ nativeID?: string
12
+ accessibilityLabel?: string
13
+ accessibilityHint?: string
14
+ 'aria-hidden'?: boolean
15
+ }
16
+
17
+ export type SemanticTextProps = TypographyUniversalProps
18
+
19
+ export interface HeadingProps extends TypographyUniversalProps {
20
+ level?: 1 | 2 | 3 | 4 | 5 | 6
21
+ }
22
+
23
+ function domProps(props: Omit<TypographyUniversalProps, 'style' | 'className' | 'children'>) {
24
+ return {
25
+ 'data-testid': props.testID,
26
+ id: props.nativeID,
27
+ 'aria-label': props.accessibilityLabel,
28
+ 'aria-description': props.accessibilityHint,
29
+ 'aria-hidden': props['aria-hidden'],
30
+ }
31
+ }
32
+
33
+ export function Paragraph({ className, children, style, ...props }: SemanticTextProps) {
34
+ return (
35
+ <p className={className} style={style} {...domProps(props)}>
36
+ {children}
37
+ </p>
38
+ )
39
+ }
40
+
41
+ export function Heading({ level = 1, className, children, style, ...props }: HeadingProps) {
42
+ const Tag = `h${Math.min(6, Math.max(1, level))}` as 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'
43
+ return (
44
+ <Tag className={className} style={style} {...domProps(props)}>
45
+ {children}
46
+ </Tag>
47
+ )
48
+ }
49
+
50
+ export function Strong({ className, children, style, ...props }: TypographyUniversalProps) {
51
+ return (
52
+ <strong className={className} style={style} {...domProps(props)}>
53
+ {children}
54
+ </strong>
55
+ )
56
+ }
57
+
58
+ export function Emphasis({ className, children, style, ...props }: TypographyUniversalProps) {
59
+ return (
60
+ <em className={className} style={style} {...domProps(props)}>
61
+ {children}
62
+ </em>
63
+ )
64
+ }
65
+
66
+ export function Underline({ className, children, style, ...props }: TypographyUniversalProps) {
67
+ return (
68
+ <u className={className} style={style} {...domProps(props)}>
69
+ {children}
70
+ </u>
71
+ )
72
+ }
73
+
74
+ export function Strikethrough({ className, children, style, ...props }: TypographyUniversalProps) {
75
+ return (
76
+ <s className={className} style={style} {...domProps(props)}>
77
+ {children}
78
+ </s>
79
+ )
80
+ }
81
+
82
+ export function Ins({ className, children, style, ...props }: TypographyUniversalProps) {
83
+ return (
84
+ <ins className={className} style={style} {...domProps(props)}>
85
+ {children}
86
+ </ins>
87
+ )
88
+ }
89
+
90
+ export function Del({ className, children, style, ...props }: TypographyUniversalProps) {
91
+ return (
92
+ <del className={className} style={style} {...domProps(props)}>
93
+ {children}
94
+ </del>
95
+ )
96
+ }
97
+
98
+ export function Sub({ className, children, style, ...props }: TypographyUniversalProps) {
99
+ return (
100
+ <sub className={className} style={style} {...domProps(props)}>
101
+ {children}
102
+ </sub>
103
+ )
104
+ }
105
+
106
+ export function Sup({ className, children, style, ...props }: TypographyUniversalProps) {
107
+ return (
108
+ <sup className={className} style={style} {...domProps(props)}>
109
+ {children}
110
+ </sup>
111
+ )
112
+ }
113
+
114
+ export function Code({ className, children, style, ...props }: TypographyUniversalProps) {
115
+ return (
116
+ <code className={className} style={style} {...domProps(props)}>
117
+ {children}
118
+ </code>
119
+ )
120
+ }
121
+
122
+ /**
123
+ * A block whose spaces and line breaks are the content, a code sample above
124
+ * all. Holds phrasing content -- put a `Code` inside for code, as `<pre><code>`
125
+ * is written by hand.
126
+ */
127
+ export function Preformatted({ className, children, style, ...props }: TypographyUniversalProps) {
128
+ return (
129
+ <pre className={className} style={style} {...domProps(props)}>
130
+ {children}
131
+ </pre>
132
+ )
133
+ }
134
+
135
+ export function Small({ className, children, style, ...props }: TypographyUniversalProps) {
136
+ return (
137
+ <small className={className} style={style} {...domProps(props)}>
138
+ {children}
139
+ </small>
140
+ )
141
+ }
142
+
143
+ export function Mark({ className, children, style, ...props }: TypographyUniversalProps) {
144
+ return (
145
+ <mark className={className} style={style} {...domProps(props)}>
146
+ {children}
147
+ </mark>
148
+ )
149
+ }
150
+
151
+ export function NoBreak({ className, children, style, ...props }: TypographyUniversalProps) {
152
+ return (
153
+ <span className={className} style={{ whiteSpace: 'nowrap', ...style }} {...domProps(props)}>
154
+ {children}
155
+ </span>
156
+ )
157
+ }
158
+
159
+ export function Ruby({ className, children, style, ...props }: TypographyUniversalProps) {
160
+ return (
161
+ <ruby className={className} style={style} {...domProps(props)}>
162
+ {children}
163
+ </ruby>
164
+ )
165
+ }
166
+
167
+ export function RubyText({ className, children, style, ...props }: TypographyUniversalProps) {
168
+ return (
169
+ <rt className={className} style={style} {...domProps(props)}>
170
+ {children}
171
+ </rt>
172
+ )
173
+ }
174
+
175
+ // Both spellings, the way `TermList` reads both. The member keeps the
176
+ // full name rather than shortening to `Text`: a flat export has to be
177
+ // readable on its own, and a `<Text>` that meant the annotation would
178
+ // not be. The compiler recognises the pair in `hozo_parser`.
179
+ Ruby.RubyText = RubyText