Skip to content

Commit

Permalink
Added TL support
Browse files Browse the repository at this point in the history
  • Loading branch information
FrayxRulez committed Nov 20, 2023
1 parent 2478423 commit c84ef66
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
42 changes: 42 additions & 0 deletions components/prism-tl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Prism.languages.tl = {
'builtin': [
/---(functions|types)---/,
{
pattern: /([^a-z0-9_])#/,
lookbehind: true,
greedy: true
},
{
pattern: /(\w*:)(#|flags\.\d*\?)/,
lookbehind: true,
greedy: true
}
],
'comment': [
{
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
lookbehind: true,
greedy: true
},
{
pattern: /(^|[^\\:])\/\/.*/,
lookbehind: true,
greedy: true
}
],
'function': {
pattern: /(:(flags\d?\.\d+\?)?)([a-zA-Z0-9_!<>]+)/,
lookbehind: true,
greedy: true
},
'punctuation': /[{}[\];]/,
'operator': /[:=]/,
'entity': /#[a-fA-F0-9]+/,
'class-name': {
pattern: /(\s*=\s*)(.*);/,
lookbehind: true,
greedy: true
},
};

Prism.languages.typelanguage = Prism.languages.tl;
14 changes: 13 additions & 1 deletion generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const include = function (src) {
(1, eval)(src.toString())
}


async function loadScript(src) {
const script = await fetch(src)
const text = await script.text()
Expand Down Expand Up @@ -44,6 +43,15 @@ async function loadLanguage(lng) {
}
}

function loadLocalLanguage(path, code, title, alias) {
include(fs.readFileSync(path))

components.languages[code] = {
title: title,
alias: alias
}
}

function unique(a, fn) {
if (a.length === 0 || a.length === 1) {
return a;
Expand Down Expand Up @@ -212,6 +220,10 @@ async function generate() {
await loadLanguages(Object.keys(components.languages))
console.log(`\nLoaded all ${langNumber} languages`)
console.log("Processing...")

// Manually add local definitions
loadLocalLanguage('./components/prism-tl.js', 'typelanguage', 'TypeLanguage', 'tl')

Object.keys(Prism.languages).forEach(lng => {
if (unsupported.includes(lng) || !components.languages[lng]) {
return
Expand Down

0 comments on commit c84ef66

Please sign in to comment.