Skip to content

Commit

Permalink
fix: sanitize highlighted text
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Jan 11, 2023
1 parent 42a31be commit c40d3da
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/runtime/transformers/shiki/highlighter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export const useShikiHighlighter = createSingleton((opts?: Exclude<ModuleOptions

function renderNode (node: any) {
if (node.type === 'text') {
return node.value
return node.value.replace(/</g, '&lt;').replace(/>/g, '&gt;')
}
const children = node.children.map(renderNode).join('')
return `<${node.tag} class="${node.props.class}">${children}</${node.tag}>`
Expand Down

0 comments on commit c40d3da

Please sign in to comment.