Connect, collaborate, and grow with a community of TypeScript developers
fix: `react-markdown` escaping `details` and `summary` tag (#1037)
Gurpal Singh64451f9882de
diff --git a/packages/db/seed/prod.ts b/packages/db/seed/prod.tsindex 0ad88b53..12763f25 100644--- a/packages/db/seed/prod.ts+++ b/packages/db/seed/prod.ts@@ -54,7 +54,10 @@ try {})),});await prisma.challenge.createMany({- data: challengesToCreate.map((challenge) => ({ ...challenge, userId: typeHeroUser.id })),+ data: challengesToCreate.map(({ author, ...challenge }) => ({+ ...challenge,+ userId: typeHeroUser.id,+ })),});for (const track of tracks) {diff --git a/packages/ui/package.json b/packages/ui/package.jsonindex 0233f565..123c8172 100644--- a/packages/ui/package.json+++ b/packages/ui/package.json@@ -62,6 +62,7 @@"react-hook-form": "^7.45.1","react-markdown": "^8.0.7","react-syntax-highlighter": "^15.5.0",+ "rehype-raw": "^7.0.0","remark-gfm": "^3.0.1","tailwind-merge": "^1.14.0","tailwindcss-animate": "^1.0.6",diff --git a/packages/ui/src/components/markdown.tsx b/packages/ui/src/components/markdown.tsxindex 73d9a650..e2b61df4 100644--- a/packages/ui/src/components/markdown.tsx+++ b/packages/ui/src/components/markdown.tsx@@ -9,6 +9,7 @@ import { visit, SKIP, type BuildVisitor } from 'unist-util-visit';import type { Transformer } from 'unified';import { useTheme } from 'next-themes';import typescript from 'react-syntax-highlighter/dist/esm/languages/prism/typescript';+import rehypeRaw from 'rehype-raw';SyntaxHighlighter.registerLanguage('typescript', typescript);@@ -91,7 +92,11 @@ export function Markdown({ children, className }: { children: string; className?</code>);},+ details: ({ ...props }) => <details {...props} />,+ summary: ({ ...props }) => <summary {...props} />,}}+ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ rehypePlugins={[rehypeRaw as any]}remarkPlugins={[removeHtmlComments, remarkGfm]}>{children}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 5819195d..1a9321c4 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -694,6 +694,9 @@ importers:react-syntax-highlighter:specifier: ^15.5.0version: 15.5.0([email protected])+ rehype-raw:+ specifier: ^7.0.0+ version: 7.0.0remark-gfm:specifier: ^3.0.1version: 3.0.1@@ -727,7 +730,7 @@ importers:dependencies:'@next/eslint-plugin-next':specifier: canary- version: 13.4.20-canary.0+ version: 13.5.7-canary.35'@repo/tsconfig':specifier: workspace:*version: link:../config-typescript@@ -739,7 +742,7 @@ importers:version: 5.62.0([email protected])([email protected])'@vercel/style-guide':specifier: ^4.0.2eslint:specifier: ^8.45.0version: 8.45.0@@ -2328,8 +2331,8 @@ packages:glob: 7.1.7dev: true- /@next/[email protected]:- resolution: {integrity: sha512-vFC1meiw/awh2xJZMWaoECsfZbgkt2fF3HIg8f2fSM/w41Z86L1SS7SjKmpbbD87yq3tiqgqHmFv0JCych4g4g==}+ /@next/[email protected]:+ resolution: {integrity: sha512-RQ5sKupGSzMEL5S/RlSKC+K8ud9VXpDK+HibbF4KFP1R9ygXlbrmCNKP6YFy2ajHMcrcjmsefni2QZ4mi60wYw==}dependencies:glob: 7.1.7dev: false@@ -4741,6 +4744,12 @@ packages:'@types/unist': 2.0.7dev: false+ /@types/[email protected]:+ resolution: {integrity: sha512-B5hZHgHsXvfCoO3xgNJvBnX7N8p86TqQeGKXcokW4XXi+qY4vxxPSFYofytvVmpFxzPv7oxDQzjg5Un5m2/xiw==}+ dependencies:+ '@types/unist': 3.0.0+ dev: false+/@types/[email protected]:resolution: {integrity: sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==}@@ -4767,6 +4776,12 @@ packages:'@types/unist': 2.0.7dev: false+ /@types/[email protected]:+ resolution: {integrity: sha512-tYR83EignvhYO9iU3kDg8V28M0jqyh9zzp5GV+EO+AYnyUl3P5ltkTeJuTiFZQFz670FSb3EwT/6LQdX+UdKfw==}+ dependencies:+ '@types/unist': 3.0.0+ dev: false+/@types/[email protected]:resolution: {integrity: sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==}dev: false@@ -5063,6 +5078,10 @@ packages:- supports-colordev: false+ /@ungap/[email protected]:+ resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==}+ dev: false+/@uploadthing/[email protected]:resolution: {integrity: sha512-UDySsPbdi7wp52WG7mp5CiZwaTvokDubqhm1xhFm73Bqhp0PsGbwSSF5PdCXH4fe8Y4EKGrMyWQ4i1fF9+DVVQ==}dev: false@@ -5123,7 +5142,7 @@ packages:yoga-wasm-web: 0.3.0dev: false- /@vercel/[email protected](@next/[email protected])([email protected])([email protected])([email protected]):+ /@vercel/[email protected](@next/[email protected])([email protected])([email protected])([email protected]):resolution: {integrity: sha512-FroL+oOePzhw7n/I+f7zr4WNroGHT/+2TlW6WH9+CVSjMNsEyu7Qstj2mI5gWIBjT1Y2ZImKPppCzI2cIYmNZw==}engines: {node: '>=16'}peerDependencies:@@ -5143,7 +5162,7 @@ packages:dependencies:'@babel/core': 7.22.10'@babel/eslint-parser': 7.22.10(@babel/[email protected])([email protected])- '@next/eslint-plugin-next': 13.4.20-canary.0+ '@next/eslint-plugin-next': 13.5.7-canary.35'@rushstack/eslint-patch': 1.3.2'@typescript-eslint/eslint-plugin': 5.59.1(@typescript-eslint/[email protected])([email protected])([email protected])'@typescript-eslint/parser': 5.62.0([email protected])([email protected])@@ -5880,7 +5899,7 @@ packages:normalize-path: 3.0.0readdirp: 3.6.0optionalDependencies:- fsevents: 2.3.2+ fsevents: 2.3.3resolution: {integrity: sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg==}@@ -6413,6 +6432,12 @@ packages:minimist: 1.2.8dev: false+ resolution: {integrity: sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==}+ dependencies:+ dequal: 2.0.3+ dev: false+resolution: {integrity: sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==}@@ -7784,6 +7809,7 @@ packages:engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}os: [darwin]requiresBuild: true+ dev: falseoptional: true@@ -7791,7 +7817,6 @@ packages:engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}os: [darwin]requiresBuild: true- dev: trueoptional: true@@ -8073,6 +8098,19 @@ packages:web-namespaces: 2.0.1dev: false+ resolution: {integrity: sha512-Er/Iixbc7IEa7r/XLtuG52zoqn/b3Xng/w6aZQ0xGVxzhw5xUFxcRqdPzP6yFi/4HBYRaifaI5fQ1RH8n0ZeOQ==}+ dependencies:+ '@types/hast': 3.0.2+ '@types/unist': 3.0.0+ devlop: 1.1.0+ hastscript: 8.0.0+ property-information: 6.2.0+ vfile: 6.0.1+ vfile-location: 5.0.2+ web-namespaces: 2.0.1+ dev: false+resolution: {integrity: sha512-X2+RwZIMTMKpXUzlotatPzWj8bspCymtXH3cfG3iQKV+wPF53Vgaqxi/eLqGck0wKq1kS9nvoB1wchbCPEL8sg==}dev: false@@ -8100,6 +8138,12 @@ packages:'@types/hast': 2.3.5dev: false+ resolution: {integrity: sha512-wkQCkSYoOGCRKERFWcxMVMOcYE2K1AaNLU8DXS9arxnLOUEWbOXKXiJUNzEpqZ3JOKpnha3jkFrumEjVliDe7A==}+ dependencies:+ '@types/hast': 3.0.2+ dev: false+resolution: {integrity: sha512-RujVQfVsOrxzPOPSzZFiwofMArbQke6DJjnFfceiEbFh7S05CbPt0cYN+A5YeD3pso0JQk6O1aHBnx9+Pm2uqg==}dependencies:@@ -8116,6 +8160,24 @@ packages:zwitch: 2.0.4dev: false+ resolution: {integrity: sha512-5m1gmba658Q+lO5uqL5YNGQWeh1MYWZbZmWrM5lncdcuiXuo5E2HT/CIOp0rLF8ksfSwiCVJ3twlgVRyTGThGA==}+ dependencies:+ '@types/hast': 3.0.2+ '@types/unist': 3.0.0+ '@ungap/structured-clone': 1.2.0+ hast-util-from-parse5: 8.0.1+ hast-util-to-parse5: 8.0.0+ html-void-elements: 3.0.0+ mdast-util-to-hast: 13.0.2+ parse5: 7.1.2+ unist-util-position: 5.0.0+ unist-util-visit: 5.0.0+ vfile: 6.0.1+ web-namespaces: 2.0.1+ zwitch: 2.0.4+ dev: false+resolution: {integrity: sha512-QQhWMhgTFRhCaQdgTKzZ5g31GLQ9qRb1hZtDPMqQaOhpLBziWcshUS0uCR5IJ0U1jrK/mxg35fmcq+Dp/Cy2Aw==}dependencies:@@ -8163,6 +8225,18 @@ packages:zwitch: 2.0.4dev: false+ resolution: {integrity: sha512-3KKrV5ZVI8if87DVSi1vDeByYrkGzg4mEfeu4alwgmmIeARiBLKCZS2uw5Gb6nU9x9Yufyj3iudm6i7nl52PFw==}+ dependencies:+ '@types/hast': 3.0.2+ comma-separated-tokens: 2.0.3+ devlop: 1.1.0+ property-information: 6.2.0+ space-separated-tokens: 2.0.2+ web-namespaces: 2.0.1+ zwitch: 2.0.4+ dev: false+resolution: {integrity: sha512-02AQ3vLhuH3FisaMM+i/9sm4OXGSq1UhOOCpTLLQtHdL3tZt7qil69r8M8iDkZYyC0HCFylcYoP+8IO7ddta1A==}dependencies:@@ -8193,6 +8267,16 @@ packages:space-separated-tokens: 2.0.2dev: false+ resolution: {integrity: sha512-dMOtzCEd3ABUeSIISmrETiKuyydk1w0pa+gE/uormcTpSYuaNJPbX1NU3JLyscSLjwAQM8bWMhhIlnCqnRvDTw==}+ dependencies:+ '@types/hast': 3.0.2+ comma-separated-tokens: 2.0.3+ hast-util-parse-selector: 4.0.0+ property-information: 6.2.0+ space-separated-tokens: 2.0.2+ dev: false+resolution: {integrity: sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A==}dev: false@@ -8241,6 +8325,10 @@ packages:resolution: {integrity: sha512-0quDb7s97CfemeJAnW9wC0hw78MtW7NU3hqtCD75g2vFlDLt36llsYD7uB7SUzojLMP24N5IatXf7ylGXiGG9A==}dev: false+ resolution: {integrity: sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg==}+ dev: false+resolution: {integrity: sha512-4lVbmc1diZC7GUJQtRQ5yBAeUCL1exyMwmForWkRLnwyzWBFxN633SALPMGYaWZvKe9j1pRZJpauvmxENSp/EA==}dependencies:@@ -9122,6 +9210,19 @@ packages:unist-util-visit: 4.1.2dev: false+ resolution: {integrity: sha512-U5I+500EOOw9e3ZrclN3Is3fRpw8c19SMyNZlZ2IS+7vLsNzb2Om11VpIVOR+/0137GhZsFEF6YiKD5+0Hr2Og==}+ dependencies:+ '@types/hast': 3.0.2+ '@types/mdast': 4.0.2+ '@ungap/structured-clone': 1.2.0+ devlop: 1.1.0+ micromark-util-sanitize-uri: 2.0.0+ trim-lines: 3.0.1+ unist-util-position: 5.0.0+ unist-util-visit: 5.0.0+ dev: false+resolution: {integrity: sha512-bbv7TPv/WC49thZPg3jXuqzuvI45IL2EVAr/KxF0BSdHsU0ceFHOmwQn6evxAh1GaoK/6GQ1wp4R4oW2+LFL/A==}dependencies:@@ -9303,6 +9404,13 @@ packages:micromark-util-types: 1.1.0dev: false+ resolution: {integrity: sha512-3wgnrmEAJ4T+mGXAUfMvMAbxU9RDG43XmGce4j6CwPtVxB3vfwXSZ6KhFwDzZ3mZHhmPimMAXg71veiBGzeAZw==}+ dependencies:+ micromark-util-symbol: 2.0.0+ micromark-util-types: 2.0.0+ dev: false+resolution: {integrity: sha512-Ye01HXpkZPNcV6FiyoW2fGZDUw4Yc7vT0E9Sad83+bEDiCJ1uXu0S3mr8WLpsz3HaG3x2q0HM6CTuPdcZcluFQ==}dependencies:@@ -9343,6 +9451,10 @@ packages:resolution: {integrity: sha512-EuEzTWSTAj9PA5GOAs992GzNh2dGQO52UvAbtSOMvXTxv3Criqb6IOzJUBCmEqrrXSblJIJBbFFv6zPxpreiJw==}dev: false+ resolution: {integrity: sha512-pS+ROfCXAGLWCOc8egcBvT0kf27GoWMqtdarNfDcjb6YLuV5cM3ioG45Ys2qOVqeqSbjaKg72vU+Wby3eddPsA==}+ dev: false+resolution: {integrity: sha512-VTQzcuQgFUD7yYztuQFKXT49KghjtETQ+Wv/zUjGSGBioZnkA4P1XXZPT1FHeJA6RwRXSF47yvJ1tsJdoxwO+Q==}dev: false@@ -9367,6 +9479,14 @@ packages:micromark-util-symbol: 1.1.0dev: false+ resolution: {integrity: sha512-WhYv5UEcZrbAtlsnPuChHUAsu/iBPOVaEVsntLBIdpibO0ddy8OzavZz3iL2xVvBZOpolujSliP65Kq0/7KIYw==}+ dependencies:+ micromark-util-character: 2.0.1+ micromark-util-encode: 2.0.0+ micromark-util-symbol: 2.0.0+ dev: false+resolution: {integrity: sha512-kUQHyzRoxvZO2PuLzMt2P/dwVsTiivCK8icYTeR+3WgbuPqfHgPPy7nFKbeqRivBvn/3N3GBiNC+JRTMSxEC7A==}dependencies:@@ -9380,10 +9500,18 @@ packages:resolution: {integrity: sha512-uEjpEYY6KMs1g7QfJ2eX1SQEV+ZT4rUD3UcF6l57acZvLNK7PBZL+ty82Z1qhK1/yXIY4bdx04FKMgR0g4IAag==}dev: false+ resolution: {integrity: sha512-8JZt9ElZ5kyTnO94muPxIGS8oyElRJaiJO8EzV6ZSyGQ1Is8xwl4Q45qU5UOg+bGH4AikWziz0iN4sFLWs8PGw==}+ dev: false+resolution: {integrity: sha512-ukRBgie8TIAcacscVHSiddHjO4k/q3pnedmzMQ4iwDcK0FtFCohKOlFbaOL/mPgfnPsL3C1ZyxJa4sbWrBl3jg==}dev: false+ resolution: {integrity: sha512-oNh6S2WMHWRZrmutsRmDDfkzKtxF+bc2VxLC9dvtrDIRFln627VsFP6fLMgTryGDljgLPjkrzQSDcPrjPyDJ5w==}+ dev: false+resolution: {integrity: sha512-uD66tJj54JLYq0De10AhWycZWGQNUvDI55xPgk2sQM5kn1JYlhbCMTtEeT27+vAhW2FBQxLlOmS3pmA7/2z4aA==}dependencies:@@ -10037,6 +10165,12 @@ packages:resolution: {integrity: sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==}dev: false+ resolution: {integrity: sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==}+ dependencies:+ entities: 4.5.0+ dev: false+resolution: {integrity: sha512-VfcwXlBWgTF+unPcr7yu3HSSA6QUdDaDnrHcytVfj5Z8azAyKBDrYnSIfeSxlrEayndNcLmrXzg+Vxbo6DWRXQ==}dependencies:@@ -10942,6 +11076,14 @@ packages:unified: 10.1.2dev: false+ resolution: {integrity: sha512-/aE8hCfKlQeA8LmyeyQvQF3eBiLRGNlfBJEvWH7ivp9sBqs7TNqBL5X3v157rM4IFETqDnIOO+z5M/biZbo9Ww==}+ dependencies:+ '@types/hast': 3.0.2+ hast-util-raw: 9.0.1+ vfile: 6.0.1+ dev: false+resolution: {integrity: sha512-REDTNCvsKcAazy8IQWzKp66AhSUDSOIKssSCqNqCcT9sN7JCwAAm3mWGTUdUzq80ABuy8d0D6RBwbnewu1aY1g==}engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}@@ -11099,7 +11241,7 @@ packages:engines: {node: '>=10.0.0'}hasBin: trueoptionalDependencies:- fsevents: 2.3.2+ fsevents: 2.3.3dev: false@@ -11107,7 +11249,7 @@ packages:engines: {node: '>=10.0.0'}hasBin: trueoptionalDependencies:- fsevents: 2.3.2+ fsevents: 2.3.3dev: true@@ -11115,7 +11257,7 @@ packages:engines: {node: '>=14.18.0', npm: '>=8.0.0'}hasBin: trueoptionalDependencies:- fsevents: 2.3.2+ fsevents: 2.3.3resolution: {integrity: sha512-XcT5rBksx1QdIhlFOCtgZkB99ZEouFZ1E2Kc2LHqNW13U3/74YGdkQRmThTwxy4QIyookibDKYZOPqX//6BlAg==}@@ -11845,7 +11987,7 @@ packages:'@esbuild-kit/core-utils': 3.1.0'@esbuild-kit/esm-loader': 2.5.5optionalDependencies:- fsevents: 2.3.2+ fsevents: 2.3.3dev: true@@ -12085,12 +12227,24 @@ packages:'@types/unist': 2.0.7dev: false+ resolution: {integrity: sha512-fucsC7HjXvkB5R3kTCO7kUjRdrS0BJt3M/FPxmHMBOm8JQi2BsHAHFsy27E0EolP8rp0NzXsJ+jNPyDWvOJZPA==}+ dependencies:+ '@types/unist': 3.0.0+ dev: false+resolution: {integrity: sha512-k5GzIBZ/QatR8N5X2y+drfpWG8IDBzdnVj6OInRNWm1oXrzydiaAT2OQiA8DPRRZyAKb9b6I2a6PxYklZD0gKg==}dependencies:'@types/unist': 2.0.7dev: false+ resolution: {integrity: sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ==}+ dependencies:+ '@types/unist': 3.0.0+ dev: false+resolution: {integrity: sha512-x6+y8g7wWMyQhL1iZfhIPhDAs7Xwbn9nRosDXl7qoPTSCy0yNxnKc+hWokFifWQIDGi154rdUqKvbCa4+1kLhg==}dependencies:@@ -12285,6 +12439,13 @@ packages:vfile: 5.3.7dev: false+ resolution: {integrity: sha512-NXPYyxyBSH7zB5U6+3uDdd6Nybz6o6/od9rk8bp9H8GR3L+cm/fC0uUTbqBmUTnMCUDslAGBOIKNfvvb+gGlDg==}+ dependencies:+ '@types/unist': 3.0.0+ vfile: 6.0.1+ dev: false+resolution: {integrity: sha512-fa0Z6P8HUrQN4BZaX05SIVXic+7kE3b05PWAtPuYP9QLHsLKYR7/AlLW3NtOrpXRLeawpDLMsVkmk5DG0NXgWw==}dependencies:@@ -12292,6 +12453,13 @@ packages:unist-util-stringify-position: 3.0.3dev: false+ resolution: {integrity: sha512-jRDZ1IMLttGj41KcZvlrYAaI3CfqpLpfpf+Mfig13viT6NKvRzWZ+lXz0Y5D60w6uJIBAOGq9mSHf0gktF0duw==}+ dependencies:+ '@types/unist': 3.0.0+ unist-util-stringify-position: 4.0.0+ dev: false+resolution: {integrity: sha512-r7qlzkgErKjobAmyNIkkSpizsFPYiUPuJb5pNW1RB4JcYVZhs4lIbVqk8XPk033CV/1z8ss5pkax8SuhGpcG8g==}dependencies:@@ -12301,6 +12469,14 @@ packages:vfile-message: 3.1.4dev: false+ resolution: {integrity: sha512-1bYqc7pt6NIADBJ98UiG0Bn/CHIVOoZ/IyEkqIruLg0mE1BKzkOXY2D6CSqQIcKqgadppE5lrxgWXJmXd7zZJw==}+ dependencies:+ '@types/unist': 3.0.0+ unist-util-stringify-position: 4.0.0+ vfile-message: 4.0.2+ dev: false+/[email protected](@types/[email protected]):resolution: {integrity: sha512-nlBMJ9x6n7/Amaz6F3zJ97EBwR2FkzhBRxF5e+jE6LA3yi6Wtc2lyTij1OnDMIr34v5g/tVQtsVAzhT0jc5ygA==}engines: {node: '>=v14.18.0'}@@ -12356,7 +12532,7 @@ packages:postcss: 8.4.31rollup: 3.28.1optionalDependencies:- fsevents: 2.3.2+ fsevents: 2.3.3dev: true