From d43e9c64b01f0f98620b591f88f416a87407e47c Mon Sep 17 00:00:00 2001 From: RunDevelopment Date: Wed, 24 Jul 2019 12:24:02 +0200 Subject: [PATCH 01/26] First draft: Unified dependency logic --- dependencies.js | 333 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 333 insertions(+) create mode 100644 dependencies.js diff --git a/dependencies.js b/dependencies.js new file mode 100644 index 0000000000..acb05dcda7 --- /dev/null +++ b/dependencies.js @@ -0,0 +1,333 @@ +"use strict"; + +var getLoad = (function () { + + /** + * @typedef {Object} Components + * @typedef {{ meta: Meta & Object } & Object} ComponentCategory + * + * @typedef Meta + * @property {string} path + * @property {string} [link] + * @property {string} [example] + * + * @typedef ComponentEntry + * @property {string} title The title of the component. + * @property {string} [owner] The GitHub user name of the owner. + * @property {boolean} [noCSS=false] Whether the component doesn't have style sheets which should also be loaded. + * @property {string | string[]} [alias] An optional list of aliases for the id of the component. + * @property {Object} [aliasTitles] An optional map from an alias to its title. + * + * Aliases which are not in this map will the get title of the component. + * @property {string | string[]} [require] + * @property {string | string[]} [modify] + * @property {string | string[]} [after] + */ + + + /** + * A function which does absolutely nothing. + * + * @type {any} + */ + var noop = function () { }; + + /** + * + * @param {null | undefined | T | T[]} value + * @returns {T[]} + * @template T + */ + function toArray(value) { + if (Array.isArray(value)) { + return value; + } else { + return value == null ? [] : [value]; + } + } + + /** + * Returns a new set for the given string array. + * + * @param {string[]} array + * @returns {StringSet} + * @typedef {Object} StringSet + */ + function toSet(array) { + /** @type {StringSet} */ + var set = {}; + for (var i = 0, l = array.length; i < l; i++) { + set[array[i]] = true; + } + return set; + } + + /** + * + * @param {Components} components + * @param {string} id + * @returns {ComponentEntry} + */ + function getEntry(components, id) { + for (var categoryName in components) { + var category = components[categoryName]; + for (var entryId in category) { + if (entryId === id) { + return category[entryId]; + } + } + } + } + + /** + * Creates a full dependencies map which includes all types of dependencies and their transitive dependencies. + * + * @param {Components} components + * @returns {DependencyMap} + * @typedef {Object} DependencyMap + */ + function createDependencyMap(components) { + /** @type {DependencyMap} */ + var map = {}; + + /** + * + * @param {string} id + * @param {ComponentEntry} [entry] + */ + function addToMap(id, entry) { + if (id in map) { + return; + } + + if (entry == undefined) { + entry = getEntry(components, id); + } + + /** @type {StringSet} */ + var dependencies = {}; + + [].concat(entry.require, entry.modify, entry.after).filter(Boolean).forEach(function (depId) { + addToMap(depId); + dependencies[depId] = true; + for (var transitiveDepId in map[depId]) { + dependencies[transitiveDepId] = true; + } + }); + + map[id] = dependencies; + } + + for (var categoryName in components) { + var category = components[categoryName]; + for (var id in category) { + if (id === 'meta') { + continue; + } else { + addToMap(id, category[id]); + } + } + } + + return map; + } + + /** + * + * @param {DependencyMap} dependencyMap + * @param {StringSet} ids + * @param {(id: string) => T} loadComponent + * @param {(before: T, after: T) => T} series + * @param {(values: T[]) => T} parallel + * @returns {T} + * @template T + */ + function loadDAG(dependencyMap, ids, loadComponent, series, parallel) { + /** @type {Object} */ + var cache = {}; + + /** + * A set of ids of nodes which are not depended upon by any other node in the graph. + * @type {StringSet} + */ + var ends = {}; + + /** + * Loads the given component and its dependencies or returns the cached value. + * + * @param {string} id + * @returns {T} + */ + function handleId(id) { + if (id in cache) { + return cache[id]; + } + + // assume that it's an end + // if it isn't, it will be removed later + ends[id] = true; + + // all dependencies of the component in the given ids + var dependsOn = []; + for (var depId in dependencyMap[id]) { + if (depId in ids) { + dependsOn.push(depId); + } + } + + /** + * The value to be returned. + * @type {T} + */ + var value; + + if (dependsOn.length === 0) { + value = loadComponent(id); + } else { + var depsValue = parallel(dependsOn.map(function (depId) { + var value = handleId(depId); + // none of the dependencies can be ends + delete ends[depId]; + return value; + })); + value = series(depsValue, loadComponent(id)); + } + + // cache and return + return cache[id] = value; + } + + for (var id in ids) { + handleId(id); + } + + /** @type {T[]} */ + var endValues = []; + for (var endId in ends) { + endValues.push(cache[endId]); + } + return parallel(endValues); + } + + /** + * Returns whether the given object has any keys. + * + * @param {object} obj + */ + function hasKeys(obj) { + for (var key in obj) { + return true; + } + return false; + } + + /** + * Returns a new array with the ids of the components which have to be loaded. The returns ids can be in any order + * and will be duplicate-free. + * + * The returned ids will be superset of `load`. If some of the returned ids are in `loaded`, the corresponding + * components will have to reloaded. + * + * The ids in `load` and `loaded` may be in any order and can contain duplicates. + * + * @param {Components} components + * @param {string[]} load + * @param {string[]} [loaded=[]] A list of already loaded components. + * + * If a component is in this list, then all of its requirements will also be assumed to be in the list. + */ + function getLoad(components, load, loaded) { + var loadedSet = toSet(loaded || []); + var loadSet = toSet(load); + + // add requirements + + load.forEach(addRequirements); + function addRequirements(id) { + var require = toArray(getEntry(components, id).require); + require.forEach(function (reqId) { + if (!(reqId in loadSet)) { + loadedSet[reqId] = true; + addRequirements(reqId); + } + }); + } + + // add components to reload + + // A component x in `loaded` has to be reloaded if + // 1) a component in `load` modifies x. + // 2) x depends on a component in `load`. + // The above two condition have to be applied until nothing changes anymore. + + var dependencyMap = createDependencyMap(components); + + /** @type {StringSet} */ + var loadAdditions = loadSet; + /** @type {StringSet} */ + var newIds; + while (hasKeys(loadAdditions)) { + newIds = {}; + + // condition 1) + for (var loadId in loadAdditions) { + var modify = toArray(getEntry(components, loadId).modify); + modify.forEach(function (modId) { + if (!(modId in loadedSet)) { + newIds[modId] = true; + } + }); + } + + // condition 2) + for (var loadedId in loadedSet) { + if (!(loadedId in loadSet)) { + for (var depId in dependencyMap[loadedId]) { + if (depId in loadSet) { + newIds[loadedId] = true; + break; + } + } + } + } + + loadAdditions = newIds; + for (var newId in loadAdditions) { + loadSet[newId] = true; + } + } + + // return ids and a method to load them + + return { + ids: Object.keys(loadSet), + /** + * A functional interface to load components. + * + * The `loadComponent` will be called for every component in the order in which they are loaded. + * + * `series` and `parallel` are useful for asynchronous loading and can be thought of as + * `Promise#then` and `Promise.all`. + * + * _Note:_ Even though, both `series` and `parallel` are optional, they have to both defined or both + * undefined together. It's not valid for just one to be defined while the other is undefined. + * + * @param {(id: string) => T} loadComponent + * @param {(before: T, after: T) => T} [series] + * @param {(values: T[]) => T} [parallel] + * @return {T} + * @template T + */ + load: function (loadComponent, series, parallel) { + return loadDAG(dependencyMap, loadSet, loadComponent, series || noop, parallel || noop); + } + }; + } + + return getLoad; + +}()); + +if (typeof module !== 'undefined') { + module.exports = getLoad; +} From b57c3d1709f7412b6666d9d30b5498dae1b0f5e9 Mon Sep 17 00:00:00 2001 From: RunDevelopment Date: Wed, 24 Jul 2019 13:37:09 +0200 Subject: [PATCH 02/26] Fix and test in index.html --- dependencies.js | 51 ++++++++++++++++++++++++++++++++++++++++--------- index.html | 1 + 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/dependencies.js b/dependencies.js index acb05dcda7..f6c60c2add 100644 --- a/dependencies.js +++ b/dependencies.js @@ -4,12 +4,7 @@ var getLoad = (function () { /** * @typedef {Object} Components - * @typedef {{ meta: Meta & Object } & Object} ComponentCategory - * - * @typedef Meta - * @property {string} path - * @property {string} [link] - * @property {string} [example] + * @typedef {{ meta: Object } & Object} ComponentCategory * * @typedef ComponentEntry * @property {string} title The title of the component. @@ -237,6 +232,8 @@ var getLoad = (function () { * If a component is in this list, then all of its requirements will also be assumed to be in the list. */ function getLoad(components, load, loaded) { + debugger; + var loadedSet = toSet(loaded || []); var loadSet = toSet(load); @@ -246,8 +243,8 @@ var getLoad = (function () { function addRequirements(id) { var require = toArray(getEntry(components, id).require); require.forEach(function (reqId) { - if (!(reqId in loadSet)) { - loadedSet[reqId] = true; + if (!(reqId in loadedSet)) { + loadSet[reqId] = true; addRequirements(reqId); } }); @@ -273,7 +270,7 @@ var getLoad = (function () { for (var loadId in loadAdditions) { var modify = toArray(getEntry(components, loadId).modify); modify.forEach(function (modId) { - if (!(modId in loadedSet)) { + if (modId in loadedSet) { newIds[modId] = true; } }); @@ -324,6 +321,42 @@ var getLoad = (function () { }; } + /** @type {Components} */ + window._comp = { + languages: { + "meta": { + "path": "" + }, + "markup": { + "title": "Markup", + "alias": ["html", "xml", "svg", "mathml"], + "aliasTitles": { + "html": "HTML", + "xml": "XML", + "svg": "SVG", + "mathml": "MathML" + }, + }, + "css": { + "title": "CSS", + "modify": "markup" + }, + "clike": { + "title": "C-like", + }, + "javascript": { + "title": "JavaScript", + "require": "clike", + "modify": "markup", + "alias": "js", + }, + } + }; + + console.dir(getLoad(_comp, ['javascript'])); + console.dir(getLoad(_comp, ['javascript'], ['clike', 'markup', 'css'])); + + return getLoad; }()); diff --git a/index.html b/index.html index 62797b18d0..0ec1ae8220 100644 --- a/index.html +++ b/index.html @@ -286,6 +286,7 @@

Credits

+ - + diff --git a/scripts/download.js b/scripts/download.js index b6ed649cf7..06d0e82adb 100644 --- a/scripts/download.js +++ b/scripts/download.js @@ -22,6 +22,21 @@ var treePromise = new Promise(function(resolve) { }); }); +/** + * Converts the given value into an array. + * + * @param {T | T[] | null | undefined} value + * @returns {T[]} + * @template T + */ +function toArray(value) { + if (Array.isArray(value)) { + return value; + } else { + return value == null ? [] : [value]; + } +} + var hstr = window.location.hash.match(/(?:languages|plugins)=[-+\w]+|themes=[-\w]+/g); if (hstr) { hstr.forEach(function(str) { @@ -50,13 +65,8 @@ if (hstr) { } components[category][id].option = 'default'; } - if (components[category][id].require) { - var deps = components[category][id].require; - if (!Array.isArray(deps)) { - deps = [deps]; - } - deps.forEach(makeDefault); - } + + toArray(components[category][id].require).forEach(makeDefault); } } }; @@ -142,9 +152,9 @@ for (var category in components) { noCSS: all[id].noCSS || all.meta.noCSS, noJS: all[id].noJS || all.meta.noJS, enabled: checked, - require: $u.type(all[id].require) === 'string' ? [all[id].require] : all[id].require, - after: $u.type(all[id].after) === 'string' ? [all[id].after] : all[id].after, - peerDependencies: $u.type(all[id].peerDependencies) === 'string' ? [all[id].peerDependencies] : all[id].peerDependencies, + require: toArray(all[id].require), + after: toArray(all[id].after), + modify: toArray(all[id].modify), owner: all[id].owner, files: { minified: { @@ -158,11 +168,9 @@ for (var category in components) { } }; - if (info.require) { - info.require.forEach(function (v) { - dependencies[v] = (dependencies[v] || []).concat(id); - }); - } + info.require.forEach(function (v) { + dependencies[v] = (dependencies[v] || []).concat(id); + }); if (!all[id].noJS && !/\.css$/.test(filepath)) { info.files.minified.paths.push(filepath.replace(/(\.js)?$/, '.min.js')); @@ -446,72 +454,31 @@ function delayedGenerateCode(){ timerId = setTimeout(generateCode, 500); } -function getSortedComponents(components, requireName, sorted) { - if (!sorted) { - sorted = []; - for (var component in components) { - sorted.push(component); - } - } - - var i = 0; - while (i < sorted.length) { - var id = sorted[i]; - var indexOfRequirement = i; - var notNow = false; - for (var requirement in components[id][requireName]) { - indexOfRequirement = sorted.indexOf(components[id][requireName][requirement]); - if (indexOfRequirement > i) { - notNow = true; - break; - } - } - if (notNow) { - var tmp = sorted[i]; - sorted[i] = sorted[indexOfRequirement]; - sorted[indexOfRequirement] = tmp; - } - else { - i++; - } - } - return sorted; -} - -function getSortedComponentsByRequirements(components, afterName) { - var sorted = getSortedComponents(components, afterName); - return getSortedComponents(components, "require", sorted); -} - function generateCode(){ + /** @type {CodePromiseInfo[]} */ var promises = []; var redownload = {}; for (var category in components) { - var all = components[category]; - - // In case if one component requires other, required component should go first. - var sorted = getSortedComponentsByRequirements(all, category === 'languages' ? 'peerDependencies' : 'after'); - - for (var i = 0; i < sorted.length; i++) { - var id = sorted[i]; - - if(id === 'meta') { + for (var id in components[category]) { + if (id === 'meta') { continue; } - var info = all[id]; + var info = components[category][id]; if (info.enabled) { if (category !== 'core') { - redownload[category] = redownload[category] || []; + redownload[category] = redownload[category] || []; redownload[category].push(id); } - info.files[minified? 'minified' : 'dev'].paths.forEach(function (path) { + info.files[minified ? 'minified' : 'dev'].paths.forEach(function (path) { if (cache[path]) { var type = path.match(/\.(\w+)$/)[1]; promises.push({ contentsPromise: cache[path].contentsPromise, + id: id, + category: category, path: path, type: type }); @@ -531,7 +498,7 @@ function generateCode(){ var code = res.code; var errors = res.errors; - if(errors.length) { + if (errors.length) { error.style.display = 'block'; error.innerHTML = ''; $u.element.contents(error, errors); @@ -571,7 +538,50 @@ function generateCode(){ }); } +/** + * Returns a promise of the code of the Prism bundle. + * + * @param {CodePromiseInfo[]} promises + * @returns {Promise<{ code: { js: string, css: string }, errors: HTMLElement[] }>} + * + * @typedef CodePromiseInfo + * @property {Promise} contentsPromise + * @property {string} id + * @property {string} category + * @property {string} path + * @property {string} type + */ function buildCode(promises) { + // sort the promises + + /** @type {CodePromiseInfo[]} */ + var finalPromises = []; + /** @type {Object} */ + var toSortMap = {}; + + promises.forEach(function (p) { + p.contentsPromise = Promise.resolve(p.id); + if (p.category == "core" || p.category == "themes") { + finalPromises.push(p); + } else { + var infos = toSortMap[p.id]; + if (!infos) { + toSortMap[p.id]=infos = []; + } + infos.push(p); + } + }); + + // this assumes that the ids in `toSortMap` are complete under transitive requirements + getLoad(components, Object.keys(toSortMap)).getIds().forEach(function (id) { + if (!toSortMap[id]) { + console.error(id + " not found."); + } + finalPromises.push.apply(finalPromises, toSortMap[id]); + }); + promises = finalPromises; + + // build var i = 0, l = promises.length; var code = {js: '', css: ''}; @@ -603,6 +613,9 @@ function buildCode(promises) { return new Promise(f); } +/** + * @returns {Promise} + */ function getVersion() { return getFileContents('./package.json').then(function (jsonStr) { return JSON.parse(jsonStr).version; From c0759f0b2f7e20291ef5add4805df3f42f085863 Mon Sep 17 00:00:00 2001 From: RunDevelopment Date: Thu, 5 Sep 2019 22:51:41 +0200 Subject: [PATCH 14/26] loadLanguages uses the new dependency logic --- components/index.js | 105 ++++++++++++++++---------------------------- 1 file changed, 37 insertions(+), 68 deletions(-) diff --git a/components/index.js b/components/index.js index fe5940ae1c..42fb4bcf5a 100644 --- a/components/index.js +++ b/components/index.js @@ -1,82 +1,51 @@ -var components = require('../components.js'); -var peerDependentsMap = null; - -function getPeerDependentsMap() { - var peerDependentsMap = {}; - Object.keys(components.languages).forEach(function (language) { - if (language === 'meta') { - return false; - } - if (components.languages[language].peerDependencies) { - var peerDependencies = components.languages[language].peerDependencies; - if (!Array.isArray(peerDependencies)) { - peerDependencies = [peerDependencies]; - } - peerDependencies.forEach(function (peerDependency) { - if (!peerDependentsMap[peerDependency]) { - peerDependentsMap[peerDependency] = []; - } - peerDependentsMap[peerDependency].push(language); - }); - } - }); - return peerDependentsMap; -} - -function getPeerDependents(mainLanguage) { - if (!peerDependentsMap) { - peerDependentsMap = getPeerDependentsMap(); +const components = require('../components.js'); +const getLoad = require('../dependencies'); + + +/** + * The set of all languages which have been loaded using the below function. + * + * @type {Set} + */ +const loadedLanguages = new Set(); + +/** + * Loads the given languages and adds them to the current Prism instance. + * + * @param {string|string[]} languages + * @returns {void} + */ +function loadLanguages(languages) { + if (!Array.isArray(languages)) { + languages = [languages]; } - return peerDependentsMap[mainLanguage] || []; -} -function loadLanguages(arr, withoutDependencies) { - // If no argument is passed, load all components - if (!arr) { - arr = Object.keys(components.languages).filter(function (language) { - return language !== 'meta'; - }); - } - if (arr && !arr.length) { - return; - } + const loaded = [...loadedLanguages]; - if (!Array.isArray(arr)) { - arr = [arr]; + // the user might have loaded languages via some other way or used `prism.js` which already includes some + for (const lang in Prism.languages) { + // type check because there are also some functions in Prism.languages + if (typeof Prism.languages[lang] == 'object') { + loaded.push(lang); + } } - arr.forEach(function (language) { - if (!components.languages[language]) { - console.warn('Language does not exist ' + language); + getLoad(components, languages, loaded).load(lang => { + if (!(lang in components.languages)) { + console.warn('Language does not exist: ' + lang); return; } - // Load dependencies first - if (!withoutDependencies && components.languages[language].require) { - loadLanguages(components.languages[language].require); - } - var pathToLanguage = './prism-' + language; + const pathToLanguage = './prism-' + lang; + + // remove from require cache and from Prism delete require.cache[require.resolve(pathToLanguage)]; - delete Prism.languages[language]; + delete Prism.languages[lang]; + require(pathToLanguage); - // Reload dependents - var dependents = getPeerDependents(language).filter(function (dependent) { - // If dependent language was already loaded, - // we want to reload it. - if (Prism.languages[dependent]) { - delete Prism.languages[dependent]; - return true; - } - return false; - }); - if (dependents.length) { - loadLanguages(dependents, true); - } + loadedLanguages.add(lang); }); } -module.exports = function (arr) { - // Don't expose withoutDependencies - loadLanguages(arr); -}; \ No newline at end of file +module.exports = loadLanguages; From 839591c429d474e0c02faed0a9a1d9bf444df0b4 Mon Sep 17 00:00:00 2001 From: RunDevelopment Date: Thu, 5 Sep 2019 22:52:00 +0200 Subject: [PATCH 15/26] Updated components.json --- components.js | 2 +- components.json | 51 ++++++++++++++++++++++++++++++------------------- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/components.js b/components.js index e07fbace3e..243c46fa2c 100644 --- a/components.js +++ b/components.js @@ -1,2 +1,2 @@ -var components = {"core":{"meta":{"path":"components/prism-core.js","option":"mandatory"},"core":"Core"},"themes":{"meta":{"path":"themes/{id}.css","link":"index.html?theme={id}","exclusive":true},"prism":{"title":"Default","option":"default"},"prism-dark":"Dark","prism-funky":"Funky","prism-okaidia":{"title":"Okaidia","owner":"ocodia"},"prism-twilight":{"title":"Twilight","owner":"remybach"},"prism-coy":{"title":"Coy","owner":"tshedor"},"prism-solarizedlight":{"title":"Solarized Light","owner":"hectormatos2011 "},"prism-tomorrow":{"title":"Tomorrow Night","owner":"Rosey"}},"languages":{"meta":{"path":"components/prism-{id}","noCSS":true,"examplesPath":"examples/prism-{id}","addCheckAll":true},"markup":{"title":"Markup","alias":["html","xml","svg","mathml"],"aliasTitles":{"html":"HTML","xml":"XML","svg":"SVG","mathml":"MathML"},"option":"default"},"css":{"title":"CSS","option":"default","peerDependencies":"markup"},"clike":{"title":"C-like","option":"default","overrideExampleHeader":true},"javascript":{"title":"JavaScript","require":"clike","peerDependencies":"markup","alias":"js","option":"default"},"abap":{"title":"ABAP","owner":"dellagustin"},"abnf":{"title":"Augmented Backus–Naur form","owner":"RunDevelopment"},"actionscript":{"title":"ActionScript","require":"javascript","peerDependencies":"markup","owner":"Golmote"},"ada":{"title":"Ada","owner":"Lucretia"},"apacheconf":{"title":"Apache Configuration","owner":"GuiTeK"},"apl":{"title":"APL","owner":"ngn"},"applescript":{"title":"AppleScript","owner":"Golmote"},"aql":{"title":"AQL","owner":"RunDevelopment"},"arduino":{"title":"Arduino","require":"cpp","owner":"eisbehr-"},"arff":{"title":"ARFF","owner":"Golmote"},"asciidoc":{"alias":"adoc","title":"AsciiDoc","owner":"Golmote"},"asm6502":{"title":"6502 Assembly","owner":"kzurawel"},"aspnet":{"title":"ASP.NET (C#)","require":["markup","csharp"],"owner":"nauzilus"},"autohotkey":{"title":"AutoHotkey","owner":"aviaryan"},"autoit":{"title":"AutoIt","owner":"Golmote"},"bash":{"title":"Bash","alias":"shell","aliasTitles":{"shell":"Shell"},"owner":"zeitgeist87"},"basic":{"title":"BASIC","owner":"Golmote"},"batch":{"title":"Batch","owner":"Golmote"},"bison":{"title":"Bison","require":"c","owner":"Golmote"},"bnf":{"title":"Backus–Naur form","alias":"rbnf","aliasTitles":{"rbnf":"Routing Backus–Naur form"},"owner":"RunDevelopment"},"brainfuck":{"title":"Brainfuck","owner":"Golmote"},"bro":{"title":"Bro","owner":"wayward710"},"c":{"title":"C","require":"clike","owner":"zeitgeist87"},"csharp":{"title":"C#","require":"clike","alias":["cs","dotnet"],"owner":"mvalipour"},"cpp":{"title":"C++","require":"c","owner":"zeitgeist87"},"cil":{"title":"CIL","owner":"sbrl"},"coffeescript":{"title":"CoffeeScript","require":"javascript","alias":"coffee","owner":"R-osey"},"cmake":{"title":"CMake","owner":"mjrogozinski"},"clojure":{"title":"Clojure","owner":"troglotit"},"crystal":{"title":"Crystal","require":"ruby","owner":"MakeNowJust"},"csp":{"title":"Content-Security-Policy","owner":"ScottHelme"},"css-extras":{"title":"CSS Extras","require":"css","owner":"milesj"},"d":{"title":"D","require":"clike","owner":"Golmote"},"dart":{"title":"Dart","require":"clike","owner":"Golmote"},"diff":{"title":"Diff","owner":"uranusjr"},"django":{"title":"Django/Jinja2","require":"markup-templating","alias":"jinja2","owner":"romanvm"},"dns-zone-file":{"title":"DNS zone file","owner":"RunDevelopment","alias":"dns-zone"},"docker":{"title":"Docker","alias":"dockerfile","owner":"JustinBeckwith"},"ebnf":{"title":"Extended Backus–Naur form","owner":"RunDevelopment"},"eiffel":{"title":"Eiffel","owner":"Conaclos"},"ejs":{"title":"EJS","require":["javascript","markup-templating"],"owner":"RunDevelopment"},"elixir":{"title":"Elixir","owner":"Golmote"},"elm":{"title":"Elm","owner":"zwilias"},"erb":{"title":"ERB","require":["ruby","markup-templating"],"owner":"Golmote"},"erlang":{"title":"Erlang","owner":"Golmote"},"fsharp":{"title":"F#","require":"clike","owner":"simonreynolds7"},"firestore-security-rules":{"title":"Firestore security rules","require":"clike","owner":"RunDevelopment"},"flow":{"title":"Flow","require":"javascript","owner":"Golmote"},"fortran":{"title":"Fortran","owner":"Golmote"},"gcode":{"title":"G-code","owner":"RunDevelopment"},"gdscript":{"title":"GDScript","owner":"RunDevelopment"},"gedcom":{"title":"GEDCOM","owner":"Golmote"},"gherkin":{"title":"Gherkin","owner":"hason"},"git":{"title":"Git","owner":"lgiraudel"},"glsl":{"title":"GLSL","require":"clike","owner":"Golmote"},"gml":{"title":"GameMaker Language","alias":"gamemakerlanguage","require":"clike","owner":"LiarOnce"},"go":{"title":"Go","require":"clike","owner":"arnehormann"},"graphql":{"title":"GraphQL","owner":"Golmote"},"groovy":{"title":"Groovy","require":"clike","owner":"robfletcher"},"haml":{"title":"Haml","require":"ruby","peerDependencies":["css","css-extras","coffeescript","erb","javascript","less","markdown","ruby","scss","textile"],"owner":"Golmote"},"handlebars":{"title":"Handlebars","require":"markup-templating","owner":"Golmote"},"haskell":{"title":"Haskell","alias":"hs","owner":"bholst"},"haxe":{"title":"Haxe","require":"clike","owner":"Golmote"},"hcl":{"title":"HCL","owner":"outsideris"},"http":{"title":"HTTP","peerDependencies":["javascript","markup"],"owner":"danielgtaylor"},"hpkp":{"title":"HTTP Public-Key-Pins","owner":"ScottHelme"},"hsts":{"title":"HTTP Strict-Transport-Security","owner":"ScottHelme"},"ichigojam":{"title":"IchigoJam","owner":"BlueCocoa"},"icon":{"title":"Icon","owner":"Golmote"},"inform7":{"title":"Inform 7","owner":"Golmote"},"ini":{"title":"Ini","owner":"aviaryan"},"io":{"title":"Io","owner":"AlesTsurko"},"j":{"title":"J","owner":"Golmote"},"java":{"title":"Java","require":"clike","owner":"sherblot"},"javadoc":{"title":"JavaDoc","require":["markup","java","javadoclike"],"peerDependencies":["scala"],"owner":"RunDevelopment"},"javadoclike":{"title":"JavaDoc-like","peerDependencies":["java","javascript","php"],"owner":"RunDevelopment"},"javastacktrace":{"title":"Java stack trace","owner":"RunDevelopment"},"jolie":{"title":"Jolie","require":"clike","owner":"thesave"},"jq":{"title":"JQ","owner":"RunDevelopment"},"jsdoc":{"title":"JSDoc","require":["javascript","javadoclike"],"peerDependencies":["actionscript","coffeescript"],"owner":"RunDevelopment"},"js-extras":{"title":"JS Extras","require":"javascript","peerDependencies":["actionscript","coffeescript","flow","n4js","typescript"],"owner":"RunDevelopment"},"js-templates":{"title":"JS Templates","require":"javascript","peerDependencies":["css","css-extras","graphql","markdown","markup"],"owner":"RunDevelopment"},"json":{"title":"JSON","owner":"CupOfTea696"},"jsonp":{"title":"JSONP","require":"json","owner":"RunDevelopment"},"json5":{"title":"JSON5","require":"json","owner":"RunDevelopment"},"julia":{"title":"Julia","owner":"cdagnino"},"keyman":{"title":"Keyman","owner":"mcdurdin"},"kotlin":{"title":"Kotlin","require":"clike","owner":"Golmote"},"latex":{"title":"LaTeX","alias":["tex","context"],"aliasTitles":{"tex":"TeX","context":"ConTeXt"},"owner":"japborst"},"less":{"title":"Less","require":"css","peerDependencies":"css-extras","owner":"Golmote"},"lilypond":{"title":"LilyPond","require":"scheme","alias":"ly","owner":"RunDevelopment"},"liquid":{"title":"Liquid","owner":"cinhtau"},"lisp":{"title":"Lisp","alias":["emacs","elisp","emacs-lisp"],"owner":"JuanCaicedo"},"livescript":{"title":"LiveScript","owner":"Golmote"},"lolcode":{"title":"LOLCODE","owner":"Golmote"},"lua":{"title":"Lua","owner":"Golmote"},"makefile":{"title":"Makefile","owner":"Golmote"},"markdown":{"title":"Markdown","require":"markup","alias":"md","owner":"Golmote"},"markup-templating":{"title":"Markup templating","require":"markup","owner":"Golmote"},"matlab":{"title":"MATLAB","owner":"Golmote"},"mel":{"title":"MEL","owner":"Golmote"},"mizar":{"title":"Mizar","owner":"Golmote"},"monkey":{"title":"Monkey","owner":"Golmote"},"n1ql":{"title":"N1QL","owner":"TMWilds"},"n4js":{"title":"N4JS","require":"javascript","peerDependencies":["jsdoc"],"alias":"n4jsd","owner":"bsmith-n4"},"nand2tetris-hdl":{"title":"Nand To Tetris HDL","owner":"stephanmax"},"nasm":{"title":"NASM","owner":"rbmj"},"nginx":{"title":"nginx","owner":"westonganger","require":"clike"},"nim":{"title":"Nim","owner":"Golmote"},"nix":{"title":"Nix","owner":"Golmote"},"nsis":{"title":"NSIS","owner":"idleberg"},"objectivec":{"title":"Objective-C","require":"c","owner":"uranusjr"},"ocaml":{"title":"OCaml","owner":"Golmote"},"opencl":{"title":"OpenCL","require":"cpp","peerDependencies":["c","cpp"],"overrideExampleHeader":true,"owner":"Milania1"},"oz":{"title":"Oz","owner":"Golmote"},"parigp":{"title":"PARI/GP","owner":"Golmote"},"parser":{"title":"Parser","require":"markup","owner":"Golmote"},"pascal":{"title":"Pascal","alias":"objectpascal","aliasTitles":{"objectpascal":"Object Pascal"},"owner":"Golmote"},"pascaligo":{"title":"Pascaligo","owner":"DefinitelyNotAGoat"},"pcaxis":{"title":"PC-Axis","alias":"px","owner":"RunDevelopment"},"perl":{"title":"Perl","owner":"Golmote"},"php":{"title":"PHP","require":["clike","markup-templating"],"owner":"milesj"},"phpdoc":{"title":"PHPDoc","require":["php","javadoclike"],"owner":"RunDevelopment"},"php-extras":{"title":"PHP Extras","require":"php","owner":"milesj"},"plsql":{"title":"PL/SQL","require":"sql","owner":"Golmote"},"powershell":{"title":"PowerShell","owner":"nauzilus"},"processing":{"title":"Processing","require":"clike","owner":"Golmote"},"prolog":{"title":"Prolog","owner":"Golmote"},"properties":{"title":".properties","owner":"Golmote"},"protobuf":{"title":"Protocol Buffers","require":"clike","owner":"just-boris"},"pug":{"title":"Pug","require":["markup","javascript"],"peerDependencies":["coffeescript","ejs","handlebars","less","livescript","markdown","scss","stylus","twig"],"owner":"Golmote"},"puppet":{"title":"Puppet","owner":"Golmote"},"pure":{"title":"Pure","peerDependencies":["c","cpp","fortran"],"owner":"Golmote"},"python":{"title":"Python","alias":"py","owner":"multipetros"},"q":{"title":"Q (kdb+ database)","owner":"Golmote"},"qore":{"title":"Qore","require":"clike","owner":"temnroegg"},"r":{"title":"R","owner":"Golmote"},"jsx":{"title":"React JSX","require":["markup","javascript"],"peerDependencies":["jsdoc","js-extras","js-templates"],"owner":"vkbansal"},"tsx":{"title":"React TSX","require":["jsx","typescript"]},"renpy":{"title":"Ren'py","owner":"HyuchiaDiego"},"reason":{"title":"Reason","require":"clike","owner":"Golmote"},"regex":{"title":"Regex","peerDependencies":["actionscript","coffeescript","flow","javascript","typescript","vala"],"owner":"RunDevelopment"},"rest":{"title":"reST (reStructuredText)","owner":"Golmote"},"rip":{"title":"Rip","owner":"ravinggenius"},"roboconf":{"title":"Roboconf","owner":"Golmote"},"robot-framework":{"title":"Robot Framework","alias":"robot","owner":"RunDevelopment"},"ruby":{"title":"Ruby","require":"clike","alias":"rb","owner":"samflores"},"rust":{"title":"Rust","owner":"Golmote"},"sas":{"title":"SAS","require":"sql","owner":"Golmote"},"sass":{"title":"Sass (Sass)","require":"css","owner":"Golmote"},"scss":{"title":"Sass (Scss)","require":"css","peerDependencies":"css-extras","owner":"MoOx"},"scala":{"title":"Scala","require":"java","owner":"jozic"},"scheme":{"title":"Scheme","owner":"bacchus123"},"shell-session":{"title":"Shell session","require":"bash","owner":"RunDevelopment"},"smalltalk":{"title":"Smalltalk","owner":"Golmote"},"smarty":{"title":"Smarty","require":"markup-templating","owner":"Golmote"},"solidity":{"title":"Solidity (Ethereum)","require":"clike","owner":"glachaud"},"soy":{"title":"Soy (Closure Template)","require":"markup-templating","owner":"Golmote"},"splunk-spl":{"title":"Splunk SPL","owner":"RunDevelopment"},"sql":{"title":"SQL","owner":"multipetros"},"stylus":{"title":"Stylus","owner":"vkbansal"},"swift":{"title":"Swift","require":"clike","owner":"chrischares"},"tap":{"title":"TAP","owner":"isaacs","require":"yaml"},"tcl":{"title":"Tcl","owner":"PeterChaplin"},"textile":{"title":"Textile","require":"markup","peerDependencies":"css","owner":"Golmote"},"toml":{"title":"TOML","owner":"RunDevelopment"},"tt2":{"title":"Template Toolkit 2","require":["clike","markup-templating"],"owner":"gflohr"},"turtle":{"title":"Turtle","alias":["trig"],"aliasTitles":{"trig":"TriG"},"owner":"jakubklimek"},"twig":{"title":"Twig","require":"markup","owner":"brandonkelly"},"typescript":{"title":"TypeScript","require":"javascript","peerDependencies":"js-templates","alias":"ts","owner":"vkbansal"},"t4-cs":{"title":"T4 Text Templates (C#)","require":["t4-templating","csharp"],"alias":"t4","owner":"RunDevelopment"},"t4-vb":{"title":"T4 Text Templates (VB)","require":["t4-templating","visual-basic"],"owner":"RunDevelopment"},"t4-templating":{"title":"T4 templating","owner":"RunDevelopment"},"vala":{"title":"Vala","require":"clike","owner":"TemplarVolk"},"vbnet":{"title":"VB.Net","require":"basic","owner":"Bigsby"},"velocity":{"title":"Velocity","require":"markup","owner":"Golmote"},"verilog":{"title":"Verilog","owner":"a-rey"},"vhdl":{"title":"VHDL","owner":"a-rey"},"vim":{"title":"vim","owner":"westonganger"},"visual-basic":{"title":"Visual Basic","alias":"vb","owner":"Golmote"},"wasm":{"title":"WebAssembly","owner":"Golmote"},"wiki":{"title":"Wiki markup","require":"markup","owner":"Golmote"},"xeora":{"title":"Xeora","require":"markup","alias":"xeoracube","aliasTitles":{"xeoracube":"XeoraCube"},"owner":"freakmaxi"},"xojo":{"title":"Xojo (REALbasic)","owner":"Golmote"},"xquery":{"title":"XQuery","require":"markup","owner":"Golmote"},"yaml":{"title":"YAML","alias":"yml","owner":"hason"},"zig":{"title":"Zig","owner":"RunDevelopment"}},"plugins":{"meta":{"path":"plugins/{id}/prism-{id}","link":"plugins/{id}/"},"line-highlight":"Line Highlight","line-numbers":{"title":"Line Numbers","owner":"kuba-kubula"},"show-invisibles":{"title":"Show Invisibles","after":["autolinker","data-uri-highlight"]},"autolinker":"Autolinker","wpd":"WebPlatform Docs","custom-class":{"title":"Custom Class","owner":"dvkndn","noCSS":true},"file-highlight":{"title":"File Highlight","noCSS":true},"show-language":{"title":"Show Language","owner":"nauzilus","noCSS":true,"require":"toolbar"},"jsonp-highlight":{"title":"JSONP Highlight","noCSS":true,"owner":"nauzilus"},"highlight-keywords":{"title":"Highlight Keywords","owner":"vkbansal","noCSS":true},"remove-initial-line-feed":{"title":"Remove initial line feed","owner":"Golmote","noCSS":true},"inline-color":{"title":"Inline color","require":"css-extras","owner":"RunDevelopment"},"previewers":{"title":"Previewers","require":"css-extras","owner":"Golmote"},"autoloader":{"title":"Autoloader","owner":"Golmote","noCSS":true},"keep-markup":{"title":"Keep Markup","owner":"Golmote","after":"normalize-whitespace","noCSS":true},"command-line":{"title":"Command Line","owner":"chriswells0"},"unescaped-markup":"Unescaped Markup","normalize-whitespace":{"title":"Normalize Whitespace","owner":"zeitgeist87","after":"unescaped-markup","noCSS":true},"data-uri-highlight":{"title":"Data-URI Highlight","owner":"Golmote","noCSS":true},"toolbar":{"title":"Toolbar","owner":"mAAdhaTTah"},"copy-to-clipboard":{"title":"Copy to Clipboard Button","owner":"mAAdhaTTah","require":"toolbar","noCSS":true},"download-button":{"title":"Download Button","owner":"Golmote","require":"toolbar","noCSS":true},"match-braces":{"title":"Match braces","owner":"RunDevelopment"},"diff-highlight":{"title":"Diff Highlight","owner":"RunDevelopment","require":"diff"}}}; +var components = {"core":{"meta":{"path":"components/prism-core.js","option":"mandatory"},"core":"Core"},"themes":{"meta":{"path":"themes/{id}.css","link":"index.html?theme={id}","exclusive":true},"prism":{"title":"Default","option":"default"},"prism-dark":"Dark","prism-funky":"Funky","prism-okaidia":{"title":"Okaidia","owner":"ocodia"},"prism-twilight":{"title":"Twilight","owner":"remybach"},"prism-coy":{"title":"Coy","owner":"tshedor"},"prism-solarizedlight":{"title":"Solarized Light","owner":"hectormatos2011 "},"prism-tomorrow":{"title":"Tomorrow Night","owner":"Rosey"}},"languages":{"meta":{"path":"components/prism-{id}","noCSS":true,"examplesPath":"examples/prism-{id}","addCheckAll":true},"markup":{"title":"Markup","alias":["html","xml","svg","mathml"],"aliasTitles":{"html":"HTML","xml":"XML","svg":"SVG","mathml":"MathML"},"option":"default"},"css":{"title":"CSS","option":"default","modify":"markup"},"clike":{"title":"C-like","option":"default","overrideExampleHeader":true},"javascript":{"title":"JavaScript","require":"clike","modify":"markup","alias":"js","option":"default"},"abap":{"title":"ABAP","owner":"dellagustin"},"abnf":{"title":"Augmented Backus–Naur form","owner":"RunDevelopment"},"actionscript":{"title":"ActionScript","require":"javascript","modify":"markup","owner":"Golmote"},"ada":{"title":"Ada","owner":"Lucretia"},"apacheconf":{"title":"Apache Configuration","owner":"GuiTeK"},"apl":{"title":"APL","owner":"ngn"},"applescript":{"title":"AppleScript","owner":"Golmote"},"aql":{"title":"AQL","owner":"RunDevelopment"},"arduino":{"title":"Arduino","require":"cpp","owner":"eisbehr-"},"arff":{"title":"ARFF","owner":"Golmote"},"asciidoc":{"alias":"adoc","title":"AsciiDoc","owner":"Golmote"},"asm6502":{"title":"6502 Assembly","owner":"kzurawel"},"aspnet":{"title":"ASP.NET (C#)","require":["markup","csharp"],"owner":"nauzilus"},"autohotkey":{"title":"AutoHotkey","owner":"aviaryan"},"autoit":{"title":"AutoIt","owner":"Golmote"},"bash":{"title":"Bash","alias":"shell","aliasTitles":{"shell":"Shell"},"owner":"zeitgeist87"},"basic":{"title":"BASIC","owner":"Golmote"},"batch":{"title":"Batch","owner":"Golmote"},"bison":{"title":"Bison","require":"c","owner":"Golmote"},"bnf":{"title":"Backus–Naur form","alias":"rbnf","aliasTitles":{"rbnf":"Routing Backus–Naur form"},"owner":"RunDevelopment"},"brainfuck":{"title":"Brainfuck","owner":"Golmote"},"bro":{"title":"Bro","owner":"wayward710"},"c":{"title":"C","require":"clike","owner":"zeitgeist87"},"csharp":{"title":"C#","require":"clike","alias":["cs","dotnet"],"owner":"mvalipour"},"cpp":{"title":"C++","require":"c","owner":"zeitgeist87"},"cil":{"title":"CIL","owner":"sbrl"},"coffeescript":{"title":"CoffeeScript","require":"javascript","alias":"coffee","owner":"R-osey"},"cmake":{"title":"CMake","owner":"mjrogozinski"},"clojure":{"title":"Clojure","owner":"troglotit"},"crystal":{"title":"Crystal","require":"ruby","owner":"MakeNowJust"},"csp":{"title":"Content-Security-Policy","owner":"ScottHelme"},"css-extras":{"title":"CSS Extras","require":"css","modify":"css","owner":"milesj"},"d":{"title":"D","require":"clike","owner":"Golmote"},"dart":{"title":"Dart","require":"clike","owner":"Golmote"},"diff":{"title":"Diff","owner":"uranusjr"},"django":{"title":"Django/Jinja2","require":"markup-templating","alias":"jinja2","owner":"romanvm"},"dns-zone-file":{"title":"DNS zone file","owner":"RunDevelopment","alias":"dns-zone"},"docker":{"title":"Docker","alias":"dockerfile","owner":"JustinBeckwith"},"ebnf":{"title":"Extended Backus–Naur form","owner":"RunDevelopment"},"eiffel":{"title":"Eiffel","owner":"Conaclos"},"ejs":{"title":"EJS","require":["javascript","markup-templating"],"owner":"RunDevelopment"},"elixir":{"title":"Elixir","owner":"Golmote"},"elm":{"title":"Elm","owner":"zwilias"},"erb":{"title":"ERB","require":["ruby","markup-templating"],"owner":"Golmote"},"erlang":{"title":"Erlang","owner":"Golmote"},"fsharp":{"title":"F#","require":"clike","owner":"simonreynolds7"},"firestore-security-rules":{"title":"Firestore security rules","require":"clike","owner":"RunDevelopment"},"flow":{"title":"Flow","require":"javascript","owner":"Golmote"},"fortran":{"title":"Fortran","owner":"Golmote"},"gcode":{"title":"G-code","owner":"RunDevelopment"},"gdscript":{"title":"GDScript","owner":"RunDevelopment"},"gedcom":{"title":"GEDCOM","owner":"Golmote"},"gherkin":{"title":"Gherkin","owner":"hason"},"git":{"title":"Git","owner":"lgiraudel"},"glsl":{"title":"GLSL","require":"clike","owner":"Golmote"},"gml":{"title":"GameMaker Language","alias":"gamemakerlanguage","require":"clike","owner":"LiarOnce"},"go":{"title":"Go","require":"clike","owner":"arnehormann"},"graphql":{"title":"GraphQL","owner":"Golmote"},"groovy":{"title":"Groovy","require":"clike","owner":"robfletcher"},"haml":{"title":"Haml","require":"ruby","after":["css","css-extras","coffeescript","erb","javascript","less","markdown","ruby","scss","textile"],"owner":"Golmote"},"handlebars":{"title":"Handlebars","require":"markup-templating","owner":"Golmote"},"haskell":{"title":"Haskell","alias":"hs","owner":"bholst"},"haxe":{"title":"Haxe","require":"clike","owner":"Golmote"},"hcl":{"title":"HCL","owner":"outsideris"},"http":{"title":"HTTP","after":["css","javascript","json","markup"],"owner":"danielgtaylor"},"hpkp":{"title":"HTTP Public-Key-Pins","owner":"ScottHelme"},"hsts":{"title":"HTTP Strict-Transport-Security","owner":"ScottHelme"},"ichigojam":{"title":"IchigoJam","owner":"BlueCocoa"},"icon":{"title":"Icon","owner":"Golmote"},"inform7":{"title":"Inform 7","owner":"Golmote"},"ini":{"title":"Ini","owner":"aviaryan"},"io":{"title":"Io","owner":"AlesTsurko"},"j":{"title":"J","owner":"Golmote"},"java":{"title":"Java","require":"clike","owner":"sherblot"},"javadoc":{"title":"JavaDoc","require":["markup","java","javadoclike"],"modify":["java"],"after":["scala"],"owner":"RunDevelopment"},"javadoclike":{"title":"JavaDoc-like","modify":["java","javascript","php"],"owner":"RunDevelopment"},"javastacktrace":{"title":"Java stack trace","owner":"RunDevelopment"},"jolie":{"title":"Jolie","require":"clike","owner":"thesave"},"jq":{"title":"JQ","owner":"RunDevelopment"},"jsdoc":{"title":"JSDoc","require":["javascript","javadoclike"],"modify":"javascript","after":["actionscript","coffeescript"],"owner":"RunDevelopment"},"js-extras":{"title":"JS Extras","require":"javascript","modify":"javascript","after":["actionscript","coffeescript","flow","n4js","typescript"],"owner":"RunDevelopment"},"js-templates":{"title":"JS Templates","require":"javascript","modify":"javascript","after":["css","css-extras","graphql","markdown","markup"],"owner":"RunDevelopment"},"json":{"title":"JSON","owner":"CupOfTea696"},"jsonp":{"title":"JSONP","require":"json","owner":"RunDevelopment"},"json5":{"title":"JSON5","require":"json","owner":"RunDevelopment"},"julia":{"title":"Julia","owner":"cdagnino"},"keyman":{"title":"Keyman","owner":"mcdurdin"},"kotlin":{"title":"Kotlin","require":"clike","owner":"Golmote"},"latex":{"title":"LaTeX","alias":["tex","context"],"aliasTitles":{"tex":"TeX","context":"ConTeXt"},"owner":"japborst"},"less":{"title":"Less","require":"css","after":"css-extras","owner":"Golmote"},"lilypond":{"title":"LilyPond","require":"scheme","alias":"ly","owner":"RunDevelopment"},"liquid":{"title":"Liquid","owner":"cinhtau"},"lisp":{"title":"Lisp","alias":["emacs","elisp","emacs-lisp"],"owner":"JuanCaicedo"},"livescript":{"title":"LiveScript","owner":"Golmote"},"lolcode":{"title":"LOLCODE","owner":"Golmote"},"lua":{"title":"Lua","owner":"Golmote"},"makefile":{"title":"Makefile","owner":"Golmote"},"markdown":{"title":"Markdown","require":"markup","alias":"md","owner":"Golmote"},"markup-templating":{"title":"Markup templating","require":"markup","owner":"Golmote"},"matlab":{"title":"MATLAB","owner":"Golmote"},"mel":{"title":"MEL","owner":"Golmote"},"mizar":{"title":"Mizar","owner":"Golmote"},"monkey":{"title":"Monkey","owner":"Golmote"},"n1ql":{"title":"N1QL","owner":"TMWilds"},"n4js":{"title":"N4JS","require":"javascript","after":["jsdoc"],"alias":"n4jsd","owner":"bsmith-n4"},"nand2tetris-hdl":{"title":"Nand To Tetris HDL","owner":"stephanmax"},"nasm":{"title":"NASM","owner":"rbmj"},"nginx":{"title":"nginx","owner":"westonganger","require":"clike"},"nim":{"title":"Nim","owner":"Golmote"},"nix":{"title":"Nix","owner":"Golmote"},"nsis":{"title":"NSIS","owner":"idleberg"},"objectivec":{"title":"Objective-C","require":"c","owner":"uranusjr"},"ocaml":{"title":"OCaml","owner":"Golmote"},"opencl":{"title":"OpenCL","require":"cpp","modify":["c","cpp"],"overrideExampleHeader":true,"owner":"Milania1"},"oz":{"title":"Oz","owner":"Golmote"},"parigp":{"title":"PARI/GP","owner":"Golmote"},"parser":{"title":"Parser","require":"markup","owner":"Golmote"},"pascal":{"title":"Pascal","alias":"objectpascal","aliasTitles":{"objectpascal":"Object Pascal"},"owner":"Golmote"},"pascaligo":{"title":"Pascaligo","owner":"DefinitelyNotAGoat"},"pcaxis":{"title":"PC-Axis","alias":"px","owner":"RunDevelopment"},"perl":{"title":"Perl","owner":"Golmote"},"php":{"title":"PHP","require":["clike","markup-templating"],"owner":"milesj"},"phpdoc":{"title":"PHPDoc","require":["php","javadoclike"],"modify":"php","owner":"RunDevelopment"},"php-extras":{"title":"PHP Extras","require":"php","modify":"php","owner":"milesj"},"plsql":{"title":"PL/SQL","require":"sql","owner":"Golmote"},"powershell":{"title":"PowerShell","owner":"nauzilus"},"processing":{"title":"Processing","require":"clike","owner":"Golmote"},"prolog":{"title":"Prolog","owner":"Golmote"},"properties":{"title":".properties","owner":"Golmote"},"protobuf":{"title":"Protocol Buffers","require":"clike","owner":"just-boris"},"pug":{"title":"Pug","require":["markup","javascript"],"after":["coffeescript","ejs","handlebars","less","livescript","markdown","scss","stylus","twig"],"owner":"Golmote"},"puppet":{"title":"Puppet","owner":"Golmote"},"pure":{"title":"Pure","after":["c","cpp","fortran"],"owner":"Golmote"},"python":{"title":"Python","alias":"py","owner":"multipetros"},"q":{"title":"Q (kdb+ database)","owner":"Golmote"},"qore":{"title":"Qore","require":"clike","owner":"temnroegg"},"r":{"title":"R","owner":"Golmote"},"jsx":{"title":"React JSX","require":["markup","javascript"],"after":["jsdoc","js-extras","js-templates"],"owner":"vkbansal"},"tsx":{"title":"React TSX","require":["jsx","typescript"]},"renpy":{"title":"Ren'py","owner":"HyuchiaDiego"},"reason":{"title":"Reason","require":"clike","owner":"Golmote"},"regex":{"title":"Regex","modify":["actionscript","coffeescript","flow","javascript","typescript","vala"],"owner":"RunDevelopment"},"rest":{"title":"reST (reStructuredText)","owner":"Golmote"},"rip":{"title":"Rip","owner":"ravinggenius"},"roboconf":{"title":"Roboconf","owner":"Golmote"},"robot-framework":{"title":"Robot Framework","alias":"robot","owner":"RunDevelopment"},"ruby":{"title":"Ruby","require":"clike","alias":"rb","owner":"samflores"},"rust":{"title":"Rust","owner":"Golmote"},"sas":{"title":"SAS","require":"sql","owner":"Golmote"},"sass":{"title":"Sass (Sass)","require":"css","owner":"Golmote"},"scss":{"title":"Sass (Scss)","require":"css","after":"css-extras","owner":"MoOx"},"scala":{"title":"Scala","require":"java","owner":"jozic"},"scheme":{"title":"Scheme","owner":"bacchus123"},"shell-session":{"title":"Shell session","require":"bash","owner":"RunDevelopment"},"smalltalk":{"title":"Smalltalk","owner":"Golmote"},"smarty":{"title":"Smarty","require":"markup-templating","owner":"Golmote"},"solidity":{"title":"Solidity (Ethereum)","require":"clike","owner":"glachaud"},"soy":{"title":"Soy (Closure Template)","require":"markup-templating","owner":"Golmote"},"splunk-spl":{"title":"Splunk SPL","owner":"RunDevelopment"},"sql":{"title":"SQL","owner":"multipetros"},"stylus":{"title":"Stylus","owner":"vkbansal"},"swift":{"title":"Swift","require":"clike","owner":"chrischares"},"tap":{"title":"TAP","owner":"isaacs","require":"yaml"},"tcl":{"title":"Tcl","owner":"PeterChaplin"},"textile":{"title":"Textile","require":"markup","after":"css","owner":"Golmote"},"toml":{"title":"TOML","owner":"RunDevelopment"},"tt2":{"title":"Template Toolkit 2","require":["clike","markup-templating"],"owner":"gflohr"},"turtle":{"title":"Turtle","alias":["trig"],"aliasTitles":{"trig":"TriG"},"owner":"jakubklimek"},"twig":{"title":"Twig","require":"markup","owner":"brandonkelly"},"typescript":{"title":"TypeScript","require":"javascript","after":"js-templates","alias":"ts","owner":"vkbansal"},"t4-cs":{"title":"T4 Text Templates (C#)","require":["t4-templating","csharp"],"alias":"t4","owner":"RunDevelopment"},"t4-vb":{"title":"T4 Text Templates (VB)","require":["t4-templating","visual-basic"],"owner":"RunDevelopment"},"t4-templating":{"title":"T4 templating","owner":"RunDevelopment"},"vala":{"title":"Vala","require":"clike","owner":"TemplarVolk"},"vbnet":{"title":"VB.Net","require":"basic","owner":"Bigsby"},"velocity":{"title":"Velocity","require":"markup","owner":"Golmote"},"verilog":{"title":"Verilog","owner":"a-rey"},"vhdl":{"title":"VHDL","owner":"a-rey"},"vim":{"title":"vim","owner":"westonganger"},"visual-basic":{"title":"Visual Basic","alias":"vb","owner":"Golmote"},"wasm":{"title":"WebAssembly","owner":"Golmote"},"wiki":{"title":"Wiki markup","require":"markup","owner":"Golmote"},"xeora":{"title":"Xeora","require":"markup","alias":"xeoracube","aliasTitles":{"xeoracube":"XeoraCube"},"owner":"freakmaxi"},"xojo":{"title":"Xojo (REALbasic)","owner":"Golmote"},"xquery":{"title":"XQuery","require":"markup","owner":"Golmote"},"yaml":{"title":"YAML","alias":"yml","owner":"hason"},"zig":{"title":"Zig","owner":"RunDevelopment"}},"plugins":{"meta":{"path":"plugins/{id}/prism-{id}","link":"plugins/{id}/"},"line-highlight":"Line Highlight","line-numbers":{"title":"Line Numbers","owner":"kuba-kubula"},"show-invisibles":{"title":"Show Invisibles","after":["autolinker","data-uri-highlight"]},"autolinker":"Autolinker","wpd":"WebPlatform Docs","custom-class":{"title":"Custom Class","owner":"dvkndn","noCSS":true},"file-highlight":{"title":"File Highlight","noCSS":true},"show-language":{"title":"Show Language","owner":"nauzilus","noCSS":true,"require":"toolbar"},"jsonp-highlight":{"title":"JSONP Highlight","noCSS":true,"owner":"nauzilus"},"highlight-keywords":{"title":"Highlight Keywords","owner":"vkbansal","noCSS":true},"remove-initial-line-feed":{"title":"Remove initial line feed","owner":"Golmote","noCSS":true},"inline-color":{"title":"Inline color","require":"css-extras","owner":"RunDevelopment"},"previewers":{"title":"Previewers","require":"css-extras","owner":"Golmote"},"autoloader":{"title":"Autoloader","owner":"Golmote","noCSS":true},"keep-markup":{"title":"Keep Markup","owner":"Golmote","after":"normalize-whitespace","noCSS":true},"command-line":{"title":"Command Line","owner":"chriswells0"},"unescaped-markup":"Unescaped Markup","normalize-whitespace":{"title":"Normalize Whitespace","owner":"zeitgeist87","after":"unescaped-markup","noCSS":true},"data-uri-highlight":{"title":"Data-URI Highlight","owner":"Golmote","noCSS":true},"toolbar":{"title":"Toolbar","owner":"mAAdhaTTah"},"copy-to-clipboard":{"title":"Copy to Clipboard Button","owner":"mAAdhaTTah","require":"toolbar","noCSS":true},"download-button":{"title":"Download Button","owner":"Golmote","require":"toolbar","noCSS":true},"match-braces":{"title":"Match braces","owner":"RunDevelopment"},"diff-highlight":{"title":"Diff Highlight","owner":"RunDevelopment","require":"diff"}}}; if (typeof module !== 'undefined' && module.exports) { module.exports = components; } \ No newline at end of file diff --git a/components.json b/components.json index e5ebcc0647..eca533a1dd 100644 --- a/components.json +++ b/components.json @@ -60,7 +60,7 @@ "css": { "title": "CSS", "option": "default", - "peerDependencies": "markup" + "modify": "markup" }, "clike": { "title": "C-like", @@ -70,7 +70,7 @@ "javascript": { "title": "JavaScript", "require": "clike", - "peerDependencies": "markup", + "modify": "markup", "alias": "js", "option": "default" }, @@ -85,7 +85,7 @@ "actionscript": { "title": "ActionScript", "require": "javascript", - "peerDependencies": "markup", + "modify": "markup", "owner": "Golmote" }, "ada": { @@ -222,6 +222,7 @@ "css-extras": { "title": "CSS Extras", "require": "css", + "modify": "css", "owner": "milesj" }, "d": { @@ -351,7 +352,7 @@ "haml": { "title": "Haml", "require": "ruby", - "peerDependencies": [ + "after": [ "css", "css-extras", "coffeescript", @@ -386,8 +387,10 @@ }, "http": { "title": "HTTP", - "peerDependencies": [ + "after": [ + "css", "javascript", + "json", "markup" ], "owner": "danielgtaylor" @@ -432,14 +435,17 @@ "javadoc": { "title": "JavaDoc", "require": ["markup", "java", "javadoclike"], - "peerDependencies": [ + "modify": [ + "java" + ], + "after": [ "scala" ], "owner": "RunDevelopment" }, "javadoclike": { "title": "JavaDoc-like", - "peerDependencies": [ + "modify": [ "java", "javascript", "php" @@ -462,7 +468,8 @@ "jsdoc": { "title": "JSDoc", "require": ["javascript", "javadoclike"], - "peerDependencies": [ + "modify": "javascript", + "after": [ "actionscript", "coffeescript" ], @@ -471,7 +478,8 @@ "js-extras": { "title": "JS Extras", "require": "javascript", - "peerDependencies": [ + "modify": "javascript", + "after": [ "actionscript", "coffeescript", "flow", @@ -483,7 +491,8 @@ "js-templates": { "title": "JS Templates", "require": "javascript", - "peerDependencies": [ + "modify": "javascript", + "after": [ "css", "css-extras", "graphql", @@ -531,7 +540,7 @@ "less": { "title": "Less", "require": "css", - "peerDependencies": "css-extras", + "after": "css-extras", "owner": "Golmote" }, "lilypond": { @@ -599,7 +608,7 @@ "n4js": { "title": "N4JS", "require": "javascript", - "peerDependencies": [ + "after": [ "jsdoc" ], "alias": "n4jsd", @@ -642,7 +651,7 @@ "opencl": { "title": "OpenCL", "require": "cpp", - "peerDependencies": [ + "modify": [ "c", "cpp" ], @@ -691,11 +700,13 @@ "phpdoc": { "title": "PHPDoc", "require": ["php", "javadoclike"], + "modify": "php", "owner": "RunDevelopment" }, "php-extras": { "title": "PHP Extras", "require": "php", + "modify": "php", "owner": "milesj" }, "plsql": { @@ -728,7 +739,7 @@ "pug": { "title": "Pug", "require": ["markup", "javascript"], - "peerDependencies": [ + "after": [ "coffeescript", "ejs", "handlebars", @@ -747,7 +758,7 @@ }, "pure": { "title": "Pure", - "peerDependencies": [ + "after": [ "c", "cpp", "fortran" @@ -775,7 +786,7 @@ "jsx": { "title": "React JSX", "require": ["markup", "javascript"], - "peerDependencies": [ + "after": [ "jsdoc", "js-extras", "js-templates" @@ -797,7 +808,7 @@ }, "regex": { "title": "Regex", - "peerDependencies": [ + "modify": [ "actionscript", "coffeescript", "flow", @@ -847,7 +858,7 @@ "scss": { "title": "Sass (Scss)", "require": "css", - "peerDependencies": "css-extras", + "after": "css-extras", "owner": "MoOx" }, "scala": { @@ -912,7 +923,7 @@ "textile": { "title": "Textile", "require": "markup", - "peerDependencies": "css", + "after": "css", "owner": "Golmote" }, "toml": { @@ -940,7 +951,7 @@ "typescript": { "title": "TypeScript", "require": "javascript", - "peerDependencies": "js-templates", + "after": "js-templates", "alias": "ts", "owner": "vkbansal" }, From bb12309a16b042b5b0d39af89c2da1421ecbf0b4 Mon Sep 17 00:00:00 2001 From: RunDevelopment Date: Fri, 6 Sep 2019 10:58:09 +0200 Subject: [PATCH 16/26] Added alias check --- dependencies.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dependencies.js b/dependencies.js index 4ce01bec85..406175de9f 100644 --- a/dependencies.js +++ b/dependencies.js @@ -161,6 +161,12 @@ var getLoad = (function () { var entry = entryMap[id]; var aliases = toArray(entry && entry.alias); aliases.forEach(function (alias) { + if (alias in map) { + throw new Error(alias + ' cannot be alias for both ' + id + ' and ' + map[alias]); + } + if (alias in entryMap) { + throw new Error(alias + ' cannot be alias of ' + id + ' because it is a component.'); + } map[alias] = id; }); } From 6d594669561c2434c7b3a44608f6f76b9c12f5ff Mon Sep 17 00:00:00 2001 From: RunDevelopment Date: Fri, 6 Sep 2019 10:58:30 +0200 Subject: [PATCH 17/26] Extended deps test --- tests/dependencies-test.js | 49 +++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/tests/dependencies-test.js b/tests/dependencies-test.js index 0c6453541e..e1d4ae3777 100644 --- a/tests/dependencies-test.js +++ b/tests/dependencies-test.js @@ -1,5 +1,6 @@ const { assert } = require('chai'); const getLoad = require('../dependencies'); +const components = require('../components'); describe('Dependency logic', function () { @@ -7,7 +8,6 @@ describe('Dependency logic', function () { /** @type {import("../dependencies").Components} */ const components = { languages: { - meta: {}, 'a': { alias: 'a2' }, @@ -24,7 +24,6 @@ describe('Dependency logic', function () { }, }, pluginsOrSomething: { - meta: {}, 'e': { modify: 'a' }, @@ -106,6 +105,38 @@ describe('Dependency logic', function () { assert.sameMembers(getIds(['d'], ['a', 'a2', 'b2']), ['c', 'd']); }); + it('- should throw on duplicate aliases', function () { + assert.throws(() => { + /** @type {import("../dependencies").Components} */ + const circular = { + languages: { + a: { + alias: 'c' + }, + b: { + alias: 'c' + } + } + }; + getLoad(circular, ['a']).getIds(); + }); + }); + + it('- should throw on aliases which are components', function () { + assert.throws(() => { + /** @type {import("../dependencies").Components} */ + const circular = { + languages: { + a: { + alias: 'b' + }, + b: "B" + } + }; + getLoad(circular, ['a']).getIds(); + }); + }); + }); describe('Circular dependencies', function () { @@ -119,7 +150,7 @@ describe('Dependency logic', function () { require: 'b' }, b: { - require: 'a' + after: 'a' } } }; @@ -130,3 +161,15 @@ describe('Dependency logic', function () { }); }); + +describe('components.json', function () { + + it('- should be valid', function () { + try { + getLoad(components, Object.keys(components.languages).filter(k => k != 'meta')).getIds(); + } catch (error) { + assert.fail(error.toString()); + } + }); + +}); From 8fcf8b1b61bd8afdda61092fb0e757f565d34b53 Mon Sep 17 00:00:00 2001 From: RunDevelopment Date: Fri, 6 Sep 2019 11:35:35 +0200 Subject: [PATCH 18/26] Test suite uses the new dependency logic --- tests/helper/prism-loader.js | 57 +++++++++++++----------------------- 1 file changed, 20 insertions(+), 37 deletions(-) diff --git a/tests/helper/prism-loader.js b/tests/helper/prism-loader.js index 8ec06e3643..aa09bd84cc 100644 --- a/tests/helper/prism-loader.js +++ b/tests/helper/prism-loader.js @@ -4,9 +4,16 @@ const fs = require("fs"); const vm = require("vm"); const { getAllFiles } = require("./test-discovery"); const components = require("../../components"); +const getLoad = require("../../dependencies"); const languagesCatalog = components.languages; +/** + * @typedef PrismLoaderContext + * @property {any} Prism The Prism instance. + * @property {Set} loaded A set of loaded components. + */ + module.exports = { /** @@ -17,7 +24,7 @@ module.exports = { */ createInstance(languages) { let context = { - loadedLanguages: [], + loaded: new Set(), Prism: this.createEmptyPrism() }; @@ -27,53 +34,29 @@ module.exports = { }, /** - * Loads the given languages and appends the config to the given Prism object + * Loads the given languages and appends the config to the given Prism object. * * @private * @param {string|string[]} languages - * @param {{loadedLanguages: string[], Prism: Prism}} context - * @returns {{loadedLanguages: string[], Prism: Prism}} + * @param {PrismLoaderContext} context + * @returns {PrismLoaderContext} */ loadLanguages(languages, context) { if (typeof languages === 'string') { languages = [languages]; } - for (const language of languages) { - context = this.loadLanguage(language, context); - } - - return context; - }, - - /** - * Loads the given language (including recursively loading the dependencies) and - * appends the config to the given Prism object - * - * @private - * @param {string} language - * @param {{loadedLanguages: string[], Prism: Prism}} context - * @returns {{loadedLanguages: string[], Prism: Prism}} - */ - loadLanguage(language, context) { - if (!languagesCatalog[language]) { - throw new Error("Language '" + language + "' not found."); - } - - // the given language was already loaded - if (-1 < context.loadedLanguages.indexOf(language)) { - return context; - } + getLoad(components, languages, [...context.loaded]).load(id => { + if (!languagesCatalog[id]) { + throw new Error(`Language '${id}' not found.`); + } - // if the language has a dependency -> load it first - if (languagesCatalog[language].require) { - context = this.loadLanguages(languagesCatalog[language].require, context); - } + // load the language itself + const languageSource = this.loadComponentSource(id); + context.Prism = this.runFileWithContext(languageSource, { Prism: context.Prism }).Prism; - // load the language itself - const languageSource = this.loadComponentSource(language); - context.Prism = this.runFileWithContext(languageSource, { Prism: context.Prism }).Prism; - context.loadedLanguages.push(language); + context.loaded.add(id); + }); return context; }, From 946281fafdf62252b3a18e361e13226dad4819ee Mon Sep 17 00:00:00 2001 From: RunDevelopment Date: Fri, 6 Sep 2019 11:52:36 +0200 Subject: [PATCH 19/26] Readded loadLanguages' load all languages behavior --- components/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/components/index.js b/components/index.js index 42fb4bcf5a..82c2a5cd9c 100644 --- a/components/index.js +++ b/components/index.js @@ -12,11 +12,15 @@ const loadedLanguages = new Set(); /** * Loads the given languages and adds them to the current Prism instance. * - * @param {string|string[]} languages + * If no languages are provided, __all__ Prism languages will be loaded. + * + * @param {string|string[]} [languages] * @returns {void} */ function loadLanguages(languages) { - if (!Array.isArray(languages)) { + if (languages === undefined) { + languages = Object.keys(components.languages).filter(l => l != 'meta'); + } else if (!Array.isArray(languages)) { languages = [languages]; } From 15ba68aafa1d008460ba41f6e14affa0efdd2264 Mon Sep 17 00:00:00 2001 From: RunDevelopment Date: Fri, 6 Sep 2019 12:09:26 +0200 Subject: [PATCH 20/26] Added check for unknown dependency ids --- dependencies.js | 4 ++++ tests/dependencies-test.js | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/dependencies.js b/dependencies.js index 406175de9f..0d243d28b7 100644 --- a/dependencies.js +++ b/dependencies.js @@ -127,6 +127,10 @@ var getLoad = (function () { /** @type {string[]} */ var deps = (/** @type {any[]} */([]).concat(entry.require, entry.modify, entry.after).filter(Boolean)); deps.forEach(function (depId) { + if (!(depId in entryMap)) { + throw new Error(id + ' depends on an unknown component ' + depId); + } + addToMap(depId, stack); dependencies[depId] = true; for (var transitiveDepId in map[depId]) { diff --git a/tests/dependencies-test.js b/tests/dependencies-test.js index e1d4ae3777..d6455ffd19 100644 --- a/tests/dependencies-test.js +++ b/tests/dependencies-test.js @@ -67,6 +67,21 @@ describe('Dependency logic', function () { assert.sameMembers(getIds(['c', 'foo'], ['bar']), ['foo', 'c', 'a']); }); + it('- should throw on unknown dependencies', function () { + assert.throws(() => { + /** @type {import("../dependencies").Components} */ + const circular = { + languages: { + a: { + require: 'c' + }, + b: "B" + } + }; + getLoad(circular, ['a']).getIds(); + }); + }); + }); describe('Load order', function () { From 746a4dc8d5931e1859d56410af7da46661f9c89b Mon Sep 17 00:00:00 2001 From: RunDevelopment Date: Fri, 6 Sep 2019 12:17:30 +0200 Subject: [PATCH 21/26] loadLanguages: Removed check for valid ids --- components/index.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/components/index.js b/components/index.js index 82c2a5cd9c..a773762dae 100644 --- a/components/index.js +++ b/components/index.js @@ -24,15 +24,9 @@ function loadLanguages(languages) { languages = [languages]; } - const loaded = [...loadedLanguages]; - // the user might have loaded languages via some other way or used `prism.js` which already includes some - for (const lang in Prism.languages) { - // type check because there are also some functions in Prism.languages - if (typeof Prism.languages[lang] == 'object') { - loaded.push(lang); - } - } + // we don't need to validate the ids because `getLoad` will ignore invalid ones + const loaded = [...loadedLanguages, ...Object.keys(Prism.languages)]; getLoad(components, languages, loaded).load(lang => { if (!(lang in components.languages)) { From 049f8c440c9f11c1c5135c5e35dff2d04fe76b99 Mon Sep 17 00:00:00 2001 From: RunDevelopment Date: Tue, 22 Oct 2019 18:25:13 +0200 Subject: [PATCH 22/26] Removed type hack --- dependencies.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies.js b/dependencies.js index 0d243d28b7..0690ff8736 100644 --- a/dependencies.js +++ b/dependencies.js @@ -125,7 +125,7 @@ var getLoad = (function () { var entry = entryMap[id]; if (entry) { /** @type {string[]} */ - var deps = (/** @type {any[]} */([]).concat(entry.require, entry.modify, entry.after).filter(Boolean)); + var deps = [].concat(entry.require, entry.modify, entry.after).filter(Boolean); deps.forEach(function (depId) { if (!(depId in entryMap)) { throw new Error(id + ' depends on an unknown component ' + depId); From 81e4b0d8adb0f6e6c06175da397417197da9829e Mon Sep 17 00:00:00 2001 From: RunDevelopment Date: Tue, 22 Oct 2019 21:19:03 +0200 Subject: [PATCH 23/26] Fixed async loading and added chainer --- dependencies.js | 34 ++++++++++++------- tests/dependencies-test.js | 67 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 11 deletions(-) diff --git a/dependencies.js b/dependencies.js index 0690ff8736..95d2f9ec27 100644 --- a/dependencies.js +++ b/dependencies.js @@ -180,6 +180,13 @@ var getLoad = (function () { }; } + /** + * @typedef LoadChainer + * @property {(before: T, after: () => T) => T} series + * @property {(values: T[]) => T} parallel + * @template T + */ + /** * Creates an implicit DAG from the given components and dependencies and call the given `loadComponent` for each * component in topological order. @@ -187,12 +194,14 @@ var getLoad = (function () { * @param {DependencyMap} dependencyMap * @param {StringSet} ids * @param {(id: string) => T} loadComponent - * @param {(before: T, after: T) => T} series - * @param {(values: T[]) => T} parallel + * @param {LoadChainer} [chainer] * @returns {T} * @template T */ - function loadComponentsInOrder(dependencyMap, ids, loadComponent, series, parallel) { + function loadComponentsInOrder(dependencyMap, ids, loadComponent, chainer) { + const series = chainer ? chainer.series : undefined; + const parallel = chainer ? chainer.parallel : noop; + /** @type {Object} */ var cache = {}; @@ -240,7 +249,13 @@ var getLoad = (function () { delete ends[depId]; return value; })); - value = series(depsValue, loadComponent(id)); + if (series) { + // the chainer will be responsibly for calling the function calling loadComponent + value = series(depsValue, function () { return loadComponent(id); }); + } else { + // we don't have a chainer, so we call loadComponent ourselves + loadComponent(id); + } } // cache and return @@ -293,17 +308,14 @@ var getLoad = (function () { * The returned ids will be duplicate-free, alias-free and in load order. * @property {LoadFunction} load A functional interface to load components. * - * @typedef { (loadComponent: (id: string) => T, series?: (before: T, after: T) => T, parallel?: (values: T[]) => T) => T} LoadFunction + * @typedef { (loadComponent: (id: string) => T, chainer?: LoadChainer) => T} LoadFunction * A functional interface to load components. * * The `loadComponent` function will be called for every component in the order in which they have to be loaded. * - * `series` and `parallel` are useful for asynchronous loading and can be thought of as + * The `chainer` is useful for asynchronous loading and its `series` and `parallel` functions can be thought of as * `Promise#then` and `Promise.all`. * - * _Note:_ Even though, both `series` and `parallel` are optional, they have to both defined or both - * undefined together. It's not valid for just one to be defined while the other is undefined. - * * @example * load(id => { loadComponent(id); }); // returns undefined * @@ -395,8 +407,8 @@ var getLoad = (function () { }); return ids; }, - load: function (loadComponent, series, parallel) { - return loadComponentsInOrder(dependencyMap, loadSet, loadComponent, series || noop, parallel || noop); + load: function (loadComponent, chainer) { + return loadComponentsInOrder(dependencyMap, loadSet, loadComponent, chainer); } }; diff --git a/tests/dependencies-test.js b/tests/dependencies-test.js index d6455ffd19..b1c7e5c884 100644 --- a/tests/dependencies-test.js +++ b/tests/dependencies-test.js @@ -175,6 +175,73 @@ describe('Dependency logic', function () { }); + describe('Async loading', function () { + + it('- should load components in the correct order', async function () { + + /** @type {import("../dependencies").Components} */ + const localComponents = { + languages: { + 'a': {}, + 'b': { + require: 'a' + }, + 'c': { + require: 'b' + } + } + }; + + /** @type {string[]} */ + const actualLoadOrder = []; + /** @type {string[]} */ + const actualResolveOrder = []; + + /** + * + * @param {string} id + * @returns {Promise} + */ + function loadComp(id) { + actualLoadOrder.push(id); + + // the idea is that the components which have to be loaded first, take the longest, so if all were to + // start getting loaded at the same time, their order would be the reverse of the expected order. + let delay; + if (id === 'a') { + delay = 30; + } else if (id === 'b') { + delay = 20; + } else if (id === 'c') { + delay = 10; + } + + return new Promise((resolve) => { + setTimeout(() => { + actualResolveOrder.push(id); + resolve(); + }, delay); + }); + } + + const result = getLoad(localComponents, ['c']); + + await result.load(id => loadComp(id), { + series: async (before, after) => { + await before; + await after(); + }, + parallel: async (values) => { + await Promise.all(values); + } + }); + + assert.deepStrictEqual(actualLoadOrder, ['a', 'b', 'c'], `actualLoadOrder:`); + assert.deepStrictEqual(actualResolveOrder, ['a', 'b', 'c'], `actualResolveOrder:`); + }); + + }); + }); describe('components.json', function () { From 4ce06aa9d77a29cc89191087d8c291fc5a3cb5ac Mon Sep 17 00:00:00 2001 From: RunDevelopment Date: Tue, 22 Oct 2019 21:52:23 +0200 Subject: [PATCH 24/26] String quote style --- tests/dependencies-test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/dependencies-test.js b/tests/dependencies-test.js index b1c7e5c884..483d693dd5 100644 --- a/tests/dependencies-test.js +++ b/tests/dependencies-test.js @@ -75,7 +75,7 @@ describe('Dependency logic', function () { a: { require: 'c' }, - b: "B" + b: 'B' } }; getLoad(circular, ['a']).getIds(); @@ -145,7 +145,7 @@ describe('Dependency logic', function () { a: { alias: 'b' }, - b: "B" + b: 'B' } }; getLoad(circular, ['a']).getIds(); @@ -236,8 +236,8 @@ describe('Dependency logic', function () { } }); - assert.deepStrictEqual(actualLoadOrder, ['a', 'b', 'c'], `actualLoadOrder:`); - assert.deepStrictEqual(actualResolveOrder, ['a', 'b', 'c'], `actualResolveOrder:`); + assert.deepStrictEqual(actualLoadOrder, ['a', 'b', 'c'], 'actualLoadOrder:'); + assert.deepStrictEqual(actualResolveOrder, ['a', 'b', 'c'], 'actualResolveOrder:'); }); }); From 5275691004763be7037f250d310ce345110f8344 Mon Sep 17 00:00:00 2001 From: RunDevelopment Date: Sun, 15 Dec 2019 21:18:33 +0100 Subject: [PATCH 25/26] =?UTF-8?q?after=20=E2=86=92=20optional=20and=20some?= =?UTF-8?q?=20other=20renaming?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components.js | 2 +- components.json | 34 +++++++++++++++++----------------- components/index.js | 6 +++--- dependencies.js | 35 +++++++++++++++++++++-------------- scripts/download.js | 2 +- tests/dependencies-test.js | 30 +++++++++++++++--------------- tests/helper/prism-loader.js | 4 ++-- 7 files changed, 60 insertions(+), 53 deletions(-) diff --git a/components.js b/components.js index 527ab5e93f..dd554dcde9 100644 --- a/components.js +++ b/components.js @@ -1,2 +1,2 @@ -var components = {"core":{"meta":{"path":"components/prism-core.js","option":"mandatory"},"core":"Core"},"themes":{"meta":{"path":"themes/{id}.css","link":"index.html?theme={id}","exclusive":true},"prism":{"title":"Default","option":"default"},"prism-dark":"Dark","prism-funky":"Funky","prism-okaidia":{"title":"Okaidia","owner":"ocodia"},"prism-twilight":{"title":"Twilight","owner":"remybach"},"prism-coy":{"title":"Coy","owner":"tshedor"},"prism-solarizedlight":{"title":"Solarized Light","owner":"hectormatos2011 "},"prism-tomorrow":{"title":"Tomorrow Night","owner":"Rosey"}},"languages":{"meta":{"path":"components/prism-{id}","noCSS":true,"examplesPath":"examples/prism-{id}","addCheckAll":true},"markup":{"title":"Markup","alias":["html","xml","svg","mathml"],"aliasTitles":{"html":"HTML","xml":"XML","svg":"SVG","mathml":"MathML"},"option":"default"},"css":{"title":"CSS","option":"default","modify":"markup"},"clike":{"title":"C-like","option":"default","overrideExampleHeader":true},"javascript":{"title":"JavaScript","require":"clike","modify":"markup","alias":"js","option":"default"},"abap":{"title":"ABAP","owner":"dellagustin"},"abnf":{"title":"Augmented Backus–Naur form","owner":"RunDevelopment"},"actionscript":{"title":"ActionScript","require":"javascript","modify":"markup","owner":"Golmote"},"ada":{"title":"Ada","owner":"Lucretia"},"antlr4":{"title":"ANTLR4","alias":"g4","owner":"RunDevelopment"},"apacheconf":{"title":"Apache Configuration","owner":"GuiTeK"},"apl":{"title":"APL","owner":"ngn"},"applescript":{"title":"AppleScript","owner":"Golmote"},"aql":{"title":"AQL","owner":"RunDevelopment"},"arduino":{"title":"Arduino","require":"cpp","owner":"eisbehr-"},"arff":{"title":"ARFF","owner":"Golmote"},"asciidoc":{"alias":"adoc","title":"AsciiDoc","owner":"Golmote"},"asm6502":{"title":"6502 Assembly","owner":"kzurawel"},"aspnet":{"title":"ASP.NET (C#)","require":["markup","csharp"],"owner":"nauzilus"},"autohotkey":{"title":"AutoHotkey","owner":"aviaryan"},"autoit":{"title":"AutoIt","owner":"Golmote"},"bash":{"title":"Bash","alias":"shell","aliasTitles":{"shell":"Shell"},"owner":"zeitgeist87"},"basic":{"title":"BASIC","owner":"Golmote"},"batch":{"title":"Batch","owner":"Golmote"},"bbcode":{"title":"BBcode","owner":"RunDevelopment"},"bison":{"title":"Bison","require":"c","owner":"Golmote"},"bnf":{"title":"Backus–Naur form","alias":"rbnf","aliasTitles":{"rbnf":"Routing Backus–Naur form"},"owner":"RunDevelopment"},"brainfuck":{"title":"Brainfuck","owner":"Golmote"},"brightscript":{"title":"BrightScript","owner":"RunDevelopment"},"bro":{"title":"Bro","owner":"wayward710"},"c":{"title":"C","require":"clike","owner":"zeitgeist87"},"csharp":{"title":"C#","require":"clike","alias":["cs","dotnet"],"owner":"mvalipour"},"cpp":{"title":"C++","require":"c","owner":"zeitgeist87"},"cil":{"title":"CIL","owner":"sbrl"},"coffeescript":{"title":"CoffeeScript","require":"javascript","alias":"coffee","owner":"R-osey"},"cmake":{"title":"CMake","owner":"mjrogozinski"},"clojure":{"title":"Clojure","owner":"troglotit"},"crystal":{"title":"Crystal","require":"ruby","owner":"MakeNowJust"},"csp":{"title":"Content-Security-Policy","owner":"ScottHelme"},"css-extras":{"title":"CSS Extras","require":"css","modify":"css","owner":"milesj"},"d":{"title":"D","require":"clike","owner":"Golmote"},"dart":{"title":"Dart","require":"clike","owner":"Golmote"},"diff":{"title":"Diff","owner":"uranusjr"},"django":{"title":"Django/Jinja2","require":"markup-templating","alias":"jinja2","owner":"romanvm"},"dns-zone-file":{"title":"DNS zone file","owner":"RunDevelopment","alias":"dns-zone"},"docker":{"title":"Docker","alias":"dockerfile","owner":"JustinBeckwith"},"ebnf":{"title":"Extended Backus–Naur form","owner":"RunDevelopment"},"eiffel":{"title":"Eiffel","owner":"Conaclos"},"ejs":{"title":"EJS","require":["javascript","markup-templating"],"owner":"RunDevelopment"},"elixir":{"title":"Elixir","owner":"Golmote"},"elm":{"title":"Elm","owner":"zwilias"},"etlua":{"title":"Embedded Lua templating","require":["lua","markup-templating"],"owner":"RunDevelopment"},"erb":{"title":"ERB","require":["ruby","markup-templating"],"owner":"Golmote"},"erlang":{"title":"Erlang","owner":"Golmote"},"fsharp":{"title":"F#","require":"clike","owner":"simonreynolds7"},"firestore-security-rules":{"title":"Firestore security rules","require":"clike","owner":"RunDevelopment"},"flow":{"title":"Flow","require":"javascript","owner":"Golmote"},"fortran":{"title":"Fortran","owner":"Golmote"},"ftl":{"title":"FreeMarker Template Language","require":"markup-templating","owner":"RunDevelopment"},"gcode":{"title":"G-code","owner":"RunDevelopment"},"gdscript":{"title":"GDScript","owner":"RunDevelopment"},"gedcom":{"title":"GEDCOM","owner":"Golmote"},"gherkin":{"title":"Gherkin","owner":"hason"},"git":{"title":"Git","owner":"lgiraudel"},"glsl":{"title":"GLSL","require":"clike","owner":"Golmote"},"gml":{"title":"GameMaker Language","alias":"gamemakerlanguage","require":"clike","owner":"LiarOnce"},"go":{"title":"Go","require":"clike","owner":"arnehormann"},"graphql":{"title":"GraphQL","owner":"Golmote"},"groovy":{"title":"Groovy","require":"clike","owner":"robfletcher"},"haml":{"title":"Haml","require":"ruby","after":["css","css-extras","coffeescript","erb","javascript","less","markdown","ruby","scss","textile"],"owner":"Golmote"},"handlebars":{"title":"Handlebars","require":"markup-templating","owner":"Golmote"},"haskell":{"title":"Haskell","alias":"hs","owner":"bholst"},"haxe":{"title":"Haxe","require":"clike","owner":"Golmote"},"hcl":{"title":"HCL","owner":"outsideris"},"http":{"title":"HTTP","after":["css","javascript","json","markup"],"owner":"danielgtaylor"},"hpkp":{"title":"HTTP Public-Key-Pins","owner":"ScottHelme"},"hsts":{"title":"HTTP Strict-Transport-Security","owner":"ScottHelme"},"ichigojam":{"title":"IchigoJam","owner":"BlueCocoa"},"icon":{"title":"Icon","owner":"Golmote"},"inform7":{"title":"Inform 7","owner":"Golmote"},"ini":{"title":"Ini","owner":"aviaryan"},"io":{"title":"Io","owner":"AlesTsurko"},"j":{"title":"J","owner":"Golmote"},"java":{"title":"Java","require":"clike","owner":"sherblot"},"javadoc":{"title":"JavaDoc","require":["markup","java","javadoclike"],"modify":["java"],"after":["scala"],"owner":"RunDevelopment"},"javadoclike":{"title":"JavaDoc-like","modify":["java","javascript","php"],"owner":"RunDevelopment"},"javastacktrace":{"title":"Java stack trace","owner":"RunDevelopment"},"jolie":{"title":"Jolie","require":"clike","owner":"thesave"},"jq":{"title":"JQ","owner":"RunDevelopment"},"jsdoc":{"title":"JSDoc","require":["javascript","javadoclike"],"modify":"javascript","after":["actionscript","coffeescript"],"owner":"RunDevelopment"},"js-extras":{"title":"JS Extras","require":"javascript","modify":"javascript","after":["actionscript","coffeescript","flow","n4js","typescript"],"owner":"RunDevelopment"},"js-templates":{"title":"JS Templates","require":"javascript","modify":"javascript","after":["css","css-extras","graphql","markdown","markup"],"owner":"RunDevelopment"},"json":{"title":"JSON","owner":"CupOfTea696"},"jsonp":{"title":"JSONP","require":"json","owner":"RunDevelopment"},"json5":{"title":"JSON5","require":"json","owner":"RunDevelopment"},"julia":{"title":"Julia","owner":"cdagnino"},"keyman":{"title":"Keyman","owner":"mcdurdin"},"kotlin":{"title":"Kotlin","require":"clike","owner":"Golmote"},"latex":{"title":"LaTeX","alias":["tex","context"],"aliasTitles":{"tex":"TeX","context":"ConTeXt"},"owner":"japborst"},"less":{"title":"Less","require":"css","after":"css-extras","owner":"Golmote"},"lilypond":{"title":"LilyPond","require":"scheme","alias":"ly","owner":"RunDevelopment"},"liquid":{"title":"Liquid","owner":"cinhtau"},"lisp":{"title":"Lisp","alias":["emacs","elisp","emacs-lisp"],"owner":"JuanCaicedo"},"livescript":{"title":"LiveScript","owner":"Golmote"},"lolcode":{"title":"LOLCODE","owner":"Golmote"},"lua":{"title":"Lua","owner":"Golmote"},"makefile":{"title":"Makefile","owner":"Golmote"},"markdown":{"title":"Markdown","require":"markup","alias":"md","owner":"Golmote"},"markup-templating":{"title":"Markup templating","require":"markup","owner":"Golmote"},"matlab":{"title":"MATLAB","owner":"Golmote"},"mel":{"title":"MEL","owner":"Golmote"},"mizar":{"title":"Mizar","owner":"Golmote"},"monkey":{"title":"Monkey","owner":"Golmote"},"moonscript":{"title":"MoonScript","alias":"moon","owner":"RunDevelopment"},"n1ql":{"title":"N1QL","owner":"TMWilds"},"n4js":{"title":"N4JS","require":"javascript","after":["jsdoc"],"alias":"n4jsd","owner":"bsmith-n4"},"nand2tetris-hdl":{"title":"Nand To Tetris HDL","owner":"stephanmax"},"nasm":{"title":"NASM","owner":"rbmj"},"nginx":{"title":"nginx","owner":"westonganger","require":"clike"},"nim":{"title":"Nim","owner":"Golmote"},"nix":{"title":"Nix","owner":"Golmote"},"nsis":{"title":"NSIS","owner":"idleberg"},"objectivec":{"title":"Objective-C","require":"c","owner":"uranusjr"},"ocaml":{"title":"OCaml","owner":"Golmote"},"opencl":{"title":"OpenCL","require":"cpp","modify":["c","cpp"],"overrideExampleHeader":true,"owner":"Milania1"},"oz":{"title":"Oz","owner":"Golmote"},"parigp":{"title":"PARI/GP","owner":"Golmote"},"parser":{"title":"Parser","require":"markup","owner":"Golmote"},"pascal":{"title":"Pascal","alias":"objectpascal","aliasTitles":{"objectpascal":"Object Pascal"},"owner":"Golmote"},"pascaligo":{"title":"Pascaligo","owner":"DefinitelyNotAGoat"},"pcaxis":{"title":"PC-Axis","alias":"px","owner":"RunDevelopment"},"perl":{"title":"Perl","owner":"Golmote"},"php":{"title":"PHP","require":["clike","markup-templating"],"owner":"milesj"},"phpdoc":{"title":"PHPDoc","require":["php","javadoclike"],"modify":"php","owner":"RunDevelopment"},"php-extras":{"title":"PHP Extras","require":"php","modify":"php","owner":"milesj"},"plsql":{"title":"PL/SQL","require":"sql","owner":"Golmote"},"powershell":{"title":"PowerShell","owner":"nauzilus"},"processing":{"title":"Processing","require":"clike","owner":"Golmote"},"prolog":{"title":"Prolog","owner":"Golmote"},"properties":{"title":".properties","owner":"Golmote"},"protobuf":{"title":"Protocol Buffers","require":"clike","owner":"just-boris"},"pug":{"title":"Pug","require":["markup","javascript"],"after":["coffeescript","ejs","handlebars","less","livescript","markdown","scss","stylus","twig"],"owner":"Golmote"},"puppet":{"title":"Puppet","owner":"Golmote"},"pure":{"title":"Pure","after":["c","cpp","fortran"],"owner":"Golmote"},"python":{"title":"Python","alias":"py","owner":"multipetros"},"q":{"title":"Q (kdb+ database)","owner":"Golmote"},"qore":{"title":"Qore","require":"clike","owner":"temnroegg"},"r":{"title":"R","owner":"Golmote"},"jsx":{"title":"React JSX","require":["markup","javascript"],"after":["jsdoc","js-extras","js-templates"],"owner":"vkbansal"},"tsx":{"title":"React TSX","require":["jsx","typescript"]},"renpy":{"title":"Ren'py","owner":"HyuchiaDiego"},"reason":{"title":"Reason","require":"clike","owner":"Golmote"},"regex":{"title":"Regex","modify":["actionscript","coffeescript","flow","javascript","typescript","vala"],"owner":"RunDevelopment"},"rest":{"title":"reST (reStructuredText)","owner":"Golmote"},"rip":{"title":"Rip","owner":"ravinggenius"},"roboconf":{"title":"Roboconf","owner":"Golmote"},"robotframework":{"title":"Robot Framework","alias":"robot","owner":"RunDevelopment"},"ruby":{"title":"Ruby","require":"clike","alias":"rb","owner":"samflores"},"rust":{"title":"Rust","owner":"Golmote"},"sas":{"title":"SAS","peerDependencies":["groovy","lua","sql"],"owner":"Golmote"},"sass":{"title":"Sass (Sass)","require":"css","owner":"Golmote"},"scss":{"title":"Sass (Scss)","require":"css","after":"css-extras","owner":"MoOx"},"scala":{"title":"Scala","require":"java","owner":"jozic"},"scheme":{"title":"Scheme","owner":"bacchus123"},"shell-session":{"title":"Shell session","require":"bash","owner":"RunDevelopment"},"smalltalk":{"title":"Smalltalk","owner":"Golmote"},"smarty":{"title":"Smarty","require":"markup-templating","owner":"Golmote"},"solidity":{"title":"Solidity (Ethereum)","require":"clike","owner":"glachaud"},"soy":{"title":"Soy (Closure Template)","require":"markup-templating","owner":"Golmote"},"sparql":{"title":"SPARQL","require":"turtle","owner":"Triply-Dev","alias":"rq"},"splunk-spl":{"title":"Splunk SPL","owner":"RunDevelopment"},"sqf":{"title":"SQF: Status Quo Function (Arma 3)","require":"clike","owner":"RunDevelopment"},"sql":{"title":"SQL","owner":"multipetros"},"stylus":{"title":"Stylus","owner":"vkbansal"},"swift":{"title":"Swift","require":"clike","owner":"chrischares"},"tap":{"title":"TAP","owner":"isaacs","require":"yaml"},"tcl":{"title":"Tcl","owner":"PeterChaplin"},"textile":{"title":"Textile","require":"markup","after":"css","owner":"Golmote"},"toml":{"title":"TOML","owner":"RunDevelopment"},"tt2":{"title":"Template Toolkit 2","require":["clike","markup-templating"],"owner":"gflohr"},"turtle":{"title":"Turtle","alias":["trig"],"aliasTitles":{"trig":"TriG"},"owner":"jakubklimek"},"twig":{"title":"Twig","require":"markup","owner":"brandonkelly"},"typescript":{"title":"TypeScript","require":"javascript","after":"js-templates","alias":"ts","owner":"vkbansal"},"t4-cs":{"title":"T4 Text Templates (C#)","require":["t4-templating","csharp"],"alias":"t4","owner":"RunDevelopment"},"t4-vb":{"title":"T4 Text Templates (VB)","require":["t4-templating","visual-basic"],"owner":"RunDevelopment"},"t4-templating":{"title":"T4 templating","owner":"RunDevelopment"},"vala":{"title":"Vala","require":"clike","owner":"TemplarVolk"},"vbnet":{"title":"VB.Net","require":"basic","owner":"Bigsby"},"velocity":{"title":"Velocity","require":"markup","owner":"Golmote"},"verilog":{"title":"Verilog","owner":"a-rey"},"vhdl":{"title":"VHDL","owner":"a-rey"},"vim":{"title":"vim","owner":"westonganger"},"visual-basic":{"title":"Visual Basic","alias":"vb","owner":"Golmote"},"wasm":{"title":"WebAssembly","owner":"Golmote"},"wiki":{"title":"Wiki markup","require":"markup","owner":"Golmote"},"xeora":{"title":"Xeora","require":"markup","alias":"xeoracube","aliasTitles":{"xeoracube":"XeoraCube"},"owner":"freakmaxi"},"xojo":{"title":"Xojo (REALbasic)","owner":"Golmote"},"xquery":{"title":"XQuery","require":"markup","owner":"Golmote"},"yaml":{"title":"YAML","alias":"yml","owner":"hason"},"zig":{"title":"Zig","owner":"RunDevelopment"}},"plugins":{"meta":{"path":"plugins/{id}/prism-{id}","link":"plugins/{id}/"},"line-highlight":{"title":"Line Highlight","description":"Highlights specific lines and/or line ranges."},"line-numbers":{"title":"Line Numbers","description":"Line number at the beginning of code lines.","owner":"kuba-kubula"},"show-invisibles":{"title":"Show Invisibles","description":"Show hidden characters such as tabs and line breaks.","after":["autolinker","data-uri-highlight"]},"autolinker":{"title":"Autolinker","description":"Converts URLs and emails in code to clickable links. Parses Markdown links in comments."},"wpd":{"title":"WebPlatform Docs","description":"Makes tokens link to WebPlatform.org documentation. The links open in a new tab."},"custom-class":{"title":"Custom Class","description":"This plugin allows you to prefix Prism's default classes (.comment can become .namespace--comment) or replace them with your defined ones (like .editor__comment). You can even add new classes.","owner":"dvkndn","noCSS":true},"file-highlight":{"title":"File Highlight","description":"Fetch external files and highlight them with Prism. Used on the Prism website itself.","noCSS":true},"show-language":{"title":"Show Language","description":"Display the highlighted language in code blocks (inline code does not show the label).","owner":"nauzilus","noCSS":true,"require":"toolbar"},"jsonp-highlight":{"title":"JSONP Highlight","description":"Fetch content with JSONP and highlight some interesting content (e.g. GitHub/Gists or Bitbucket API).","noCSS":true,"owner":"nauzilus"},"highlight-keywords":{"title":"Highlight Keywords","description":"Adds special CSS classes for each keyword matched in the code. For example, the keyword if will have the class keyword-if as well. You can have fine grained control over the appearance of each keyword by providing your own CSS rules.","owner":"vkbansal","noCSS":true},"remove-initial-line-feed":{"title":"Remove initial line feed","description":"Removes the initial line feed in code blocks.","owner":"Golmote","noCSS":true},"inline-color":{"title":"Inline color","description":"Adds a small inline preview for colors in style sheets.","require":"css-extras","owner":"RunDevelopment"},"previewers":{"title":"Previewers","description":"Previewers for angles, colors, gradients, easing and time.","require":"css-extras","owner":"Golmote"},"autoloader":{"title":"Autoloader","description":"Automatically loads the needed languages to highlight the code blocks.","owner":"Golmote","noCSS":true},"keep-markup":{"title":"Keep Markup","description":"Prevents custom markup from being dropped out during highlighting.","owner":"Golmote","after":"normalize-whitespace","noCSS":true},"command-line":{"title":"Command Line","description":"Display a command line with a prompt and, optionally, the output/response from the commands.","owner":"chriswells0"},"unescaped-markup":{"title":"Unescaped Markup","description":"Write markup without having to escape anything."},"normalize-whitespace":{"title":"Normalize Whitespace","description":"Supports multiple operations to normalize whitespace in code blocks.","owner":"zeitgeist87","after":"unescaped-markup","noCSS":true},"data-uri-highlight":{"title":"Data-URI Highlight","description":"Highlights data-URI contents.","owner":"Golmote","noCSS":true},"toolbar":{"title":"Toolbar","description":"Attach a toolbar for plugins to easily register buttons on the top of a code block.","owner":"mAAdhaTTah"},"copy-to-clipboard":{"title":"Copy to Clipboard Button","description":"Add a button that copies the code block to the clipboard when clicked.","owner":"mAAdhaTTah","require":"toolbar","noCSS":true},"download-button":{"title":"Download Button","description":"A button in the toolbar of a code block adding a convenient way to download a code file.","owner":"Golmote","require":"toolbar","noCSS":true},"match-braces":{"title":"Match braces","description":"Highlights matching braces.","owner":"RunDevelopment"},"diff-highlight":{"title":"Diff Highlight","description":"Highlights the code inside diff blocks.","owner":"RunDevelopment","require":"diff"},"filter-highlight-all":{"title":"Filter highlightAll","description":"Filters the elements the highlightAll and highlightAllUnder methods actually highlight.","owner":"RunDevelopment","noCSS":true}}}; +var components = {"core":{"meta":{"path":"components/prism-core.js","option":"mandatory"},"core":"Core"},"themes":{"meta":{"path":"themes/{id}.css","link":"index.html?theme={id}","exclusive":true},"prism":{"title":"Default","option":"default"},"prism-dark":"Dark","prism-funky":"Funky","prism-okaidia":{"title":"Okaidia","owner":"ocodia"},"prism-twilight":{"title":"Twilight","owner":"remybach"},"prism-coy":{"title":"Coy","owner":"tshedor"},"prism-solarizedlight":{"title":"Solarized Light","owner":"hectormatos2011 "},"prism-tomorrow":{"title":"Tomorrow Night","owner":"Rosey"}},"languages":{"meta":{"path":"components/prism-{id}","noCSS":true,"examplesPath":"examples/prism-{id}","addCheckAll":true},"markup":{"title":"Markup","alias":["html","xml","svg","mathml"],"aliasTitles":{"html":"HTML","xml":"XML","svg":"SVG","mathml":"MathML"},"option":"default"},"css":{"title":"CSS","option":"default","modify":"markup"},"clike":{"title":"C-like","option":"default","overrideExampleHeader":true},"javascript":{"title":"JavaScript","require":"clike","modify":"markup","alias":"js","option":"default"},"abap":{"title":"ABAP","owner":"dellagustin"},"abnf":{"title":"Augmented Backus–Naur form","owner":"RunDevelopment"},"actionscript":{"title":"ActionScript","require":"javascript","modify":"markup","owner":"Golmote"},"ada":{"title":"Ada","owner":"Lucretia"},"antlr4":{"title":"ANTLR4","alias":"g4","owner":"RunDevelopment"},"apacheconf":{"title":"Apache Configuration","owner":"GuiTeK"},"apl":{"title":"APL","owner":"ngn"},"applescript":{"title":"AppleScript","owner":"Golmote"},"aql":{"title":"AQL","owner":"RunDevelopment"},"arduino":{"title":"Arduino","require":"cpp","owner":"eisbehr-"},"arff":{"title":"ARFF","owner":"Golmote"},"asciidoc":{"alias":"adoc","title":"AsciiDoc","owner":"Golmote"},"asm6502":{"title":"6502 Assembly","owner":"kzurawel"},"aspnet":{"title":"ASP.NET (C#)","require":["markup","csharp"],"owner":"nauzilus"},"autohotkey":{"title":"AutoHotkey","owner":"aviaryan"},"autoit":{"title":"AutoIt","owner":"Golmote"},"bash":{"title":"Bash","alias":"shell","aliasTitles":{"shell":"Shell"},"owner":"zeitgeist87"},"basic":{"title":"BASIC","owner":"Golmote"},"batch":{"title":"Batch","owner":"Golmote"},"bbcode":{"title":"BBcode","owner":"RunDevelopment"},"bison":{"title":"Bison","require":"c","owner":"Golmote"},"bnf":{"title":"Backus–Naur form","alias":"rbnf","aliasTitles":{"rbnf":"Routing Backus–Naur form"},"owner":"RunDevelopment"},"brainfuck":{"title":"Brainfuck","owner":"Golmote"},"brightscript":{"title":"BrightScript","owner":"RunDevelopment"},"bro":{"title":"Bro","owner":"wayward710"},"c":{"title":"C","require":"clike","owner":"zeitgeist87"},"csharp":{"title":"C#","require":"clike","alias":["cs","dotnet"],"owner":"mvalipour"},"cpp":{"title":"C++","require":"c","owner":"zeitgeist87"},"cil":{"title":"CIL","owner":"sbrl"},"coffeescript":{"title":"CoffeeScript","require":"javascript","alias":"coffee","owner":"R-osey"},"cmake":{"title":"CMake","owner":"mjrogozinski"},"clojure":{"title":"Clojure","owner":"troglotit"},"crystal":{"title":"Crystal","require":"ruby","owner":"MakeNowJust"},"csp":{"title":"Content-Security-Policy","owner":"ScottHelme"},"css-extras":{"title":"CSS Extras","require":"css","modify":"css","owner":"milesj"},"d":{"title":"D","require":"clike","owner":"Golmote"},"dart":{"title":"Dart","require":"clike","owner":"Golmote"},"diff":{"title":"Diff","owner":"uranusjr"},"django":{"title":"Django/Jinja2","require":"markup-templating","alias":"jinja2","owner":"romanvm"},"dns-zone-file":{"title":"DNS zone file","owner":"RunDevelopment","alias":"dns-zone"},"docker":{"title":"Docker","alias":"dockerfile","owner":"JustinBeckwith"},"ebnf":{"title":"Extended Backus–Naur form","owner":"RunDevelopment"},"eiffel":{"title":"Eiffel","owner":"Conaclos"},"ejs":{"title":"EJS","require":["javascript","markup-templating"],"owner":"RunDevelopment"},"elixir":{"title":"Elixir","owner":"Golmote"},"elm":{"title":"Elm","owner":"zwilias"},"etlua":{"title":"Embedded Lua templating","require":["lua","markup-templating"],"owner":"RunDevelopment"},"erb":{"title":"ERB","require":["ruby","markup-templating"],"owner":"Golmote"},"erlang":{"title":"Erlang","owner":"Golmote"},"fsharp":{"title":"F#","require":"clike","owner":"simonreynolds7"},"firestore-security-rules":{"title":"Firestore security rules","require":"clike","owner":"RunDevelopment"},"flow":{"title":"Flow","require":"javascript","owner":"Golmote"},"fortran":{"title":"Fortran","owner":"Golmote"},"ftl":{"title":"FreeMarker Template Language","require":"markup-templating","owner":"RunDevelopment"},"gcode":{"title":"G-code","owner":"RunDevelopment"},"gdscript":{"title":"GDScript","owner":"RunDevelopment"},"gedcom":{"title":"GEDCOM","owner":"Golmote"},"gherkin":{"title":"Gherkin","owner":"hason"},"git":{"title":"Git","owner":"lgiraudel"},"glsl":{"title":"GLSL","require":"clike","owner":"Golmote"},"gml":{"title":"GameMaker Language","alias":"gamemakerlanguage","require":"clike","owner":"LiarOnce"},"go":{"title":"Go","require":"clike","owner":"arnehormann"},"graphql":{"title":"GraphQL","owner":"Golmote"},"groovy":{"title":"Groovy","require":"clike","owner":"robfletcher"},"haml":{"title":"Haml","require":"ruby","optional":["css","css-extras","coffeescript","erb","javascript","less","markdown","ruby","scss","textile"],"owner":"Golmote"},"handlebars":{"title":"Handlebars","require":"markup-templating","owner":"Golmote"},"haskell":{"title":"Haskell","alias":"hs","owner":"bholst"},"haxe":{"title":"Haxe","require":"clike","owner":"Golmote"},"hcl":{"title":"HCL","owner":"outsideris"},"http":{"title":"HTTP","optional":["css","javascript","json","markup"],"owner":"danielgtaylor"},"hpkp":{"title":"HTTP Public-Key-Pins","owner":"ScottHelme"},"hsts":{"title":"HTTP Strict-Transport-Security","owner":"ScottHelme"},"ichigojam":{"title":"IchigoJam","owner":"BlueCocoa"},"icon":{"title":"Icon","owner":"Golmote"},"inform7":{"title":"Inform 7","owner":"Golmote"},"ini":{"title":"Ini","owner":"aviaryan"},"io":{"title":"Io","owner":"AlesTsurko"},"j":{"title":"J","owner":"Golmote"},"java":{"title":"Java","require":"clike","owner":"sherblot"},"javadoc":{"title":"JavaDoc","require":["markup","java","javadoclike"],"modify":["java"],"optional":["scala"],"owner":"RunDevelopment"},"javadoclike":{"title":"JavaDoc-like","modify":["java","javascript","php"],"owner":"RunDevelopment"},"javastacktrace":{"title":"Java stack trace","owner":"RunDevelopment"},"jolie":{"title":"Jolie","require":"clike","owner":"thesave"},"jq":{"title":"JQ","owner":"RunDevelopment"},"jsdoc":{"title":"JSDoc","require":["javascript","javadoclike"],"modify":"javascript","optional":["actionscript","coffeescript"],"owner":"RunDevelopment"},"js-extras":{"title":"JS Extras","require":"javascript","modify":"javascript","optional":["actionscript","coffeescript","flow","n4js","typescript"],"owner":"RunDevelopment"},"js-templates":{"title":"JS Templates","require":"javascript","modify":"javascript","optional":["css","css-extras","graphql","markdown","markup"],"owner":"RunDevelopment"},"json":{"title":"JSON","owner":"CupOfTea696"},"jsonp":{"title":"JSONP","require":"json","owner":"RunDevelopment"},"json5":{"title":"JSON5","require":"json","owner":"RunDevelopment"},"julia":{"title":"Julia","owner":"cdagnino"},"keyman":{"title":"Keyman","owner":"mcdurdin"},"kotlin":{"title":"Kotlin","require":"clike","owner":"Golmote"},"latex":{"title":"LaTeX","alias":["tex","context"],"aliasTitles":{"tex":"TeX","context":"ConTeXt"},"owner":"japborst"},"less":{"title":"Less","require":"css","optional":"css-extras","owner":"Golmote"},"lilypond":{"title":"LilyPond","require":"scheme","alias":"ly","owner":"RunDevelopment"},"liquid":{"title":"Liquid","owner":"cinhtau"},"lisp":{"title":"Lisp","alias":["emacs","elisp","emacs-lisp"],"owner":"JuanCaicedo"},"livescript":{"title":"LiveScript","owner":"Golmote"},"lolcode":{"title":"LOLCODE","owner":"Golmote"},"lua":{"title":"Lua","owner":"Golmote"},"makefile":{"title":"Makefile","owner":"Golmote"},"markdown":{"title":"Markdown","require":"markup","alias":"md","owner":"Golmote"},"markup-templating":{"title":"Markup templating","require":"markup","owner":"Golmote"},"matlab":{"title":"MATLAB","owner":"Golmote"},"mel":{"title":"MEL","owner":"Golmote"},"mizar":{"title":"Mizar","owner":"Golmote"},"monkey":{"title":"Monkey","owner":"Golmote"},"moonscript":{"title":"MoonScript","alias":"moon","owner":"RunDevelopment"},"n1ql":{"title":"N1QL","owner":"TMWilds"},"n4js":{"title":"N4JS","require":"javascript","optional":["jsdoc"],"alias":"n4jsd","owner":"bsmith-n4"},"nand2tetris-hdl":{"title":"Nand To Tetris HDL","owner":"stephanmax"},"nasm":{"title":"NASM","owner":"rbmj"},"nginx":{"title":"nginx","owner":"westonganger","require":"clike"},"nim":{"title":"Nim","owner":"Golmote"},"nix":{"title":"Nix","owner":"Golmote"},"nsis":{"title":"NSIS","owner":"idleberg"},"objectivec":{"title":"Objective-C","require":"c","owner":"uranusjr"},"ocaml":{"title":"OCaml","owner":"Golmote"},"opencl":{"title":"OpenCL","require":"cpp","modify":["c","cpp"],"overrideExampleHeader":true,"owner":"Milania1"},"oz":{"title":"Oz","owner":"Golmote"},"parigp":{"title":"PARI/GP","owner":"Golmote"},"parser":{"title":"Parser","require":"markup","owner":"Golmote"},"pascal":{"title":"Pascal","alias":"objectpascal","aliasTitles":{"objectpascal":"Object Pascal"},"owner":"Golmote"},"pascaligo":{"title":"Pascaligo","owner":"DefinitelyNotAGoat"},"pcaxis":{"title":"PC-Axis","alias":"px","owner":"RunDevelopment"},"perl":{"title":"Perl","owner":"Golmote"},"php":{"title":"PHP","require":["clike","markup-templating"],"owner":"milesj"},"phpdoc":{"title":"PHPDoc","require":["php","javadoclike"],"modify":"php","owner":"RunDevelopment"},"php-extras":{"title":"PHP Extras","require":"php","modify":"php","owner":"milesj"},"plsql":{"title":"PL/SQL","require":"sql","owner":"Golmote"},"powershell":{"title":"PowerShell","owner":"nauzilus"},"processing":{"title":"Processing","require":"clike","owner":"Golmote"},"prolog":{"title":"Prolog","owner":"Golmote"},"properties":{"title":".properties","owner":"Golmote"},"protobuf":{"title":"Protocol Buffers","require":"clike","owner":"just-boris"},"pug":{"title":"Pug","require":["markup","javascript"],"optional":["coffeescript","ejs","handlebars","less","livescript","markdown","scss","stylus","twig"],"owner":"Golmote"},"puppet":{"title":"Puppet","owner":"Golmote"},"pure":{"title":"Pure","optional":["c","cpp","fortran"],"owner":"Golmote"},"python":{"title":"Python","alias":"py","owner":"multipetros"},"q":{"title":"Q (kdb+ database)","owner":"Golmote"},"qore":{"title":"Qore","require":"clike","owner":"temnroegg"},"r":{"title":"R","owner":"Golmote"},"jsx":{"title":"React JSX","require":["markup","javascript"],"optional":["jsdoc","js-extras","js-templates"],"owner":"vkbansal"},"tsx":{"title":"React TSX","require":["jsx","typescript"]},"renpy":{"title":"Ren'py","owner":"HyuchiaDiego"},"reason":{"title":"Reason","require":"clike","owner":"Golmote"},"regex":{"title":"Regex","modify":["actionscript","coffeescript","flow","javascript","typescript","vala"],"owner":"RunDevelopment"},"rest":{"title":"reST (reStructuredText)","owner":"Golmote"},"rip":{"title":"Rip","owner":"ravinggenius"},"roboconf":{"title":"Roboconf","owner":"Golmote"},"robotframework":{"title":"Robot Framework","alias":"robot","owner":"RunDevelopment"},"ruby":{"title":"Ruby","require":"clike","alias":"rb","owner":"samflores"},"rust":{"title":"Rust","owner":"Golmote"},"sas":{"title":"SAS","peerDependencies":["groovy","lua","sql"],"owner":"Golmote"},"sass":{"title":"Sass (Sass)","require":"css","owner":"Golmote"},"scss":{"title":"Sass (Scss)","require":"css","optional":"css-extras","owner":"MoOx"},"scala":{"title":"Scala","require":"java","owner":"jozic"},"scheme":{"title":"Scheme","owner":"bacchus123"},"shell-session":{"title":"Shell session","require":"bash","owner":"RunDevelopment"},"smalltalk":{"title":"Smalltalk","owner":"Golmote"},"smarty":{"title":"Smarty","require":"markup-templating","owner":"Golmote"},"solidity":{"title":"Solidity (Ethereum)","require":"clike","owner":"glachaud"},"soy":{"title":"Soy (Closure Template)","require":"markup-templating","owner":"Golmote"},"sparql":{"title":"SPARQL","require":"turtle","owner":"Triply-Dev","alias":"rq"},"splunk-spl":{"title":"Splunk SPL","owner":"RunDevelopment"},"sqf":{"title":"SQF: Status Quo Function (Arma 3)","require":"clike","owner":"RunDevelopment"},"sql":{"title":"SQL","owner":"multipetros"},"stylus":{"title":"Stylus","owner":"vkbansal"},"swift":{"title":"Swift","require":"clike","owner":"chrischares"},"tap":{"title":"TAP","owner":"isaacs","require":"yaml"},"tcl":{"title":"Tcl","owner":"PeterChaplin"},"textile":{"title":"Textile","require":"markup","optional":"css","owner":"Golmote"},"toml":{"title":"TOML","owner":"RunDevelopment"},"tt2":{"title":"Template Toolkit 2","require":["clike","markup-templating"],"owner":"gflohr"},"turtle":{"title":"Turtle","alias":["trig"],"aliasTitles":{"trig":"TriG"},"owner":"jakubklimek"},"twig":{"title":"Twig","require":"markup","owner":"brandonkelly"},"typescript":{"title":"TypeScript","require":"javascript","optional":"js-templates","alias":"ts","owner":"vkbansal"},"t4-cs":{"title":"T4 Text Templates (C#)","require":["t4-templating","csharp"],"alias":"t4","owner":"RunDevelopment"},"t4-vb":{"title":"T4 Text Templates (VB)","require":["t4-templating","visual-basic"],"owner":"RunDevelopment"},"t4-templating":{"title":"T4 templating","owner":"RunDevelopment"},"vala":{"title":"Vala","require":"clike","owner":"TemplarVolk"},"vbnet":{"title":"VB.Net","require":"basic","owner":"Bigsby"},"velocity":{"title":"Velocity","require":"markup","owner":"Golmote"},"verilog":{"title":"Verilog","owner":"a-rey"},"vhdl":{"title":"VHDL","owner":"a-rey"},"vim":{"title":"vim","owner":"westonganger"},"visual-basic":{"title":"Visual Basic","alias":"vb","owner":"Golmote"},"wasm":{"title":"WebAssembly","owner":"Golmote"},"wiki":{"title":"Wiki markup","require":"markup","owner":"Golmote"},"xeora":{"title":"Xeora","require":"markup","alias":"xeoracube","aliasTitles":{"xeoracube":"XeoraCube"},"owner":"freakmaxi"},"xojo":{"title":"Xojo (REALbasic)","owner":"Golmote"},"xquery":{"title":"XQuery","require":"markup","owner":"Golmote"},"yaml":{"title":"YAML","alias":"yml","owner":"hason"},"zig":{"title":"Zig","owner":"RunDevelopment"}},"plugins":{"meta":{"path":"plugins/{id}/prism-{id}","link":"plugins/{id}/"},"line-highlight":{"title":"Line Highlight","description":"Highlights specific lines and/or line ranges."},"line-numbers":{"title":"Line Numbers","description":"Line number at the beginning of code lines.","owner":"kuba-kubula"},"show-invisibles":{"title":"Show Invisibles","description":"Show hidden characters such as tabs and line breaks.","optional":["autolinker","data-uri-highlight"]},"autolinker":{"title":"Autolinker","description":"Converts URLs and emails in code to clickable links. Parses Markdown links in comments."},"wpd":{"title":"WebPlatform Docs","description":"Makes tokens link to WebPlatform.org documentation. The links open in a new tab."},"custom-class":{"title":"Custom Class","description":"This plugin allows you to prefix Prism's default classes (.comment can become .namespace--comment) or replace them with your defined ones (like .editor__comment). You can even add new classes.","owner":"dvkndn","noCSS":true},"file-highlight":{"title":"File Highlight","description":"Fetch external files and highlight them with Prism. Used on the Prism website itself.","noCSS":true},"show-language":{"title":"Show Language","description":"Display the highlighted language in code blocks (inline code does not show the label).","owner":"nauzilus","noCSS":true,"require":"toolbar"},"jsonp-highlight":{"title":"JSONP Highlight","description":"Fetch content with JSONP and highlight some interesting content (e.g. GitHub/Gists or Bitbucket API).","noCSS":true,"owner":"nauzilus"},"highlight-keywords":{"title":"Highlight Keywords","description":"Adds special CSS classes for each keyword matched in the code. For example, the keyword if will have the class keyword-if as well. You can have fine grained control over the appearance of each keyword by providing your own CSS rules.","owner":"vkbansal","noCSS":true},"remove-initial-line-feed":{"title":"Remove initial line feed","description":"Removes the initial line feed in code blocks.","owner":"Golmote","noCSS":true},"inline-color":{"title":"Inline color","description":"Adds a small inline preview for colors in style sheets.","require":"css-extras","owner":"RunDevelopment"},"previewers":{"title":"Previewers","description":"Previewers for angles, colors, gradients, easing and time.","require":"css-extras","owner":"Golmote"},"autoloader":{"title":"Autoloader","description":"Automatically loads the needed languages to highlight the code blocks.","owner":"Golmote","noCSS":true},"keep-markup":{"title":"Keep Markup","description":"Prevents custom markup from being dropped out during highlighting.","owner":"Golmote","optional":"normalize-whitespace","noCSS":true},"command-line":{"title":"Command Line","description":"Display a command line with a prompt and, optionally, the output/response from the commands.","owner":"chriswells0"},"unescaped-markup":{"title":"Unescaped Markup","description":"Write markup without having to escape anything."},"normalize-whitespace":{"title":"Normalize Whitespace","description":"Supports multiple operations to normalize whitespace in code blocks.","owner":"zeitgeist87","optional":"unescaped-markup","noCSS":true},"data-uri-highlight":{"title":"Data-URI Highlight","description":"Highlights data-URI contents.","owner":"Golmote","noCSS":true},"toolbar":{"title":"Toolbar","description":"Attach a toolbar for plugins to easily register buttons on the top of a code block.","owner":"mAAdhaTTah"},"copy-to-clipboard":{"title":"Copy to Clipboard Button","description":"Add a button that copies the code block to the clipboard when clicked.","owner":"mAAdhaTTah","require":"toolbar","noCSS":true},"download-button":{"title":"Download Button","description":"A button in the toolbar of a code block adding a convenient way to download a code file.","owner":"Golmote","require":"toolbar","noCSS":true},"match-braces":{"title":"Match braces","description":"Highlights matching braces.","owner":"RunDevelopment"},"diff-highlight":{"title":"Diff Highlight","description":"Highlights the code inside diff blocks.","owner":"RunDevelopment","require":"diff"},"filter-highlight-all":{"title":"Filter highlightAll","description":"Filters the elements the highlightAll and highlightAllUnder methods actually highlight.","owner":"RunDevelopment","noCSS":true}}}; if (typeof module !== 'undefined' && module.exports) { module.exports = components; } \ No newline at end of file diff --git a/components.json b/components.json index 79f7e1dbaa..9292842699 100644 --- a/components.json +++ b/components.json @@ -375,7 +375,7 @@ "haml": { "title": "Haml", "require": "ruby", - "after": [ + "optional": [ "css", "css-extras", "coffeescript", @@ -410,7 +410,7 @@ }, "http": { "title": "HTTP", - "after": [ + "optional": [ "css", "javascript", "json", @@ -461,7 +461,7 @@ "modify": [ "java" ], - "after": [ + "optional": [ "scala" ], "owner": "RunDevelopment" @@ -492,7 +492,7 @@ "title": "JSDoc", "require": ["javascript", "javadoclike"], "modify": "javascript", - "after": [ + "optional": [ "actionscript", "coffeescript" ], @@ -502,7 +502,7 @@ "title": "JS Extras", "require": "javascript", "modify": "javascript", - "after": [ + "optional": [ "actionscript", "coffeescript", "flow", @@ -515,7 +515,7 @@ "title": "JS Templates", "require": "javascript", "modify": "javascript", - "after": [ + "optional": [ "css", "css-extras", "graphql", @@ -563,7 +563,7 @@ "less": { "title": "Less", "require": "css", - "after": "css-extras", + "optional": "css-extras", "owner": "Golmote" }, "lilypond": { @@ -636,7 +636,7 @@ "n4js": { "title": "N4JS", "require": "javascript", - "after": [ + "optional": [ "jsdoc" ], "alias": "n4jsd", @@ -767,7 +767,7 @@ "pug": { "title": "Pug", "require": ["markup", "javascript"], - "after": [ + "optional": [ "coffeescript", "ejs", "handlebars", @@ -786,7 +786,7 @@ }, "pure": { "title": "Pure", - "after": [ + "optional": [ "c", "cpp", "fortran" @@ -814,7 +814,7 @@ "jsx": { "title": "React JSX", "require": ["markup", "javascript"], - "after": [ + "optional": [ "jsdoc", "js-extras", "js-templates" @@ -886,7 +886,7 @@ "scss": { "title": "Sass (Scss)", "require": "css", - "after": "css-extras", + "optional": "css-extras", "owner": "MoOx" }, "scala": { @@ -962,7 +962,7 @@ "textile": { "title": "Textile", "require": "markup", - "after": "css", + "optional": "css", "owner": "Golmote" }, "toml": { @@ -990,7 +990,7 @@ "typescript": { "title": "TypeScript", "require": "javascript", - "after": "js-templates", + "optional": "js-templates", "alias": "ts", "owner": "vkbansal" }, @@ -1095,7 +1095,7 @@ "show-invisibles": { "title": "Show Invisibles", "description": "Show hidden characters such as tabs and line breaks.", - "after": [ + "optional": [ "autolinker", "data-uri-highlight" ] @@ -1166,7 +1166,7 @@ "title": "Keep Markup", "description": "Prevents custom markup from being dropped out during highlighting.", "owner": "Golmote", - "after": "normalize-whitespace", + "optional": "normalize-whitespace", "noCSS": true }, "command-line": { @@ -1182,7 +1182,7 @@ "title": "Normalize Whitespace", "description": "Supports multiple operations to normalize whitespace in code blocks.", "owner": "zeitgeist87", - "after": "unescaped-markup", + "optional": "unescaped-markup", "noCSS": true }, "data-uri-highlight": { diff --git a/components/index.js b/components/index.js index a773762dae..450810a7a2 100644 --- a/components/index.js +++ b/components/index.js @@ -1,5 +1,5 @@ const components = require('../components.js'); -const getLoad = require('../dependencies'); +const getLoader = require('../dependencies'); /** @@ -25,10 +25,10 @@ function loadLanguages(languages) { } // the user might have loaded languages via some other way or used `prism.js` which already includes some - // we don't need to validate the ids because `getLoad` will ignore invalid ones + // we don't need to validate the ids because `getLoader` will ignore invalid ones const loaded = [...loadedLanguages, ...Object.keys(Prism.languages)]; - getLoad(components, languages, loaded).load(lang => { + getLoader(components, languages, loaded).load(lang => { if (!(lang in components.languages)) { console.warn('Language does not exist: ' + lang); return; diff --git a/dependencies.js b/dependencies.js index 95d2f9ec27..f301cd4d74 100644 --- a/dependencies.js +++ b/dependencies.js @@ -12,12 +12,12 @@ * @property {Object} [aliasTitles] An optional map from an alias to its title. * * Aliases which are not in this map will the get title of the component. + * @property {string | string[]} [optional] * @property {string | string[]} [require] * @property {string | string[]} [modify] - * @property {string | string[]} [after] */ -var getLoad = (function () { +var getLoader = (function () { /** * A function which does absolutely nothing. @@ -125,7 +125,7 @@ var getLoad = (function () { var entry = entryMap[id]; if (entry) { /** @type {string[]} */ - var deps = [].concat(entry.require, entry.modify, entry.after).filter(Boolean); + var deps = [].concat(entry.require, entry.modify, entry.optional).filter(Boolean); deps.forEach(function (depId) { if (!(depId in entryMap)) { throw new Error(id + ' depends on an unknown component ' + depId); @@ -300,9 +300,9 @@ var getLoad = (function () { * @param {string[]} [loaded=[]] A list of already loaded components. * * If a component is in this list, then all of its requirements will also be assumed to be in the list. - * @returns {GetLoadResult} + * @returns {Loader} * - * @typedef GetLoadResult + * @typedef Loader * @property {() => string[]} getIds A function to get all ids of the components to load. * * The returned ids will be duplicate-free, alias-free and in load order. @@ -321,11 +321,18 @@ var getLoad = (function () { * * await load( * id => loadComponentAsync(id), // returns a Promise for each id - * (before, after) => before.then(() => after), - * Promise.all + * { + * series: async (before, after) => { + * await before; + * await after(); + * }, + * parallel: async (values) => { + * await Promise.all(values); + * } + * } * ); */ - function getLoad(components, load, loaded) { + function getLoader(components, load, loaded) { var entryMap = createEntryMap(components); var resolveAlias = createAliasResolver(entryMap); @@ -398,11 +405,11 @@ var getLoad = (function () { } } - /** @type {GetLoadResult} */ - var result = { + /** @type {Loader} */ + var loader = { getIds: function () { var ids = []; - result.load(function (id) { + loader.load(function (id) { ids.push(id); }); return ids; @@ -412,13 +419,13 @@ var getLoad = (function () { } }; - return result; + return loader; } - return getLoad; + return getLoader; }()); if (typeof module !== 'undefined') { - module.exports = getLoad; + module.exports = getLoader; } diff --git a/scripts/download.js b/scripts/download.js index 06d0e82adb..1a7587150c 100644 --- a/scripts/download.js +++ b/scripts/download.js @@ -573,7 +573,7 @@ function buildCode(promises) { }); // this assumes that the ids in `toSortMap` are complete under transitive requirements - getLoad(components, Object.keys(toSortMap)).getIds().forEach(function (id) { + getLoader(components, Object.keys(toSortMap)).getIds().forEach(function (id) { if (!toSortMap[id]) { console.error(id + " not found."); } diff --git a/tests/dependencies-test.js b/tests/dependencies-test.js index 483d693dd5..2a9bdb2f3e 100644 --- a/tests/dependencies-test.js +++ b/tests/dependencies-test.js @@ -1,5 +1,5 @@ const { assert } = require('chai'); -const getLoad = require('../dependencies'); +const getLoader = require('../dependencies'); const components = require('../components'); @@ -16,7 +16,7 @@ describe('Dependency logic', function () { }, 'c': { require: 'a', - after: ['b', 'e'] + optional: ['b', 'e'] }, 'd': { require: ['c', 'b'], @@ -31,14 +31,14 @@ describe('Dependency logic', function () { }; /** - * Returns the ids of `getLoad`. + * Returns the ids of `getLoader`. * * @param {string[]} load * @param {string[]} [loaded] * @returns {string[]} */ function getIds(load, loaded) { - return getLoad(components, load, loaded).getIds(); + return getLoader(components, load, loaded).getIds(); } describe('Returned ids', function () { @@ -78,7 +78,7 @@ describe('Dependency logic', function () { b: 'B' } }; - getLoad(circular, ['a']).getIds(); + getLoader(circular, ['a']).getIds(); }); }); @@ -96,15 +96,15 @@ describe('Dependency logic', function () { assert.deepStrictEqual(getIds(['e', 'a']), ['a', 'e']); }); - it('- should load components in the correct order (after)', function () { + it('- should load components in the correct order (optional)', function () { assert.deepStrictEqual(getIds(['c', 'b'], ['a']), ['b', 'c']); }); - it('- should load components in the correct order (require + after)', function () { + it('- should load components in the correct order (require + optional)', function () { assert.deepStrictEqual(getIds(['d'], ['a']), ['b', 'c', 'd']); }); - it('- should load components in the correct order (require + modify + after)', function () { + it('- should load components in the correct order (require + modify + optional)', function () { assert.deepStrictEqual(getIds(['d', 'e'], ['b']), ['a', 'e', 'c', 'd']); }); @@ -133,7 +133,7 @@ describe('Dependency logic', function () { } } }; - getLoad(circular, ['a']).getIds(); + getLoader(circular, ['a']).getIds(); }); }); @@ -148,7 +148,7 @@ describe('Dependency logic', function () { b: 'B' } }; - getLoad(circular, ['a']).getIds(); + getLoader(circular, ['a']).getIds(); }); }); @@ -165,11 +165,11 @@ describe('Dependency logic', function () { require: 'b' }, b: { - after: 'a' + optional: 'a' } } }; - getLoad(circular, ['a']).getIds(); + getLoader(circular, ['a']).getIds(); }); }); @@ -224,9 +224,9 @@ describe('Dependency logic', function () { }); } - const result = getLoad(localComponents, ['c']); + const loader = getLoader(localComponents, ['c']); - await result.load(id => loadComp(id), { + await loader.load(id => loadComp(id), { series: async (before, after) => { await before; await after(); @@ -248,7 +248,7 @@ describe('components.json', function () { it('- should be valid', function () { try { - getLoad(components, Object.keys(components.languages).filter(k => k != 'meta')).getIds(); + getLoader(components, Object.keys(components.languages).filter(k => k != 'meta')).getIds(); } catch (error) { assert.fail(error.toString()); } diff --git a/tests/helper/prism-loader.js b/tests/helper/prism-loader.js index aa09bd84cc..7bc07487c9 100644 --- a/tests/helper/prism-loader.js +++ b/tests/helper/prism-loader.js @@ -4,7 +4,7 @@ const fs = require("fs"); const vm = require("vm"); const { getAllFiles } = require("./test-discovery"); const components = require("../../components"); -const getLoad = require("../../dependencies"); +const getLoader = require("../../dependencies"); const languagesCatalog = components.languages; @@ -46,7 +46,7 @@ module.exports = { languages = [languages]; } - getLoad(components, languages, [...context.loaded]).load(id => { + getLoader(components, languages, [...context.loaded]).load(id => { if (!languagesCatalog[id]) { throw new Error(`Language '${id}' not found.`); } From 39ff76e3ba7300ef762551a9c8fd8e030a272323 Mon Sep 17 00:00:00 2001 From: RunDevelopment Date: Sun, 15 Dec 2019 21:19:06 +0100 Subject: [PATCH 26/26] Fixed download page I forgot to remove a debug line. This could have gone real wrong. --- scripts/download.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/download.js b/scripts/download.js index 1a7587150c..cfd1d16a05 100644 --- a/scripts/download.js +++ b/scripts/download.js @@ -560,13 +560,12 @@ function buildCode(promises) { var toSortMap = {}; promises.forEach(function (p) { - p.contentsPromise = Promise.resolve(p.id); if (p.category == "core" || p.category == "themes") { finalPromises.push(p); } else { var infos = toSortMap[p.id]; if (!infos) { - toSortMap[p.id]=infos = []; + toSortMap[p.id] = infos = []; } infos.push(p); }