Added GFLM features + removed it from the languages list

This commit is contained in:
2023-11-23 22:18:32 +01:00
parent 1a8e667944
commit 2809dc6295
4 changed files with 221 additions and 8 deletions
+10 -6
View File
@@ -36,15 +36,19 @@
}
onMount(() => {
languages = CodeMirror.modeInfo.map((e: any) => ({
text: e.name,
value: shorten(e.name),
data: { mime: e.mime, mode: e.mode },
}))
languages = CodeMirror.modeInfo
.map((e: any) => ({
text: e.name,
value: shorten(e.name),
data: { mime: e.mime, mode: e.mode },
}))
.filter((l: any) => l.value !== 'gflm') // Remove github flavored markdown, redundant with markdown
console.log(languages)
})
export function setLanguage(lang: string) {
if (lang === 'mrwn') { // back compatiblity with old links
if (lang === 'mrwn' || lang === 'gflm') {
// back compatiblity with old links
lang = 'md'
}
const language = languages.find((e) => e.value === lang)!
+3 -2
View File
@@ -5,6 +5,7 @@
import { unified } from 'unified'
import remarkParse from 'remark-parse'
import remarkRehype from 'remark-rehype'
import remarkGfm from 'remark-gfm'
import rehypeHighlight from 'rehype-highlight'
import rehypeStringify from 'rehype-stringify'
import hljs from 'highlight.js'
@@ -16,7 +17,7 @@
onMount(async () => {
let lang = new URLSearchParams(window.location.search).get('l')
lang = lang === 'mrwn' ? 'md' : lang // back compatiblity with old links
lang = lang === 'mrwn' || lang === 'gflm' ? 'md' : lang // back compatiblity with old links
// extract the part in the url after the hash
const hash = window.location.hash.slice(1)
@@ -32,6 +33,7 @@
if (lang === 'md' || lang === 'gflm') {
const html = await unified()
.use(remarkParse)
.use(remarkGfm)
.use(remarkRehype)
.use(rehypeHighlight)
.use(rehypeStringify)
@@ -55,7 +57,6 @@
</script>
<div>
<div class="prose dark:prose-invert lg:py-12 p-[0.5em] md:max-w-3xl md:mx-auto lg:max-w-4xl">
{#if isMarkdown}
{@html decompressed}