Skip to content

Commit

Permalink
fix(utils): fix markdown parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
nfroidure committed Dec 22, 2022
1 parent 3e42abb commit 1a1e1b5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/utils/markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ const blockquoteMap: NodeToElementMapper<MarkdownBlockquoteNode> = (
</Blockquote>
);
const imageMap: NodeToElementMapper<MarkdownImageNode> = (context, node) => {
const finalTitle = (node.title || "").replace(/^🖼(|)\s*/, "");
const finalTitle = (node.title || "").replace(/^🖼(|)\s*/u, "");

return (
<span key={context.index}>
Expand Down Expand Up @@ -325,7 +325,7 @@ const imageMap: NodeToElementMapper<MarkdownImageNode> = (context, node) => {
const hyperlinkMap: NodeToElementMapper<MarkdownLinkNode> = (context, node) => {
const youtubeURL = parseYouTubeURL(node.url);

return node?.title.startsWith("🎧") ? (
return node?.title?.startsWith("🎧") ? (
<audio
controls
src={
Expand All @@ -334,16 +334,17 @@ const hyperlinkMap: NodeToElementMapper<MarkdownLinkNode> = (context, node) => {
"/" +
node.url
}
title={node.title}
title={node.title.replace(/^🎧\s*/u, '').trim()}
/>
) : youtubeURL && node?.title === "📺" ? (
) : youtubeURL && node?.title?.startsWith("📺") ? (
<span className="root" key={context.index}>
<iframe
width="560"
height="315"
src={`https://www.youtube.com/embed/${youtubeURL.videoId}${
youtubeURL.startTime ? "?start=" + youtubeURL.startTime : ""
}`}
title={node.title.replace(/^📺\s*/u, '').trim()}
frameBorder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowFullScreen
Expand Down

0 comments on commit 1a1e1b5

Please sign in to comment.