Skip to content

Commit 20c7a0b

Browse files
committed
refactor: rename content to children
1 parent c20733a commit 20c7a0b

File tree

1 file changed

+45
-43
lines changed

1 file changed

+45
-43
lines changed

index.tsx

+45-43
Original file line numberDiff line numberDiff line change
@@ -902,14 +902,14 @@ function unescapeUrl(rawUrlString: string): string {
902902
*/
903903
function parseInline(
904904
parse: MarkdownToJSX.NestedParser,
905-
content: string,
905+
children: string,
906906
state: MarkdownToJSX.State
907907
): MarkdownToJSX.ParserResult[] {
908908
const isCurrentlyInline = state.inline || false
909909
const isCurrentlySimple = state.simple || false
910910
state.inline = true
911911
state.simple = true
912-
const result = parse(content, state)
912+
const result = parse(children, state)
913913
state.inline = isCurrentlyInline
914914
state.simple = isCurrentlySimple
915915
return result
@@ -920,33 +920,33 @@ function parseInline(
920920
*/
921921
function parseSimpleInline(
922922
parse: MarkdownToJSX.NestedParser,
923-
content: string,
923+
children: string,
924924
state: MarkdownToJSX.State
925925
): MarkdownToJSX.ParserResult[] {
926926
const isCurrentlyInline = state.inline || false
927927
const isCurrentlySimple = state.simple || false
928928
state.inline = false
929929
state.simple = true
930-
const result = parse(content, state)
930+
const result = parse(children, state)
931931
state.inline = isCurrentlyInline
932932
state.simple = isCurrentlySimple
933933
return result
934934
}
935935

936936
function parseBlock(
937937
parse,
938-
content,
938+
children,
939939
state: MarkdownToJSX.State
940940
): MarkdownToJSX.ParserResult[] {
941941
state.inline = false
942-
return parse(content, state)
942+
return parse(children, state)
943943
}
944944

945945
const parseCaptureInline: MarkdownToJSX.Parser<{
946-
content: MarkdownToJSX.ParserResult[]
946+
children: MarkdownToJSX.ParserResult[]
947947
}> = (capture, parse, state: MarkdownToJSX.State) => {
948948
return {
949-
content: parseInline(parse, capture[1], state),
949+
children: parseInline(parse, capture[1], state),
950950
}
951951
}
952952

@@ -1205,15 +1205,17 @@ export function compiler(
12051205
order: Priority.HIGH,
12061206
parse(capture, parse, state) {
12071207
return {
1208-
content: parse(
1208+
children: parse(
12091209
capture[0].replace(BLOCKQUOTE_TRIM_LEFT_MULTILINE_R, ''),
12101210
state
12111211
),
12121212
}
12131213
},
12141214
render(node, output, state) {
12151215
return (
1216-
<blockquote key={state.key}>{output(node.content, state)}</blockquote>
1216+
<blockquote key={state.key}>
1217+
{output(node.children, state)}
1218+
</blockquote>
12171219
)
12181220
},
12191221
},
@@ -1353,7 +1355,7 @@ export function compiler(
13531355
order: Priority.HIGH,
13541356
parse(capture, parse, state) {
13551357
return {
1356-
content: parseInline(parse, capture[2], state),
1358+
children: parseInline(parse, capture[2], state),
13571359
id: options.slugify(capture[2]),
13581360
level: capture[1].length as MarkdownToJSX.HeadingNode['level'],
13591361
}
@@ -1362,7 +1364,7 @@ export function compiler(
13621364
return h(
13631365
`h${node.level}`,
13641366
{ id: node.id, key: state.key },
1365-
output(node.content, state)
1367+
output(node.children, state)
13661368
)
13671369
},
13681370
},
@@ -1372,7 +1374,7 @@ export function compiler(
13721374
order: Priority.MAX,
13731375
parse(capture, parse, state) {
13741376
return {
1375-
content: parseInline(parse, capture[1], state),
1377+
children: parseInline(parse, capture[1], state),
13761378
level: capture[2] === '=' ? 1 : 2,
13771379
type: RuleType.heading,
13781380
}
@@ -1404,7 +1406,7 @@ export function compiler(
14041406
tag: noInnerParse ? tagName : capture[1],
14051407
} as {
14061408
attrs: ReturnType<typeof attrStringToMap>
1407-
content?: ReturnType<MarkdownToJSX.NestedParser> | undefined
1409+
children?: ReturnType<MarkdownToJSX.NestedParser> | undefined
14081410
noInnerParse: Boolean
14091411
tag: MarkdownToJSX.HTMLTags
14101412
text?: string | undefined
@@ -1415,7 +1417,7 @@ export function compiler(
14151417
if (noInnerParse) {
14161418
ast.text = capture[3]
14171419
} else {
1418-
ast.content = parseFunc(parse, trimmed, state)
1420+
ast.children = parseFunc(parse, trimmed, state)
14191421
}
14201422

14211423
/**
@@ -1429,7 +1431,7 @@ export function compiler(
14291431
render(node, output, state) {
14301432
return (
14311433
<node.tag key={state.key} {...node.attrs}>
1432-
{node.text || output(node.content, state)}
1434+
{node.text || output(node.children, state)}
14331435
</node.tag>
14341436
)
14351437
},
@@ -1492,15 +1494,15 @@ export function compiler(
14921494
order: Priority.LOW,
14931495
parse(capture, parse, state) {
14941496
return {
1495-
content: parseSimpleInline(parse, capture[1], state),
1497+
children: parseSimpleInline(parse, capture[1], state),
14961498
target: unescapeUrl(capture[2]),
14971499
title: capture[3],
14981500
}
14991501
},
15001502
render(node, output, state) {
15011503
return (
15021504
<a key={state.key} href={sanitizeUrl(node.target)} title={node.title}>
1503-
{output(node.content, state)}
1505+
{output(node.children, state)}
15041506
</a>
15051507
)
15061508
},
@@ -1512,7 +1514,7 @@ export function compiler(
15121514
order: Priority.MAX,
15131515
parse(capture /*, parse, state*/) {
15141516
return {
1515-
content: [
1517+
children: [
15161518
{
15171519
text: capture[1],
15181520
type: RuleType.text,
@@ -1534,7 +1536,7 @@ export function compiler(
15341536
order: Priority.MAX,
15351537
parse(capture /*, parse, state*/) {
15361538
return {
1537-
content: [
1539+
children: [
15381540
{
15391541
text: capture[1],
15401542
type: RuleType.text,
@@ -1560,7 +1562,7 @@ export function compiler(
15601562
}
15611563

15621564
return {
1563-
content: [
1565+
children: [
15641566
{
15651567
text: address.replace('mailto:', ''),
15661568
type: RuleType.text,
@@ -1596,7 +1598,7 @@ export function compiler(
15961598
order: Priority.LOW,
15971599
parse: parseCaptureInline,
15981600
render(node, output, state) {
1599-
return <p key={state.key}>{output(node.content, state)}</p>
1601+
return <p key={state.key}>{output(node.children, state)}</p>
16001602
},
16011603
} as MarkdownToJSX.Rule<ReturnType<typeof parseCaptureInline>>,
16021604

@@ -1640,8 +1642,8 @@ export function compiler(
16401642
order: Priority.MAX,
16411643
parse(capture, parse, state) {
16421644
return {
1643-
content: parse(capture[1], state),
1644-
fallbackContent: parse(
1645+
children: parse(capture[1], state),
1646+
fallbackChildren: parse(
16451647
capture[0].replace(SQUARE_BRACKETS_R, '\\$1'),
16461648
state
16471649
),
@@ -1655,10 +1657,10 @@ export function compiler(
16551657
href={sanitizeUrl(refs[node.ref].target)}
16561658
title={refs[node.ref].title}
16571659
>
1658-
{output(node.content, state)}
1660+
{output(node.children, state)}
16591661
</a>
16601662
) : (
1661-
<span key={state.key}>{output(node.fallbackContent, state)}</span>
1663+
<span key={state.key}>{output(node.fallbackChildren, state)}</span>
16621664
)
16631665
},
16641666
},
@@ -1750,11 +1752,11 @@ export function compiler(
17501752
return {
17511753
// capture[1] -> the syntax control character
17521754
// capture[2] -> inner content
1753-
content: parse(capture[2], state),
1755+
children: parse(capture[2], state),
17541756
}
17551757
},
17561758
render(node, output, state) {
1757-
return <strong key={state.key}>{output(node.content, state)}</strong>
1759+
return <strong key={state.key}>{output(node.children, state)}</strong>
17581760
},
17591761
},
17601762

@@ -1765,11 +1767,11 @@ export function compiler(
17651767
return {
17661768
// capture[1] -> opening * or _
17671769
// capture[2] -> inner content
1768-
content: parse(capture[2], state),
1770+
children: parse(capture[2], state),
17691771
}
17701772
},
17711773
render(node, output, state) {
1772-
return <em key={state.key}>{output(node.content, state)}</em>
1774+
return <em key={state.key}>{output(node.children, state)}</em>
17731775
},
17741776
},
17751777

@@ -1793,7 +1795,7 @@ export function compiler(
17931795
order: Priority.LOW,
17941796
parse: parseCaptureInline,
17951797
render(node, output, state) {
1796-
return <mark key={state.key}>{output(node.content, state)}</mark>
1798+
return <mark key={state.key}>{output(node.children, state)}</mark>
17971799
},
17981800
},
17991801

@@ -1802,7 +1804,7 @@ export function compiler(
18021804
order: Priority.LOW,
18031805
parse: parseCaptureInline,
18041806
render(node, output, state) {
1805-
return <del key={state.key}>{output(node.content, state)}</del>
1807+
return <del key={state.key}>{output(node.children, state)}</del>
18061808
},
18071809
},
18081810
}
@@ -1922,7 +1924,7 @@ export namespace MarkdownToJSX {
19221924
}
19231925

19241926
export interface BlockQuoteNode {
1925-
content: MarkdownToJSX.ParserResult[]
1927+
children: MarkdownToJSX.ParserResult[]
19261928
type: (typeof RuleType)['blockQuote']
19271929
}
19281930

@@ -1967,7 +1969,7 @@ export namespace MarkdownToJSX {
19671969

19681970
export interface HeadingNode {
19691971
type: (typeof RuleType)['heading']
1970-
content: MarkdownToJSX.ParserResult[]
1972+
children: MarkdownToJSX.ParserResult[]
19711973
id: string
19721974
level: 1 | 2 | 3 | 4 | 5 | 6
19731975
}
@@ -1989,7 +1991,7 @@ export namespace MarkdownToJSX {
19891991

19901992
export interface LinkNode {
19911993
type: (typeof RuleType)['link']
1992-
content: MarkdownToJSX.ParserResult[]
1994+
children: MarkdownToJSX.ParserResult[]
19931995
target: string
19941996
title?: string
19951997
}
@@ -2025,7 +2027,7 @@ export namespace MarkdownToJSX {
20252027

20262028
export interface ParagraphNode {
20272029
type: (typeof RuleType)['paragraph']
2028-
content: MarkdownToJSX.ParserResult[]
2030+
children: MarkdownToJSX.ParserResult[]
20292031
}
20302032

20312033
export interface ReferenceNode {
@@ -2040,8 +2042,8 @@ export namespace MarkdownToJSX {
20402042

20412043
export interface ReferenceLinkNode {
20422044
type: (typeof RuleType)['refLink']
2043-
content: MarkdownToJSX.ParserResult[]
2044-
fallbackContent: MarkdownToJSX.ParserResult[]
2045+
children: MarkdownToJSX.ParserResult[]
2046+
fallbackChildren: MarkdownToJSX.ParserResult[]
20452047
ref: string
20462048
}
20472049

@@ -2066,12 +2068,12 @@ export namespace MarkdownToJSX {
20662068

20672069
export interface BoldTextNode {
20682070
type: (typeof RuleType)['textBolded']
2069-
content: MarkdownToJSX.ParserResult[]
2071+
children: MarkdownToJSX.ParserResult[]
20702072
}
20712073

20722074
export interface ItalicTextNode {
20732075
type: (typeof RuleType)['textEmphasized']
2074-
content: MarkdownToJSX.ParserResult[]
2076+
children: MarkdownToJSX.ParserResult[]
20752077
}
20762078

20772079
export interface EscapedTextNode {
@@ -2080,18 +2082,18 @@ export namespace MarkdownToJSX {
20802082

20812083
export interface MarkedTextNode {
20822084
type: (typeof RuleType)['textMarked']
2083-
content: MarkdownToJSX.ParserResult[]
2085+
children: MarkdownToJSX.ParserResult[]
20842086
}
20852087

20862088
export interface StrikethroughTextNode {
20872089
type: (typeof RuleType)['textStrikethroughed']
2088-
content: MarkdownToJSX.ParserResult[]
2090+
children: MarkdownToJSX.ParserResult[]
20892091
}
20902092

20912093
export interface HTMLNode {
20922094
type: (typeof RuleType)['htmlBlock']
20932095
attrs: JSX.IntrinsicAttributes
2094-
content?: ReturnType<MarkdownToJSX.NestedParser> | undefined
2096+
children?: ReturnType<MarkdownToJSX.NestedParser> | undefined
20952097
noInnerParse: Boolean
20962098
tag: MarkdownToJSX.HTMLTags
20972099
text?: string | undefined

0 commit comments

Comments
 (0)