File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change 11import React from "react" ;
22
3+ import { AppMarkdownTable } from "@/components/libresplit/AppMarkdownTable" ;
34import { fromMarkdown } from "mdast-util-from-markdown" ;
45import { CodeBlock } from "react-code-block" ;
6+ import { gfm } from "micromark-extension-gfm" ;
7+ import { gfmFromMarkdown } from "mdast-util-gfm" ;
58
69export function Markdown ( { content } : { content : string } ) {
7- const tree = fromMarkdown ( content ) ;
10+ const tree = fromMarkdown ( content , {
11+ extensions : [ gfm ( ) ] ,
12+ mdastExtensions : [ gfmFromMarkdown ( ) ] ,
13+ } ) ;
814
915 function renderChildren ( node : any ) : React . ReactNode | null {
1016 if ( ! node . children ) {
@@ -79,6 +85,19 @@ export function Markdown({ content }: { content: string }) {
7985 return < li > { renderChildren ( node ) } </ li > ;
8086 }
8187
88+ // Handles tables.
89+ case "table" :
90+ return (
91+ < AppMarkdownTable
92+ node = { node }
93+ renderChildren = { ( n ) =>
94+ n ?. children ?. map ( ( c : any , i : number ) => (
95+ < React . Fragment key = { i } > { renderNode ( c ) } </ React . Fragment >
96+ ) )
97+ }
98+ />
99+ ) ;
100+
82101 // Handles code blocks.
83102 case "code" :
84103 return (
You can’t perform that action at this time.
0 commit comments