Fixed deprecations and removed taggerscript
This commit is contained in:
parent
7f8091120c
commit
ed2fd9f45e
|
@ -12,22 +12,22 @@ export const slugify = (str: string) =>
|
||||||
|
|
||||||
export const shorten = (name: string) => {
|
export const shorten = (name: string) => {
|
||||||
let n = slugify(name).replace('script', '-s').replace('python', 'py').replace('markdown', 'md')
|
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) {
|
if (n.replace(/-/g, '').length <= 4) {
|
||||||
return n.replace(/-/g, '')
|
return n.replace(/-/g, '')
|
||||||
}
|
}
|
||||||
if (n.split('-').length >= 2) {
|
if (n.split('-').length >= 2) {
|
||||||
return n
|
return n
|
||||||
.split('-')
|
.split('-')
|
||||||
.map((x) => nov(x.substr(0, 2)))
|
.map((x) => nov(x.substring(0, 2)))
|
||||||
.join('')
|
.join('')
|
||||||
.substr(0, 4)
|
.substring(0, 4)
|
||||||
}
|
}
|
||||||
n = nov(n)
|
n = nov(n)
|
||||||
if (n.length <= 4) {
|
if (n.length <= 4) {
|
||||||
return n
|
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() {
|
export function getLangFromUrl() {
|
||||||
|
@ -41,6 +41,9 @@ export function isInIframe(): boolean {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getHljsLangFromShort(short: string): string {
|
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'
|
return langs.find((l) => l.short === short)?.lang ?? 'plaintext'
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user