@@ -6,11 +6,8 @@ import {
66 Checkbox ,
77 Code ,
88 Em ,
9- Heading ,
109 Kbd ,
1110 Link ,
12- Strong ,
13- Table ,
1411 Text ,
1512} from "@radix-ui/themes" ;
1613import type { Components } from "react-markdown" ;
@@ -27,44 +24,20 @@ function preprocessMarkdown(content: string): string {
2724 return content . replace ( / \n ( [ ^ \n ] .* ) \n ( - - - + | _ _ _ + | \* \* \* + ) \n / g, "\n$1\n\n$2\n" ) ;
2825}
2926
30- const fontStyle = {
31- fontSize : "var(--font-size-1-5)" ,
32- lineHeight : "var(--line-height-1-5)" ,
33- } ;
27+ const HeadingText = ( { children } : { children : React . ReactNode } ) => (
28+ < Text as = "p" size = "1" mb = "2" style = { { color : "var(--accent-11)" } } >
29+ < strong > { children } </ strong >
30+ </ Text >
31+ ) ;
3432
3533const components : Components = {
36- h1 : ( { children } ) => (
37- < Heading as = "h1" size = "4" mb = "3" color = "gray" highContrast >
38- { children }
39- </ Heading >
40- ) ,
41- h2 : ( { children } ) => (
42- < Heading as = "h2" size = "3" mb = "3" color = "gray" highContrast >
43- { children }
44- </ Heading >
45- ) ,
46- h3 : ( { children } ) => (
47- < Heading as = "h3" size = "2" mb = "2" color = "gray" highContrast >
48- { children }
49- </ Heading >
50- ) ,
51- h4 : ( { children } ) => (
52- < Heading as = "h4" size = "2" mb = "2" color = "gray" highContrast >
53- { children }
54- </ Heading >
55- ) ,
56- h5 : ( { children } ) => (
57- < Heading as = "h5" size = "2" mb = "2" color = "gray" highContrast >
58- { children }
59- </ Heading >
60- ) ,
61- h6 : ( { children } ) => (
62- < Heading as = "h6" size = "2" mb = "2" color = "gray" highContrast >
63- { children }
64- </ Heading >
65- ) ,
34+ h1 : ( { children } ) => < HeadingText > { children } </ HeadingText > ,
35+ h2 : ( { children } ) => < HeadingText > { children } </ HeadingText > ,
36+ h3 : ( { children } ) => < HeadingText > { children } </ HeadingText > ,
37+ h4 : ( { children } ) => < HeadingText > { children } </ HeadingText > ,
38+ h5 : ( { children } ) => < HeadingText > { children } </ HeadingText > ,
39+ h6 : ( { children } ) => < HeadingText > { children } </ HeadingText > ,
6640 p : ( { children, node } ) => {
67- // Check if paragraph only contains a strong element (used as pseudo-heading by LLMs)
6841 const isStrongOnly =
6942 node ?. children ?. length === 1 &&
7043 node . children [ 0 ] . type === "element" &&
@@ -76,66 +49,66 @@ const components: Components = {
7649 size = "1"
7750 mb = { isStrongOnly ? "2" : "3" }
7851 color = "gray"
79- style = { fontStyle }
8052 highContrast
8153 >
8254 { children }
8355 </ Text >
8456 ) ;
8557 } ,
8658 blockquote : ( { children } ) => (
87- < Blockquote size = "2" mb = "3" color = "gray" style = { fontStyle } highContrast >
59+ < Blockquote
60+ size = "1"
61+ mb = "3"
62+ style = { { color : "var(--accent-10)" , borderColor : "var(--accent-6)" } }
63+ >
8864 { children }
8965 </ Blockquote >
9066 ) ,
9167 code : ( { children, className } ) => {
9268 const isInline = ! className ?. includes ( "language-" ) ;
9369 if ( isInline ) {
9470 return (
95- < Code
96- size = "2"
97- variant = "soft"
98- color = "gray"
99- style = { fontStyle }
100- highContrast
101- >
71+ < Code size = "1" variant = "soft" color = "gray" highContrast >
10272 { children }
10373 </ Code >
10474 ) ;
10575 }
10676 return < code > { children } </ code > ;
10777 } ,
108- pre : ( { children } ) => < CodeBlock size = "1.5" > { children } </ CodeBlock > ,
109- em : ( { children } ) => < Em > { children } </ Em > ,
110- strong : ( { children } ) => < Strong > { children } </ Strong > ,
78+ pre : ( { children } ) => < CodeBlock size = "1" > { children } </ CodeBlock > ,
79+ em : ( { children } ) => (
80+ < Em style = { { color : "var(--accent-10)" } } > { children } </ Em >
81+ ) ,
82+ strong : ( { children } ) => (
83+ < strong
84+ style = { { fontSize : "var(--font-size-1)" , color : "var(--accent-11)" } }
85+ >
86+ { children }
87+ </ strong >
88+ ) ,
11189 del : ( { children } ) => (
112- < del style = { { textDecoration : "line-through" , color : "var(--gray-11 )" } } >
90+ < del style = { { textDecoration : "line-through" , color : "var(--gray-9 )" } } >
11391 { children }
11492 </ del >
11593 ) ,
11694 a : ( { href, children } ) => (
117- < Link
118- href = { href }
119- target = "_blank"
120- rel = "noopener noreferrer"
121- style = { fontStyle }
122- >
95+ < Link href = { href } target = "_blank" rel = "noopener noreferrer" size = "1" >
12396 { children }
12497 </ Link >
12598 ) ,
126- kbd : ( { children } ) => < Kbd style = { fontStyle } > { children } </ Kbd > ,
99+ kbd : ( { children } ) => < Kbd size = "1" > { children } </ Kbd > ,
127100 ul : ( { children } ) => (
128- < List as = "ul" size = "1.5 " >
101+ < List as = "ul" size = "1" >
129102 { children }
130103 </ List >
131104 ) ,
132105 ol : ( { children } ) => (
133- < List as = "ol" size = "1.5 " >
106+ < List as = "ol" size = "1" >
134107 { children }
135108 </ List >
136109 ) ,
137- li : ( { children } ) => < ListItem size = "1.5 " > { children } </ ListItem > ,
138- hr : ( ) => < Divider size = "2 " /> ,
110+ li : ( { children } ) => < ListItem size = "1" > { children } </ ListItem > ,
111+ hr : ( ) => < Divider size = "1 " /> ,
139112 // Task list checkbox
140113 input : ( { type, checked } ) => {
141114 if ( type === "checkbox" ) {
@@ -149,22 +122,24 @@ const components: Components = {
149122 }
150123 return < input type = { type } /> ;
151124 } ,
152- // Table components using Radix Table
125+ // Table components - plain HTML for size control
153126 table : ( { children } ) => (
154- < Table . Root size = "1" variant = "surface" mb = "3" >
127+ < table className = "mb-3" style = { { fontSize : "var(--font-size-1)" } } >
155128 { children }
156- </ Table . Root >
129+ </ table >
157130 ) ,
158- thead : ( { children } ) => < Table . Header > { children } </ Table . Header > ,
159- tbody : ( { children } ) => < Table . Body > { children } </ Table . Body > ,
160- tr : ( { children } ) => < Table . Row > { children } </ Table . Row > ,
131+ thead : ( { children } ) => < thead > { children } </ thead > ,
132+ tbody : ( { children } ) => < tbody > { children } </ tbody > ,
133+ tr : ( { children } ) => < tr className = "border-gray-6 border-b" > { children } </ tr > ,
161134 th : ( { children, style } ) => (
162- < Table . ColumnHeaderCell style = { { ... fontStyle , ... style } } >
135+ < th className = "px-2 py-1 text-left text-gray-11" style = { style } >
163136 { children }
164- </ Table . ColumnHeaderCell >
137+ </ th >
165138 ) ,
166139 td : ( { children, style } ) => (
167- < Table . Cell style = { { ...fontStyle , ...style } } > { children } </ Table . Cell >
140+ < td className = "px-2 py-1 text-gray-12" style = { style } >
141+ { children }
142+ </ td >
168143 ) ,
169144} ;
170145
0 commit comments