@@ -62,16 +62,25 @@ renderer.image = ({ href, text }: { href: string; text: string }) => {
6262renderer . blockquote = ( { text } : { text : string } ) =>
6363 `<blockquote class="border-l-4 border-[#00FFA7] pl-4 py-2 my-4 text-[#8b949e] bg-[#161b22] rounded-r">${ text } </blockquote>` ;
6464
65- renderer . table = ( { header, body } : { header : string ; body : string } ) =>
66- `<div class="overflow-x-auto my-4"><table class="w-full border-collapse">${ header } ${ body } </table></div>` ;
67-
68- renderer . tablerow = ( { text } : { text : string } ) =>
69- `<tr class="hover:bg-[#161b22]">${ text } </tr>` ;
70-
71- renderer . tablecell = ( { text, header } : { text : string ; header : boolean } ) =>
72- header
73- ? `<th class="px-4 py-2 text-left text-sm font-semibold text-[#e6edf3] border-b border-[#30363d]">${ text } </th>`
74- : `<td class="px-4 py-2 text-sm text-[#8b949e] border-b border-[#21262d]">${ text } </td>` ;
65+ renderer . table = ( { header, rows } : { header : { text : string ; tokens : any [ ] ; header : boolean ; align : string | null } [ ] ; rows : { text : string ; tokens : any [ ] ; header : boolean ; align : string | null } [ ] [ ] } ) => {
66+ const parser = marked . parse ;
67+ const renderCell = ( cell : { text : string ; tokens : any [ ] ; header : boolean ; align : string | null } , isHeader : boolean ) => {
68+ const content = cell . tokens . map ( ( t : any ) => {
69+ if ( t . type === 'text' ) return t . text ;
70+ if ( t . type === 'codespan' ) return `<code class="bg-[#161b22] text-[#00FFA7] px-1.5 py-0.5 rounded text-sm font-mono">${ t . text } </code>` ;
71+ if ( t . type === 'strong' ) return `<strong class="text-[#e6edf3] font-semibold">${ t . text } </strong>` ;
72+ if ( t . type === 'em' ) return `<em>${ t . text } </em>` ;
73+ if ( t . type === 'link' ) return `<a href="${ t . href } " class="text-[#00FFA7] hover:underline">${ t . text } </a>` ;
74+ return t . raw || t . text || '' ;
75+ } ) . join ( '' ) ;
76+ return isHeader
77+ ? `<th class="px-4 py-2 text-left text-sm font-semibold text-[#e6edf3] border-b border-[#30363d]">${ content } </th>`
78+ : `<td class="px-4 py-2 text-sm text-[#8b949e] border-b border-[#21262d]">${ content } </td>` ;
79+ } ;
80+ const headerRow = `<tr>${ header . map ( c => renderCell ( c , true ) ) . join ( '' ) } </tr>` ;
81+ const bodyRows = rows . map ( row => `<tr class="hover:bg-[#161b22]">${ row . map ( c => renderCell ( c , false ) ) . join ( '' ) } </tr>` ) . join ( '' ) ;
82+ return `<div class="overflow-x-auto my-4"><table class="w-full border-collapse"><thead>${ headerRow } </thead><tbody>${ bodyRows } </tbody></table></div>` ;
83+ } ;
7584
7685renderer . list = ( { body, ordered } : { body : string ; ordered : boolean } ) =>
7786 ordered
0 commit comments