Skip to content

Commit

Permalink
fix: can not render code, close #640
Browse files Browse the repository at this point in the history
  • Loading branch information
hyoban committed Sep 27, 2024
1 parent 4751447 commit ab8c9e5
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions apps/renderer/src/lib/parse-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,19 @@ export const parseHtml = (
if (typeof props.children !== "object") {
codeString = props.children.toString()
} else {
const propsChildren = props.children
const children = Array.isArray(propsChildren)
? propsChildren.find((i) => i.type === "code")
: propsChildren

if (
"type" in props.children &&
props.children.type === "code" &&
props.children.props.className?.includes("language-")
"type" in children &&
children.type === "code" &&
children.props.className?.includes("language-")
) {
language = props.children.props.className.replace("language-", "")
language = children.props.className.replace("language-", "")
}
const code = "props" in props.children && props.children.props.children
const code = "props" in children && children.props.children
if (!code) return null

try {
Expand Down

0 comments on commit ab8c9e5

Please sign in to comment.