Fixed deprecations and removed taggerscript

master
Simon Cambier 1 month ago
parent 7f8091120c
commit ed2fd9f45e

@ -12,22 +12,22 @@ export const slugify = (str: string) =>
export const shorten = (name: string) => {
let n = slugify(name).replace('script', '-s').replace('python', 'py').replace('markdown', 'md')
const nov = (s: string) => s[0] + s.substr(1).replace(/[aeiouy-]/g, '')
const nov = (s: string) => s[0] + s.substring(1).replace(/[aeiouy-]/g, '')
if (n.replace(/-/g, '').length <= 4) {
return n.replace(/-/g, '')
}
if (n.split('-').length >= 2) {
return n
.split('-')
.map((x) => nov(x.substr(0, 2)))
.map((x) => nov(x.substring(0, 2)))
.join('')
.substr(0, 4)
.substring(0, 4)
}
n = nov(n)
if (n.length <= 4) {
return n
}
return n.substr(0, 2) + n.substr(n.length - 2, 2)
return n.substring(0, 2) + n.substring(n.length - 2, 2)
}
export function getLangFromUrl() {
@ -41,6 +41,9 @@ export function isInIframe(): boolean {
}
export function getHljsLangFromShort(short: string): string {
const langs = hljs.listLanguages().map((lang) => ({ lang, short: shorten(lang) }))
const langs = hljs
.listLanguages()
.filter((l) => l !== 'taggerscript') // seriously? This overrides typescript.
.map((lang) => ({ lang, short: shorten(lang) }))
return langs.find((l) => l.short === short)?.lang ?? 'plaintext'
}

Loading…
Cancel
Save