diff --git a/scripts/generate-file-icon-index.js b/scripts/generate-file-icon-index.js new file mode 100644 index 0000000..a3fe1b3 --- /dev/null +++ b/scripts/generate-file-icon-index.js @@ -0,0 +1,62 @@ +const languageIds = require('./language-id-ext.json') + +const records = [] + +document.body + .querySelector('table') + .querySelectorAll('tbody tr') + .forEach(tr => { + const [name, id, dark, light] = Array.from(tr.querySelectorAll('td')) + const exts = [] + const names = [] + id.innerHTML + .replace(/|<\/sub>/g, '') + .split(', ') + .map(part => { + const match = part.match(/<(\w+)>(.*?)<\/\1>/) + if (match) { + const [, tag, content] = match + if (tag === 'strong') { + // filenames in bold + names.push(content) + } else if (tag === 'code') { + // language ids in code block + const map = Object.values(languageIds).find(({ ids }) => + (Array.isArray(ids) ? ids : [ids]).includes(content), + ) + if (map && map.exts) exts.push(map.exts) + } else { + console.warn(`Found unrecognized format`, part) // unknown + } + } else if (part) { + // extensions are in regular fonts + exts.push(part.replace(/^\./, '')) + } + }) + records.push({ + name: name.innerText, + exts, + names, + icon: getSrc(dark.querySelector('img')) || getSrc(light.querySelector('img')), + }) + }) + +function getSrc(img) { + return img && img.src +} + +const prepend = 'https://github.com/vscode-icons/vscode-icons/raw/master/icons/file_type_' +const append = '.svg?sanitize=true' +const separator = ':' +const csv = records + .map(({ name, names, exts, icon }) => + [ + name, + names.join(separator), + exts.join(separator), + // icon.replace(prepend, '').replace(append, ''), // assumption: name is equal to this + ].join(','), + ) + .join('\n') + +console.log(csv) diff --git a/scripts/generate-folder-icon-index.js b/scripts/generate-folder-icon-index.js new file mode 100644 index 0000000..8ddd743 --- /dev/null +++ b/scripts/generate-folder-icon-index.js @@ -0,0 +1,41 @@ +function parsePageContent() { + const records = [] + document.body + .querySelector('table') + .querySelectorAll('tbody tr') + .forEach(tr => { + const [name, folderNames, closed, open] = Array.from(tr.querySelectorAll('td')) + const names = folderNames.innerHTML.split(', ') + records.push({ + name: name.innerText, + names, + icon: { + closed: getSrc(closed.querySelector('img')), + open: getSrc(open.querySelector('img')), + }, + }) + }) + return records +} + +function getSrc(img) { + return img && img.src +} + +function generateCSV(records) { + const prepend = 'https://github.com/vscode-icons/vscode-icons/raw/master/icons/folder_type_' + const append = '.svg?sanitize=true' + const separator = ':' + const csv = records + .map(({ name, names, icon }) => + [ + name, + names.join(separator), + // icon.replace(prepend, '').replace(append, ''), // assumption: name is equal to this + ].join(','), + ) + .join('\n') + return csv +} + +console.log(generateCSV(parsePageContent())) diff --git a/scripts/language-id-ext.json b/scripts/language-id-ext.json new file mode 100644 index 0000000..b4254a5 --- /dev/null +++ b/scripts/language-id-ext.json @@ -0,0 +1,276 @@ +{ + "actionscript": { "ids": "nextgenas", "exts": "as" }, + "ada": { "ids": "ada", "exts": "ada" }, + "advpl": { "ids": "advpl", "exts": "prw" }, + "affectscript": { "ids": "affectscript", "exts": "affect" }, + "al": { "ids": "al", "exts": "al" }, + "ansible": { "ids": "ansible", "exts": "ansible" }, + "antlr": { "ids": "antlr", "exts": "g4" }, + "anyscript": { "ids": "anyscript", "exts": "any" }, + "apache": { "ids": "apacheconf", "exts": "htaccess" }, + "apex": { "ids": "apex", "exts": "cls" }, + "apib": { "ids": "apiblueprint", "exts": "apib" }, + "apl": { "ids": "apl", "exts": "apl" }, + "applescript": { "ids": "applescript", "exts": "applescript" }, + "asciidoc": { "ids": "asciidoc", "exts": "adoc" }, + "asp": { "ids": ["asp", "asp (html)"], "exts": "asp" }, + "assembly": { "ids": ["arm", "asm"], "exts": "asm" }, + "ats": { "ids": ["ats"], "exts": "ats" }, + "autohotkey": { "ids": "ahk", "exts": "ahk" }, + "autoit": { "ids": "autoit", "exts": "au3" }, + "avro": { "ids": "avro", "exts": "avcs" }, + "azcli": { "ids": "azcli", "exts": "azcli" }, + "azurepipelines": { + "ids": "azure-pipelines", + "exts": "azure-pipelines.yml" + }, + "ballerina": { "ids": "ballerina", "exts": "bal" }, + "bat": { "ids": "bat", "exts": "bat" }, + "bazel": { "ids": "bazel", "exts": "bzl" }, + "befunge": { "ids": ["befunge", "befunge98"], "exts": "bf" }, + "bibtex": { "ids": "bibtex", "exts": "bib" }, + "biml": { "ids": "biml", "exts": "biml" }, + "blade": { "ids": ["blade", "laravel-blade"], "exts": "blade.php" }, + "bolt": { "ids": "bolt", "exts": "bolt" }, + "c": { "ids": "c", "exts": "c" }, + "c_al": { "ids": "c-al", "exts": "cal" }, + "cabal": { "ids": "cabal", "exts": "cabal" }, + "caddyfile": { "ids": "caddyfile", "exts": "Caddyfile" }, + "ceylon": { "ids": "ceylon", "exts": "ceylon" }, + "cfc": { "ids": "cfc", "exts": "cfc" }, + "cfm": { "ids": "cfmhtml", "exts": "cfm" }, + "clojure": { "ids": "clojure", "exts": "clojure" }, + "clojurescript": { "ids": "clojurescript", "exts": "clojurescript" }, + "cmake": { "ids": "cmake", "exts": "cmake" }, + "cmakecache": { "ids": "cmake-cache", "exts": "CMakeCache.txt" }, + "cobol": { "ids": "cobol", "exts": "cbl" }, + "coffeescript": { "ids": "coffeescript", "exts": "coffee" }, + "coldfusion": { "ids": ["cfml", "lang-cfml"], "exts": "cfml" }, + "confluence": { "ids": ["confluence"], "exts": "confluence" }, + "cookbook": { "ids": "cookbook", "exts": "ckbk" }, + "cpp": { "ids": "cpp", "exts": "cpp" }, + "crystal": { "ids": "crystal", "exts": "cr" }, + "csharp": { "ids": "csharp", "exts": "cs" }, + "css": { "ids": "css", "exts": "css" }, + "cucumber": { "ids": "feature", "exts": "feature" }, + "cuda": { "ids": "cuda", "exts": "cu" }, + "cython": { "ids": "cython", "exts": "pyx" }, + "dal": { "ids": "dal", "exts": "dal" }, + "dart": { "ids": "dart", "exts": "dart" }, + "django": { "ids": ["django-html", "django-txt"], "exts": "html" }, + "diff": { "ids": "diff", "exts": "diff" }, + "dlang": { "ids": ["d", "dscript", "dml", "diet"], "exts": "d" }, + "dockerfile": { "ids": "dockerfile", "exts": "dockerfile" }, + "dockerignore": { "ids": "ignore", "exts": "dockerignore" }, + "doctex": { "ids": "doctex", "exts": "dtx" }, + "dotenv": { "ids": "dotenv", "exts": "env" }, + "dotjs": { "ids": "dotjs", "exts": "dot" }, + "doxygen": { "ids": "doxygen", "exts": "dox" }, + "drools": { "ids": "drools", "exts": "drl" }, + "dylanlang": { "ids": ["dylan", "dylan-lid"], "exts": "dylan" }, + "dustjs": { "ids": "dustjs", "exts": "dust" }, + "edge": { "ids": "edge", "exts": "edge" }, + "eex": { "ids": ["eex", "html-eex"], "exts": "eex" }, + "elastic": { "ids": "es", "exts": "es" }, + "elixir": { "ids": "elixir", "exts": "ex" }, + "elm": { "ids": "elm", "exts": "elm" }, + "erb": { "ids": "erb", "exts": "erb" }, + "erlang": { "ids": "erlang", "exts": "erl" }, + "falcon": { "ids": "falcon", "exts": "falcon" }, + "fortran": { + "ids": ["fortran", "fortran-modern", "FortranFreeForm", "fortran_fixed-form"], + "exts": "f" + }, + "freemarker": { "ids": "ftl", "exts": "ftl" }, + "fsharp": { "ids": "fsharp", "exts": "fs" }, + "galen": { "ids": "galen", "exts": "gspec" }, + "gamemaker": { "ids": "gml-gms", "exts": "gml" }, + "gamemaker2": { "ids": "gml-gms2", "exts": "gml" }, + "gamemaker81": { "ids": "gml-gm81", "exts": "gml" }, + "gcode": { "ids": "gcode", "exts": "gcode" }, + "git": { "ids": ["git-commit", "git-rebase"], "exts": "git" }, + "glsl": { "ids": "glsl", "exts": "glsl" }, + "go": { "ids": "go", "exts": "go" }, + "godot": { "ids": "gdscript", "exts": "gd" }, + "graphql": { "ids": "graphql", "exts": "gql" }, + "graphviz": { "ids": "dot", "exts": "gv" }, + "groovy": { "ids": "groovy", "exts": "groovy" }, + "haml": { "ids": "haml", "exts": "haml" }, + "handlebars": { "ids": "handlebars", "exts": "hbs" }, + "harbour": { "ids": "harbour", "exts": "prg" }, + "haskell": { "ids": "haskell", "exts": "hs" }, + "haxe": { "ids": ["haxe", "hxml", "Haxe AST dump"], "exts": "haxe" }, + "helm": { "ids": "helm", "exts": "helm.tpl" }, + "hjson": { "ids": "hjson", "exts": "hjson" }, + "hlsl": { "ids": "hlsl", "exts": "hlsl" }, + "homeassistant": { "ids": "home-assistant", "exts": "yaml" }, + "hosts": { "ids": "hosts", "exts": "hosts" }, + "html": { "ids": "html", "exts": "html" }, + "http": { "ids": "http", "exts": "http" }, + "hunspell": { "ids": ["hunspell.aff", "hunspell.dic"], "exts": "aff" }, + "icl": { "ids": "icl", "exts": "icl" }, + "imba": { "ids": "imba", "exts": "imba" }, + "informix": { "ids": "4GL", "exts": "4gl" }, + "ini": { "ids": "ini", "exts": "ini" }, + "ink": { "ids": "ink", "exts": "ink" }, + "innosetup": { "ids": "innosetup", "exts": "iss" }, + "io": { "ids": "io", "exts": "io" }, + "latex": { "ids": "latex", "exts": "tex" }, + "janet": { "ids": "janet", "exts": "janet" }, + "java": { "ids": "java", "exts": "java" }, + "javascript": { "ids": "javascript", "exts": "js" }, + "javascriptreact": { "ids": "javascriptreact", "exts": "jsx" }, + "jekyll": { "ids": "jekyll", "exts": "jekyll" }, + "jenkins": { + "ids": ["jenkins", "declarative", "jenkinsfile"], + "exts": "jenkins" + }, + "jinja": { "ids": "jinja", "exts": "jinja" }, + "json": { "ids": "json", "exts": "json" }, + "jsonc": { "ids": "jsonc", "exts": "jsonc" }, + "jsonnet": { "ids": "jsonnet", "exts": "jsonnet" }, + "json5": { "ids": "json5", "exts": "json5" }, + "julia": { "ids": ["julia", "juliamarkdown"], "exts": "jl" }, + "iodine": { "ids": "iodine", "exts": "id" }, + "kivy": { "ids": "kivy", "exts": "kv" }, + "kos": { "ids": "kos", "exts": "ks" }, + "kotlin": { "ids": "kotlin", "exts": "kt" }, + "less": { "ids": "less", "exts": "less" }, + "lisp": { "ids": "lisp", "exts": "lisp" }, + "literatehaskell": { "ids": ["literate haskell"], "exts": "lhs" }, + "lolcode": { "ids": "lolcode", "exts": "lol" }, + "lsl": { "ids": "lsl", "exts": "lsl" }, + "lua": { "ids": "lua", "exts": "lua" }, + "makefile": { "ids": "makefile", "exts": "mk" }, + "markdown": { "ids": "markdown", "exts": "md" }, + "marko": { "ids": "marko", "exts": "marko" }, + "matlab": { "ids": "matlab", "exts": "mat" }, + "maxscript": { "ids": "maxscript", "exts": "ms" }, + "mediawiki": { "ids": "mediawiki", "exts": "mediawiki" }, + "mel": { "ids": "mel", "exts": "mel" }, + "meson": { "ids": "meson", "exts": "meson.build" }, + "mjml": { "ids": "mjml", "exts": "mjml" }, + "mlang": { "ids": ["mlang", "powerquerymlanguage"], "exts": "pq" }, + "mojolicious": { "ids": "mojolicious", "exts": "ep" }, + "mongo": { "ids": "mongo", "exts": "mongo" }, + "mson": { "ids": "mson", "exts": "mson" }, + "nearley": { "ids": "nearley", "exts": "ne" }, + "nim": { "ids": ["nim", "nimble"], "exts": "nim" }, + "nsis": { "ids": ["nsis", "nfl", "nsl", "bridlensis"], "exts": "nsi" }, + "nunjucks": { "ids": "nunjucks", "exts": "nunjucks" }, + "objectivec": { "ids": "objective-c", "exts": "m" }, + "objectivecpp": { "ids": "objective-cpp", "exts": "mm" }, + "ocaml": { "ids": ["ocaml", "ocamllex", "menhir"], "exts": "ml" }, + "openEdge": { "ids": "abl", "exts": "w" }, + "openHAB": { "ids": "openhab", "exts": "things" }, + "pascal": { "ids": ["pascal", "objectpascal"], "exts": "pas" }, + "pddl": { "ids": "pddl", "exts": "pddl" }, + "pddlplan": { "ids": "plan", "exts": "plan" }, + "pddlhappenings": { "ids": "happenings", "exts": "happenings" }, + "perl": { "ids": "perl", "exts": "pl" }, + "perl6": { "ids": "perl6", "exts": "pl6" }, + "pgsql": { "ids": "pgsql", "exts": "pgsql" }, + "php": { "ids": "php", "exts": "php" }, + "pine": { "ids": "pine", "exts": "pine" }, + "pip": { "ids": "pip-requirements", "exts": "requirements.txt" }, + "plaintext": { "ids": "plaintext", "exts": "txt" }, + "platformio": { + "ids": ["platformio-debug.disassembly", "platformio-debug.memoryview", "platformio-debug.asm"], + "exts": "dbgasm" + }, + "plsql": { "ids": ["plsql", "oracle"], "exts": "ddl" }, + "polymer": { "ids": "polymer", "exts": "polymer" }, + "pony": { "ids": "pony", "exts": "pony" }, + "postcss": { "ids": "postcss", "exts": "pcss" }, + "powershell": { "ids": "powershell", "exts": "ps1" }, + "prisma": { "ids": "prisma", "exts": "prisma" }, + "processinglang": { "ids": "pde", "exts": "pde" }, + "prolog": { "ids": "prolog", "exts": "pro" }, + "prometheus": { "ids": "prometheus", "exts": "rules" }, + "properties": { "ids": "properties", "exts": "properties" }, + "protobuf": { "ids": ["proto3", "proto"], "exts": "proto" }, + "pug": { "ids": "jade", "exts": "pug" }, + "puppet": { "ids": "puppet", "exts": "pp" }, + "purescript": { "ids": "purescript", "exts": "purs" }, + "pyret": { "ids": "pyret", "exts": "arr" }, + "python": { "ids": "python", "exts": "py" }, + "qlik": { "ids": "qlik", "exts": "qvs" }, + "qml": { "ids": "qml", "exts": "qml" }, + "qsharp": { "ids": "qsharp", "exts": "qs" }, + "r": { "ids": "r", "exts": "r" }, + "racket": { "ids": "racket", "exts": "rkt" }, + "razor": { "ids": ["razor", "aspnetcorerazor"], "exts": "cshtml" }, + "raml": { "ids": "raml", "exts": "raml" }, + "reason": { "ids": "reason", "exts": "re" }, + "red": { "ids": "red", "exts": "red" }, + "restructuredtext": { "ids": "restructuredtext", "exts": "rst" }, + "riot": { "ids": "riot", "exts": "tag" }, + "robot": { "ids": "robot", "exts": "robot" }, + "ruby": { "ids": "ruby", "exts": "rb" }, + "rust": { "ids": "rust", "exts": "rs" }, + "san": { "ids": "san", "exts": "san" }, + "sbt": { "ids": "sbt", "exts": "sbt" }, + "scala": { "ids": "scala", "exts": "scala" }, + "scilab": { "ids": "scilab", "exts": "sce" }, + "scss": { "ids": "scss", "exts": "scss" }, + "sdlang": { "ids": "sdl", "exts": "sdl" }, + "shaderlab": { "ids": "shaderlab", "exts": "shader" }, + "shellscript": { "ids": "shellscript", "exts": "sh" }, + "slang": { "ids": "slang", "exts": "slang" }, + "slice": { "ids": ["slice"], "exts": "ice" }, + "slim": { "ids": ["slim"], "exts": "slim" }, + "silverstripe": { "ids": "silverstripe", "exts": "ss" }, + "skipper": { "ids": ["eskip"], "exts": "eskip" }, + "smarty": { "ids": ["smarty"], "exts": "tpl" }, + "snort": { "ids": ["snort"], "exts": "snort" }, + "solidity": { "ids": ["solidity"], "exts": "sol" }, + "sqf": { "ids": "sqf", "exts": "sqf" }, + "sql": { "ids": "sql", "exts": "sql" }, + "squirrel": { "ids": "squirrel", "exts": "nut" }, + "stan": { "ids": "stan", "exts": "stan" }, + "stata": { "ids": "stata", "exts": "do" }, + "stencil": { "ids": "stencil", "exts": "stencil" }, + "stencilhtml": { "ids": "stencil-html", "exts": "html.stencil" }, + "stylable": { "ids": "stylable", "exts": "st.css" }, + "styled": { "ids": "source.css.styled", "exts": "styled" }, + "stylus": { "ids": "stylus", "exts": "styl" }, + "svelte": { "ids": "svelte", "exts": "svelte" }, + "swagger": { "ids": ["Swagger", "swagger"], "exts": "swagger" }, + "swift": { "ids": "swift", "exts": "swift" }, + "swig": { "ids": "swig", "exts": "swig" }, + "systemd": { "ids": "systemd-unit-file", "exts": "link" }, + "systemverilog": { "ids": "systemverilog", "exts": "sv" }, + "t4": { "ids": "t4", "exts": "tt" }, + "templatetoolkit": { "ids": "tt", "exts": "tt3" }, + "tera": { "ids": "tera", "exts": "tera" }, + "terraform": { "ids": "terraform", "exts": "tf" }, + "tex": { "ids": "tex", "exts": "sty" }, + "textile": { "ids": "textile", "exts": "textile" }, + "textmatejson": { "ids": "json-tmlanguage", "exts": "JSON-tmLanguage" }, + "textmateyaml": { "ids": "yaml-tmlanguage", "exts": "YAML-tmLanguage" }, + "toml": { "ids": "toml", "exts": "toml" }, + "ttcn": { "ids": "ttcn", "exts": "ttcn3" }, + "twig": { "ids": "twig", "exts": "twig" }, + "typescript": { "ids": "typescript", "exts": "ts" }, + "typescriptreact": { "ids": "typescriptreact", "exts": "tsx" }, + "typo3": { "ids": "typoscript", "exts": "typoscript" }, + "vb": { "ids": "vb", "exts": "vb" }, + "vba": { "ids": "vba", "exts": "cls" }, + "vbscript": { "ids": "vbscript", "exts": "wsf" }, + "velocity": { "ids": "velocity", "exts": "vm" }, + "verilog": { "ids": "verilog", "exts": "v" }, + "vhdl": { "ids": "vhdl", "exts": "vhdl" }, + "viml": { "ids": "viml", "exts": "vim" }, + "vlang": { "ids": "v", "exts": "v" }, + "volt": { "ids": "volt", "exts": "volt" }, + "vue": { "ids": "vue", "exts": "vue" }, + "wasm": { "ids": ["wasm", "wat"], "exts": "wasm" }, + "wolfram": { "ids": "wolfram", "exts": "wl" }, + "wurst": { "ids": ["wurstlang", "wurst"], "exts": "wurst" }, + "wxml": { "ids": "wxml", "exts": "wxml" }, + "xml": { "ids": "xml", "exts": "xml" }, + "xquery": { "ids": "xquery", "exts": "xquery" }, + "xsl": { "ids": "xsl", "exts": "xsl" }, + "yaml": { "ids": "yaml", "exts": "yaml" }, + "yang": { "ids": "yang", "exts": "yang" } +}