Skip to content

Commit

Permalink
Fix tags rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
catacgc committed Dec 14, 2024
1 parent 2c080b0 commit 9d05861
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/view/NodeRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,20 @@ export const NodeRenderer = (props: { tokens: Token[] }) => {
}

if (token.type == "image") {
return <NodeRendererImage token={token}/>
return <>
<NodeRendererImage token={token}/>
<NodeRenderer tokens={tokens.slice(1)}/>
</>
}

if (token.type == "code_inline") {
return <code>{token.content}</code>
return <>
<code>{token.content}</code>
<NodeRenderer tokens={tokens.slice(1)}/>
</>
}

// if (!token.type.includes("_close")) console.log("tokens not rendered: ", tokens)
if (!token.type.includes("_close")) console.log("tokens not rendered: ", tokens)

return <NodeRenderer tokens={tokens.slice(1)}/>
}
Expand Down
6 changes: 6 additions & 0 deletions tests/view/noderenderer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ describe('NodeRenderer', () => {
expect(screen.getByText('snippet')).toBeInTheDocument();
});

it('renders tags', () => {
renderMarkdown("test #tag")

expect(screen.getByText('test #tag')).toBeInTheDocument();
});

it('renders inline tokens', () => {
renderMarkdown("Hello");

Expand Down

0 comments on commit 9d05861

Please sign in to comment.