Skip to content

Commit 9489a09

Browse files
Parse raw HTML where needed
Finally support <img>s in descriptions and <details>s in comments, among others
1 parent ae4fd87 commit 9489a09

File tree

4 files changed

+140
-3
lines changed

4 files changed

+140
-3
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"prettier": "^3.3.3",
3737
"prettier-plugin-svelte": "^3.2.6",
3838
"prettier-plugin-tailwindcss": "^0.6.6",
39+
"rehype-raw": "^7.0.0",
3940
"semver": "^7.6.3",
4041
"shiki": "^1.14.1",
4142
"svelte": "^4.2.19",

pnpm-lock.yaml

Lines changed: 122 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/components/MarkdownRenderer.svelte

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
*/
88
import Markdown, { type Plugin } from "svelte-exmarkdown";
99
import { gfmPlugin } from "svelte-exmarkdown/gfm";
10+
import rehypeRaw from "rehype-raw";
1011
import { cn } from "$lib/utils";
1112
1213
export let markdown: string;
1314
export let inline = false;
15+
export let parseRawHtml = false;
1416
export let additionalPlugins: Plugin[] = [];
1517
1618
let className: string | undefined | null = undefined;
@@ -26,5 +28,12 @@
2628
className
2729
)}
2830
>
29-
<Markdown md={markdown} plugins={[gfmPlugin(), ...additionalPlugins]} />
31+
<Markdown
32+
md={markdown}
33+
plugins={[
34+
gfmPlugin(),
35+
...(parseRawHtml ? [{ rehypePlugin: rehypeRaw }] : []),
36+
...additionalPlugins
37+
]}
38+
/>
3039
</span>

src/routes/[pullOrIssue=poi]/[org]/[repo]/[id=number]/PageRenderer.svelte

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
</Accordion.Trigger>
146146
<!-- Body -->
147147
<Accordion.Content class="mx-auto sm:w-3/4">
148-
<MarkdownRenderer markdown={entity.body} class="max-w-full text-base" />
148+
<MarkdownRenderer markdown={entity.body} parseRawHtml class="max-w-full text-base" />
149149
</Accordion.Content>
150150
</Accordion.Item>
151151
{/each}
@@ -206,6 +206,7 @@
206206
{:then highlighter}
207207
<MarkdownRenderer
208208
markdown={info.body || "_No description provided_"}
209+
parseRawHtml
209210
class="max-w-full"
210211
additionalPlugins={[
211212
{ renderer: { p: BodyRenderer } },
@@ -272,7 +273,11 @@
272273
</div>
273274
<!-- Body -->
274275
<div class="p-4">
275-
<MarkdownRenderer markdown={comment.body || "_Empty comment_"} class="w-full" />
276+
<MarkdownRenderer
277+
markdown={comment.body || "_Empty comment_"}
278+
parseRawHtml
279+
class="w-full"
280+
/>
276281
</div>
277282
</div>
278283
{/each}

0 commit comments

Comments
 (0)