Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions generate.js
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure why the unsupported list is needed, but I suspect that these languages were included in the components.js file but were missing from prismjs@1.29.0.
If that's the case, it would be best to remove the unsupported list.

Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
const fs = require('fs')
const isEqual = require('lodash.isequal')
const Prism = require('prismjs')
const components = require('prismjs/components.js')

global.Prism = Prism

const SCRIPTS = {}
const include = function (src) {
// Some black magic of eval. Load the script from src to global scope. Source: https://stackoverflow.com/a/23699187/17140794
(1, eval)(src.toString())
}

async function loadScript(src) {
const script = await fetch(src)
const text = await script.text()
include(text)
}

async function loadLanguages(lngs) {
if (lngs) {
lngs = Array.isArray(lngs) ? lngs : [lngs];
Expand All @@ -39,7 +37,7 @@ async function loadLanguage(lng) {
console.log(`${langNumber} | Loading ${lng}`);
// TODO: version should probably not be hardcoded

await loadScript(`https://cdn.jsdelivr.net/npm/prismjs@1.29.0/components/prism-${lng}.min.js`)
require(`prismjs/components/prism-${lng}.js`)
}
}

Expand Down Expand Up @@ -215,8 +213,6 @@ async function generate() {
"sparql" // requires turtle
]

await loadScript("https://cdn.jsdelivr.net/npm/prismjs@1.29.0/components/prism-core.min.js")
await loadScript("https://prismjs.com/components.js")
await loadLanguages(Object.keys(components.languages))
console.log(`\nLoaded all ${langNumber} languages`)
console.log("Processing...")
Expand Down
12 changes: 11 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
},
"homepage": "https://github.com/TelegramMessenger/libprisma#readme",
"dependencies": {
"lodash.isequal": "^4.5.0"
"lodash.isequal": "^4.5.0",
"prismjs": "1.29.0"
}
}