diff --git a/package.json b/package.json index 6093281..49bf002 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ }, "dependencies": { "chroma.ts": "^1.0.10", + "dompurify": "^3.3.0", "marked": "^16.4.2", "nuxt": "^3.21.6", "vue": "^3.5.34", @@ -21,6 +22,7 @@ "@nuxt/image": "1.10.0", "@nuxtjs/mdc": "^0.17.4", "@nuxtjs/tailwindcss": "^6.14.0", + "@types/dompurify": "^3.0.5", "prettier": "3.6.2", "prettier-plugin-tailwindcss": "0.6.13", "sass-embedded": "^1.99.0" diff --git a/src/app.vue b/src/app.vue index 14ac760..550a9fb 100644 --- a/src/app.vue +++ b/src/app.vue @@ -18,7 +18,7 @@ else API.Logout(); -
+ \ No newline at end of file diff --git a/src/components/markdown/viewer.vue b/src/components/markdown/viewer.vue new file mode 100644 index 0000000..ea517c6 --- /dev/null +++ b/src/components/markdown/viewer.vue @@ -0,0 +1,231 @@ + + + +{{ loadingPlaceholder }}
+ +{{ placeholder }}
+{{ mapset.description }}
-No description provided.
+{{ map.source }}
@@ -31,4 +30,4 @@ defineProps<{No tags provided.
${lines.join('\n')}`;
+ },
+ blockquote: (block) => {
+ if (filter.isBlocked('blockquote')) return block.text;
+
let content = block.text;
let type = 'tip';
- const matches = [...content.matchAll(Markdown.BlockquoteRegex)];
-
- if (matches.length > 0) {
- const match = matches[0];
- type = match[1];
- content = content.replace(match[0], '').trim();
+ // github style for codeblocks: [!NOTE], [!WARNING], etc
+ const githubAlertMatch = content.match(Markdown.GithubAlertRegex);
+ if (githubAlertMatch) {
+ type = githubAlertMatch[1].toLowerCase();
+ content = content.replace(Markdown.GithubAlertRegex, '').trim();
+ } else {
+ // normal {: .class }
+ const matches = [...content.matchAll(Markdown.BlockquoteRegex)];
+ if (matches.length > 0) {
+ const match = matches[0];
+ type = match[1];
+ content = content.replace(match[0], '').trim();
+ }
}
- return `${label}${content}`; + }, + image: (image) => { + if (filter.isBlocked('img') || !this.isImageAllowed(image.href)) return ''; + + const escapedAlt = image.text.replace(/\"/g, '"'); + const escapedHref = image.href.replace(/\"/g, '"'); + return `
\\s*${placeholder}\\s*<\\/p>|${placeholder}`), final);
+ }
+
// footnote stuff
const matches = [...html.matchAll(Markdown.FootnoteRegex)];
@@ -136,10 +306,15 @@ export default class Markdown {
const raw = m[0];
const num = m[1];
- html = html.replace(raw, `