fix indent, add H1 title parsing

This commit is contained in:
Maxime Cannoodt 2022-07-04 21:08:56 +02:00
parent 5a370900fc
commit 112c0e6f08
3 changed files with 18 additions and 1 deletions

View File

@ -15,20 +15,30 @@
import ListItem from '$lib/marked/renderers/ListItem.svelte';
export let plaintext: string;
let ref: HTMLDivElement;
// @ts-ignore: typing mismatch
marked.use({ extensions: extensions });
const options = { ...marked.defaults, breaks: true };
function setTitle() {
const res = ref.querySelector('h1');
if (res) {
document.title = res.innerText;
}
}
</script>
<div
bind:this={ref}
id="md-box"
class="prose prose-zinc dark:prose-invert max-w-none prose-li:my-0 prose-ul:mt-0 prose-ol:mt-0 leading-7
prose-strong:font-bold prose-a:font-normal prose-blockquote:font-normal prose-blockquote:not-italic
prose-blockquote:first:before:content-[''] prose-hr:transition-colors"
>
<SvelteMarkdown
on:parsed={setTitle}
renderers={{
heading: Heading,
list: List,

View File

@ -1,4 +1,4 @@
<pre
class="whitespace-pre-wrap text-black dark:text-white bg-zinc-100 dark:bg-zinc-900 py-3 px-6 border dark:border-zinc-700 mt-4">
class="whitespace-pre-line text-black dark:text-white bg-zinc-100 dark:bg-zinc-900 py-3 px-6 border dark:border-zinc-700 mt-4">
<slot />
</pre>

View File

@ -70,6 +70,13 @@
}
</script>
<svelte:head>
<title>{import.meta.env.VITE_BRANDING} | Shared note</title>
{#if decryptFailed}
<title>{import.meta.env.VITE_BRANDING} | Error decrypting note</title>
{/if}
</svelte:head>
{#if plaintext}
<div class="max-w-2xl mx-auto">
<p class="mb-4 text-sm flex justify-between text-zinc-500 dark:text-zinc-400">