From f72b7f2f560f1c025d63cef4f7f10c3030e35580 Mon Sep 17 00:00:00 2001 From: Simon Cambier Date: Sat, 25 Nov 2023 08:36:59 +0100 Subject: [PATCH] Cleaning --- src/routes/+page.svelte | 3 ++- src/routes/editor/+page.svelte | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index e1f786e..cd833cb 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -28,7 +28,8 @@ onMount(async () => { let lang = getLangFromUrl() - lang = lang === 'mrwn' || lang === 'gflm' ? 'md' : lang // back compatiblity with old links + // Remove github flavored markdown, redundant with markdown + lang = lang === 'gflm' ? 'md' : lang // extract the part in the url after the hash const hash = window.location.hash.slice(1) diff --git a/src/routes/editor/+page.svelte b/src/routes/editor/+page.svelte index 81147ef..a332458 100644 --- a/src/routes/editor/+page.svelte +++ b/src/routes/editor/+page.svelte @@ -18,7 +18,8 @@ if (editor) { const url = new URL(window.location.origin) compressed = await brotli.compress(editor.getValue()) - if ($selectedLang) { + // Set the language (ignore for plain text, since it's the default) + if ($selectedLang && $selectedLang !== 'plt') { url.searchParams.set('l', $selectedLang) } url.hash = compressed @@ -32,6 +33,8 @@ }, 1000) async function initCodeEditor() { + $selectedLang = new URLSearchParams(window.location.search).get('l') ?? ' plt' + CodeMirror.modeURL = 'https://cdn.jsdelivr.net/npm/codemirror@5.65.16/mode/%N/%N.js' editor = new CodeMirror(byId('editor'), { lineNumbers: true, @@ -64,7 +67,6 @@ } } - $selectedLang = new URLSearchParams(window.location.search).get('l') ?? ' plt' }