Skip to content

Commit a960cd8

Browse files
committed
fix: ensure GFM alerts are rendered correctly when displaying plugin README files
1 parent 56ef547 commit a960cd8

4 files changed

Lines changed: 58 additions & 0 deletions

File tree

deno.lock

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

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"@tauri-apps/plugin-dialog": "^2.6",
3131
"dompurify": "^3.3",
3232
"marked": "^17.0",
33+
"marked-alert": "^2.1",
3334
"marked-base-url": "^1.1",
3435
"phosphor-svelte": "^2.0"
3536
}

src/app.css

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,50 @@ select {
6161
.plugin-readme img {
6262
@apply my-3;
6363
}
64+
65+
.plugin-readme .octicon {
66+
display: inline-block;
67+
fill: currentColor;
68+
vertical-align: text-bottom;
69+
}
70+
.plugin-readme .markdown-alert {
71+
padding: 0 1em;
72+
margin-bottom: 16px;
73+
color: inherit;
74+
border-left: 0.25em solid #444c56;
75+
}
76+
.plugin-readme .markdown-alert-title {
77+
display: inline-flex;
78+
align-items: center;
79+
font-weight: 500;
80+
}
81+
.plugin-readme .markdown-alert-note {
82+
border-left-color: #539bf5;
83+
}
84+
.plugin-readme .markdown-alert-tip {
85+
border-left-color: #57ab5a;
86+
}
87+
.plugin-readme .markdown-alert-important {
88+
border-left-color: #986ee2;
89+
}
90+
.plugin-readme .markdown-alert-warning {
91+
border-left-color: #c69026;
92+
}
93+
.plugin-readme .markdown-alert-caution {
94+
border-left-color: #e5534b;
95+
}
96+
.plugin-readme .markdown-alert-note > .markdown-alert-title {
97+
color: #539bf5;
98+
}
99+
.plugin-readme .markdown-alert-tip > .markdown-alert-title {
100+
color: #57ab5a;
101+
}
102+
.plugin-readme .markdown-alert-important > .markdown-alert-title {
103+
color: #986ee2;
104+
}
105+
.plugin-readme .markdown-alert-warning > .markdown-alert-title {
106+
color: #c69026;
107+
}
108+
.plugin-readme .markdown-alert-caution > .markdown-alert-title {
109+
color: #e5534b;
110+
}

src/components/PluginDetails.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import { invoke } from "@tauri-apps/api/core";
99
import DOMPurify from "dompurify";
1010
import { marked } from "marked";
11+
import markedAlert from "marked-alert";
1112
import { baseUrl } from "marked-base-url";
1213
import { onMount } from "svelte";
1314
@@ -38,6 +39,7 @@
3839
for (const url of urls) {
3940
const response = await fetch(url);
4041
if (response.ok) {
42+
marked.use(markedAlert());
4143
marked.use(baseUrl(url));
4244
return await marked.parse(DOMPurify.sanitize(await response.text()).replace(/<a/g, '<a target="_blank" '));
4345
}

0 commit comments

Comments
 (0)