From 033b9b5904b4324f9d6cf35d5da69e4c428bd9f6 Mon Sep 17 00:00:00 2001
From: Sam
Date: Mon, 3 Apr 2023 23:32:34 +0200
Subject: [PATCH] fix: fix some markdown rendering bugs (closes #46)
---
frontend/src/lib/utils.ts | 3 ++-
frontend/src/routes/@[username]/+page.svelte | 3 +--
.../src/routes/edit/member/[id]/+page.svelte | 15 +++++++++------
frontend/src/routes/edit/profile/+page.svelte | 16 +++++++++-------
frontend/src/routes/settings/+layout.svelte | 18 +++++++++---------
5 files changed, 30 insertions(+), 25 deletions(-)
diff --git a/frontend/src/lib/utils.ts b/frontend/src/lib/utils.ts
index 2eb0258..276d98a 100644
--- a/frontend/src/lib/utils.ts
+++ b/frontend/src/lib/utils.ts
@@ -4,7 +4,8 @@ import sanitize from "sanitize-html";
const md = new MarkdownIt({
html: false,
breaks: true,
-}).disable(["heading", "link", "table"]);
+ linkify: true,
+}).disable(["heading", "lheading", "link", "table", "blockquote"]);
export function renderMarkdown(src: string | null) {
return src ? sanitize(md.render(src)) : null;
diff --git a/frontend/src/routes/@[username]/+page.svelte b/frontend/src/routes/@[username]/+page.svelte
index 29686c6..00f647f 100644
--- a/frontend/src/routes/@[username]/+page.svelte
+++ b/frontend/src/routes/@[username]/+page.svelte
@@ -12,7 +12,6 @@
ModalFooter,
} from "sveltestrap";
import FieldCard from "$lib/components/FieldCard.svelte";
- import StatusIcon from "$lib/components/StatusIcon.svelte";
import PronounLink from "$lib/components/PronounLink.svelte";
import PartialMemberCard from "$lib/components/PartialMemberCard.svelte";
import FallbackImage from "$lib/components/FallbackImage.svelte";
@@ -44,7 +43,7 @@
let memberPage: number = 0;
let memberSlice: PartialMember[] = [];
$: memberSlice = data.members.slice(memberPage * 20, (memberPage + 1) * 20);
- const totalPages = Math.floor(data.members.length / 20) + 1;
+ const totalPages = Math.ceil(data.members.length / 20);
const prevPage = () => {
if (memberPage === 0) {
diff --git a/frontend/src/routes/edit/member/[id]/+page.svelte b/frontend/src/routes/edit/member/[id]/+page.svelte
index 8c2a508..8b9cba6 100644
--- a/frontend/src/routes/edit/member/[id]/+page.svelte
+++ b/frontend/src/routes/edit/member/[id]/+page.svelte
@@ -457,12 +457,15 @@
>.
-
- Preview
-
- {@html renderMarkdown(bio)}
-
-
+ {#if bio}
+
+
+ Preview
+
+ {@html renderMarkdown(bio)}
+
+
+ {/if}
diff --git a/frontend/src/routes/edit/profile/+page.svelte b/frontend/src/routes/edit/profile/+page.svelte
index ea38689..0c9be45 100644
--- a/frontend/src/routes/edit/profile/+page.svelte
+++ b/frontend/src/routes/edit/profile/+page.svelte
@@ -384,13 +384,15 @@
rel="noopener noreferrer">Markdown.
-
-
- Preview
-
- {@html renderMarkdown(bio)}
-
-
+ {#if bio}
+
+
+ Preview
+
+ {@html renderMarkdown(bio)}
+
+
+ {/if}
diff --git a/frontend/src/routes/settings/+layout.svelte b/frontend/src/routes/settings/+layout.svelte
index 6921b22..8e254bd 100644
--- a/frontend/src/routes/settings/+layout.svelte
+++ b/frontend/src/routes/settings/+layout.svelte
@@ -56,15 +56,15 @@
>
Authentication
-
-
- Hidden members
-
-
+ {#if hasHiddenMembers}
+
+ Hidden members
+
+ {/if}
{#if data.invitesEnabled}