fix: fix some markdown rendering bugs (closes #46)

This commit is contained in:
Sam 2023-04-03 23:32:34 +02:00
parent 691711d542
commit 033b9b5904
No known key found for this signature in database
GPG Key ID: B4EF20DDE721CAA1
5 changed files with 30 additions and 25 deletions

View File

@ -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;

View File

@ -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) {

View File

@ -457,12 +457,15 @@
>.
</p>
<hr />
<Card>
<CardHeader>Preview</CardHeader>
<CardBody>
{@html renderMarkdown(bio)}
</CardBody>
</Card>
{#if bio}
<hr />
<Card>
<CardHeader>Preview</CardHeader>
<CardBody>
{@html renderMarkdown(bio)}
</CardBody>
</Card>
{/if}
</div>
</TabPane>
<TabPane tabId="pronouns" tab="Pronouns">

View File

@ -384,13 +384,15 @@
rel="noopener noreferrer">Markdown</a
>.
</p>
<hr />
<Card>
<CardHeader>Preview</CardHeader>
<CardBody>
{@html renderMarkdown(bio)}
</CardBody>
</Card>
{#if bio}
<hr />
<Card>
<CardHeader>Preview</CardHeader>
<CardBody>
{@html renderMarkdown(bio)}
</CardBody>
</Card>
{/if}
</div>
</TabPane>
<TabPane tabId="pronouns" tab="Pronouns">

View File

@ -56,15 +56,15 @@
>
Authentication
</ListGroupItem>
<!--{#if hasHiddenMembers}-->
<ListGroupItem
tag="a"
active={$page.url.pathname === "/settings/members"}
href="/settings/members"
>
Hidden members
</ListGroupItem>
<!--{/if}-->
{#if hasHiddenMembers}
<ListGroupItem
tag="a"
active={$page.url.pathname === "/settings/members"}
href="/settings/members"
>
Hidden members
</ListGroupItem>
{/if}
{#if data.invitesEnabled}
<ListGroupItem
tag="a"