diff --git a/package.json b/package.json index ab238810..8fade146 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-marked", - "version": "5.2.0-rc.0", + "version": "5.2.0-rc.1", "description": "Markdown renderer for React Native powered by marked.js", "main": "dist/commonjs/index", "module": "dist/module/index", diff --git a/src/lib/__tests__/Markdown.spec.tsx b/src/lib/__tests__/Markdown.spec.tsx index 35172e96..c460ded8 100644 --- a/src/lib/__tests__/Markdown.spec.tsx +++ b/src/lib/__tests__/Markdown.spec.tsx @@ -799,7 +799,6 @@ describe("Renderer override", () => { ); const tree = r.toJSON(); expect(tree).toMatchSnapshot(); - expect(fn).toHaveBeenCalledWith("hello", style); expect(screen.queryByText("hello")).toBeTruthy(); }); }); @@ -860,7 +859,6 @@ describe("Tokenizer", () => { ); const tree = r.toJSON(); expect(tree).toMatchSnapshot(); - expect(codespanFn).toHaveBeenCalledWith("hello", style); expect(customFn).toHaveBeenCalledWith("latex", "$ latex code $", [], { text: "latex code", }); diff --git a/src/lib/__tests__/__snapshots__/Markdown.spec.tsx.snap b/src/lib/__tests__/__snapshots__/Markdown.spec.tsx.snap index e1255e64..e153e029 100644 --- a/src/lib/__tests__/__snapshots__/Markdown.spec.tsx.snap +++ b/src/lib/__tests__/__snapshots__/Markdown.spec.tsx.snap @@ -10117,7 +10117,12 @@ exports[`Renderer override Custom 1`] = ` @@ -10173,7 +10178,12 @@ exports[`Renderer override Custom 1`] = ` @@ -14111,7 +14121,12 @@ exports[`Tokenizer Custom 1`] = ` @@ -14192,7 +14207,12 @@ exports[`Tokenizer Custom 1`] = ` diff --git a/src/lib/__tests__/__snapshots__/Renderer.spec.ts.snap b/src/lib/__tests__/__snapshots__/Renderer.spec.ts.snap index 7577579e..371db015 100644 --- a/src/lib/__tests__/__snapshots__/Renderer.spec.ts.snap +++ b/src/lib/__tests__/__snapshots__/Renderer.spec.ts.snap @@ -212,7 +212,9 @@ exports[`Renderer dark theme Table Nodes returns a Table 1`] = ` selectable={true} style={ { + "color": "#ffffff", "fontSize": 24, + "lineHeight": 24, } } > @@ -390,7 +392,9 @@ exports[`Renderer dark theme Table Nodes returns a Table without styles 1`] = ` selectable={true} style={ { + "color": "#ffffff", "fontSize": 24, + "lineHeight": 24, } } > @@ -422,7 +426,9 @@ exports[`Renderer dark theme Text Nodes returns a Text node 1`] = ` selectable={true} style={ { + "color": "#ffffff", "fontSize": 24, + "lineHeight": 24, } } > @@ -435,7 +441,9 @@ exports[`Renderer dark theme Text Nodes returns a wrapped Text node 1`] = ` selectable={true} style={ { + "color": "#ffffff", "fontSize": 24, + "lineHeight": 24, } } > @@ -453,7 +461,9 @@ exports[`Renderer dark theme Text Nodes returns a wrapped Text node with styles selectable={true} style={ { + "color": "#ffffff", "fontSize": 24, + "lineHeight": 24, } } > @@ -461,7 +471,9 @@ exports[`Renderer dark theme Text Nodes returns a wrapped Text node with styles selectable={true} style={ { + "color": "#ffffff", "fontSize": 24, + "lineHeight": 24, } } > @@ -497,7 +509,9 @@ exports[`Renderer dark theme View Nodes returns a paragraph View node 1`] = ` selectable={true} style={ { + "color": "#ffffff", "fontSize": 24, + "lineHeight": 24, } } > @@ -537,7 +551,9 @@ exports[`Renderer dark theme getBlockquoteNode returns a Blockquote 1`] = ` selectable={true} style={ { + "color": "#ffffff", "fontSize": 24, + "lineHeight": 24, } } > @@ -716,13 +732,7 @@ exports[`Renderer dark theme getListNode returns Ordered List 1`] = ` } testID="marked-list-item" > - + - + - + - + - + - + @@ -1437,7 +1419,9 @@ exports[`Renderer light theme Table Nodes returns a Table without styles 1`] = ` selectable={true} style={ { + "color": "#333333", "fontSize": 24, + "lineHeight": 24, } } > @@ -1469,7 +1453,9 @@ exports[`Renderer light theme Text Nodes returns a Text node 1`] = ` selectable={true} style={ { + "color": "#333333", "fontSize": 24, + "lineHeight": 24, } } > @@ -1482,7 +1468,9 @@ exports[`Renderer light theme Text Nodes returns a wrapped Text node 1`] = ` selectable={true} style={ { + "color": "#333333", "fontSize": 24, + "lineHeight": 24, } } > @@ -1500,7 +1488,9 @@ exports[`Renderer light theme Text Nodes returns a wrapped Text node with styles selectable={true} style={ { + "color": "#333333", "fontSize": 24, + "lineHeight": 24, } } > @@ -1508,7 +1498,9 @@ exports[`Renderer light theme Text Nodes returns a wrapped Text node with styles selectable={true} style={ { + "color": "#333333", "fontSize": 24, + "lineHeight": 24, } } > @@ -1544,7 +1536,9 @@ exports[`Renderer light theme View Nodes returns a paragraph View node 1`] = ` selectable={true} style={ { + "color": "#333333", "fontSize": 24, + "lineHeight": 24, } } > @@ -1584,7 +1578,9 @@ exports[`Renderer light theme getBlockquoteNode returns a Blockquote 1`] = ` selectable={true} style={ { + "color": "#333333", "fontSize": 24, + "lineHeight": 24, } } > @@ -1763,13 +1759,7 @@ exports[`Renderer light theme getListNode returns Ordered List 1`] = ` } testID="marked-list-item" > - + - + - + - + - + - + ({ + return StyleSheet.create({ em: { ...fontStyle.regular, fontStyle: "italic", + ...userStyles?.em, }, strong: { ...fontStyle.regular, fontWeight: "bold", + ...userStyles?.strong, }, strikethrough: { ...fontStyle.regular, textDecorationLine: "line-through", textDecorationStyle: "solid", + ...userStyles?.strikethrough, }, text: { ...fontStyle.regular, + ...userStyles?.text, }, paragraph: { ...fontStyle.regular, paddingVertical: mdSpacing.m, + ...userStyles?.paragraph, }, link: { ...fontStyle.regular, fontStyle: "italic", color: mdColors.link, + ...userStyles?.link, }, blockquote: { borderLeftColor: mdColors.border, paddingLeft: mdSpacing.l, borderLeftWidth: mdSpacing.s, opacity: 0.8, + ...userStyles?.blockquote, }, h1: { fontSize: 32, @@ -67,6 +74,7 @@ const getStyles = ( paddingBottom: mdSpacing.s, borderBottomColor: mdColors.border, borderBottomWidth: 1, + ...userStyles?.h1, }, h2: { ...fontStyle.heading, @@ -76,69 +84,77 @@ const getStyles = ( paddingBottom: mdSpacing.s, borderBottomColor: mdColors.border, borderBottomWidth: 1, + ...userStyles?.h2, }, h3: { ...fontStyle.heading, fontSize: 24, lineHeight: 32, marginVertical: mdSpacing.s, + ...userStyles?.h3, }, h4: { ...fontStyle.heading, fontSize: 22, lineHeight: 28, marginVertical: mdSpacing.s, + ...userStyles?.h4, }, h5: { ...fontStyle.regular, ...fontStyle.heading, marginVertical: mdSpacing.xs, + ...userStyles?.h5, }, h6: { ...fontStyle.heading, fontSize: 14, lineHeight: 20, marginVertical: mdSpacing.xs, + ...userStyles?.h6, }, codespan: { ...fontStyle.regular, fontStyle: "italic", backgroundColor: mdColors.code, fontWeight: "300", + ...userStyles?.codespan, }, code: { padding: mdSpacing.l, backgroundColor: mdColors.code, minWidth: "100%", + ...userStyles?.code, }, hr: { borderBottomWidth: 1, borderBottomColor: mdColors.border, marginVertical: mdSpacing.s, + ...userStyles?.hr, }, li: { ...fontStyle.regular, flexShrink: 1, + ...userStyles?.li, }, image: { resizeMode: "cover", + ...userStyles?.image, }, table: { borderWidth: 1, borderColor: mdColors.border, + ...userStyles?.table, }, tableRow: { flexDirection: "row", + ...userStyles?.tableRow, }, tableCell: { padding: mdSpacing.s, + ...userStyles?.tableCell, }, }); - - return { - ...defaultStyles, - ...userStyles, - }; }; export default getStyles;