From 10de9234724e3e280df522809b27458c4ffaf132 Mon Sep 17 00:00:00 2001 From: jacoblee93 Date: Tue, 16 Apr 2024 15:43:18 -0700 Subject: [PATCH] Render markdown using marked and DOMPurify --- package.json | 3 +- src/components/InstructionsWithCode.js | 11 +- yarn.lock | 183 ++----------------------- 3 files changed, 24 insertions(+), 173 deletions(-) diff --git a/package.json b/package.json index 0e8bea63..76043276 100644 --- a/package.json +++ b/package.json @@ -35,11 +35,12 @@ "@scalar/docusaurus": "^0.0.6", "@supabase/supabase-js": "^2.39.7", "clsx": "^1.2.1", + "dompurify": "^3.1.0", "json-loader": "^0.5.7", + "marked": "^12.0.1", "process": "^0.11.10", "react": "^17.0.2", "react-dom": "^17.0.2", - "react-markdown": "^9.0.1", "webpack": "^5.75.0" }, "devDependencies": { diff --git a/src/components/InstructionsWithCode.js b/src/components/InstructionsWithCode.js index 524f3625..fad6f196 100644 --- a/src/components/InstructionsWithCode.js +++ b/src/components/InstructionsWithCode.js @@ -2,7 +2,8 @@ import React from "react"; import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem"; import CodeBlock from "@theme/CodeBlock"; -import Markdown from "react-markdown"; +import { marked } from "marked"; +import * as DOMPurify from "dompurify"; export function LangChainPyBlock(content) { return { @@ -67,7 +68,13 @@ export function CodeTabs({ tabs, groupId }) { const key = `${groupId}-${index}`; return ( - {tab.caption && {tab.caption}} + {tab.caption && ( +
+ )}