prism-show-language.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. (function () {
  2. if (typeof Prism === 'undefined' || typeof document === 'undefined') {
  3. return;
  4. }
  5. if (!Prism.plugins.toolbar) {
  6. console.warn('Show Languages plugin loaded before Toolbar plugin.');
  7. return;
  8. }
  9. /* eslint-disable */
  10. // The languages map is built automatically with gulp
  11. var Languages = /*languages_placeholder[*/{
  12. "none": "Plain text",
  13. "plain": "Plain text",
  14. "plaintext": "Plain text",
  15. "text": "Plain text",
  16. "txt": "Plain text",
  17. "html": "HTML",
  18. "xml": "XML",
  19. "svg": "SVG",
  20. "mathml": "MathML",
  21. "ssml": "SSML",
  22. "rss": "RSS",
  23. "css": "CSS",
  24. "clike": "C-like",
  25. "js": "JavaScript",
  26. "abap": "ABAP",
  27. "abnf": "ABNF",
  28. "al": "AL",
  29. "antlr4": "ANTLR4",
  30. "g4": "ANTLR4",
  31. "apacheconf": "Apache Configuration",
  32. "apl": "APL",
  33. "aql": "AQL",
  34. "ino": "Arduino",
  35. "arff": "ARFF",
  36. "armasm": "ARM Assembly",
  37. "arm-asm": "ARM Assembly",
  38. "art": "Arturo",
  39. "asciidoc": "AsciiDoc",
  40. "adoc": "AsciiDoc",
  41. "aspnet": "ASP.NET (C#)",
  42. "asm6502": "6502 Assembly",
  43. "asmatmel": "Atmel AVR Assembly",
  44. "autohotkey": "AutoHotkey",
  45. "autoit": "AutoIt",
  46. "avisynth": "AviSynth",
  47. "avs": "AviSynth",
  48. "avro-idl": "Avro IDL",
  49. "avdl": "Avro IDL",
  50. "awk": "AWK",
  51. "gawk": "GAWK",
  52. "sh": "Shell",
  53. "basic": "BASIC",
  54. "bbcode": "BBcode",
  55. "bbj": "BBj",
  56. "bnf": "BNF",
  57. "rbnf": "RBNF",
  58. "bqn": "BQN",
  59. "bsl": "BSL (1C:Enterprise)",
  60. "oscript": "OneScript",
  61. "csharp": "C#",
  62. "cs": "C#",
  63. "dotnet": "C#",
  64. "cpp": "C++",
  65. "cfscript": "CFScript",
  66. "cfc": "CFScript",
  67. "cil": "CIL",
  68. "cilkc": "Cilk/C",
  69. "cilk-c": "Cilk/C",
  70. "cilkcpp": "Cilk/C++",
  71. "cilk-cpp": "Cilk/C++",
  72. "cilk": "Cilk/C++",
  73. "cmake": "CMake",
  74. "cobol": "COBOL",
  75. "coffee": "CoffeeScript",
  76. "conc": "Concurnas",
  77. "csp": "Content-Security-Policy",
  78. "css-extras": "CSS Extras",
  79. "csv": "CSV",
  80. "cue": "CUE",
  81. "dataweave": "DataWeave",
  82. "dax": "DAX",
  83. "django": "Django/Jinja2",
  84. "jinja2": "Django/Jinja2",
  85. "dns-zone-file": "DNS zone file",
  86. "dns-zone": "DNS zone file",
  87. "dockerfile": "Docker",
  88. "dot": "DOT (Graphviz)",
  89. "gv": "DOT (Graphviz)",
  90. "ebnf": "EBNF",
  91. "editorconfig": "EditorConfig",
  92. "ejs": "EJS",
  93. "etlua": "Embedded Lua templating",
  94. "erb": "ERB",
  95. "excel-formula": "Excel Formula",
  96. "xlsx": "Excel Formula",
  97. "xls": "Excel Formula",
  98. "fsharp": "F#",
  99. "firestore-security-rules": "Firestore security rules",
  100. "ftl": "FreeMarker Template Language",
  101. "gml": "GameMaker Language",
  102. "gamemakerlanguage": "GameMaker Language",
  103. "gap": "GAP (CAS)",
  104. "gcode": "G-code",
  105. "gdscript": "GDScript",
  106. "gedcom": "GEDCOM",
  107. "gettext": "gettext",
  108. "po": "gettext",
  109. "glsl": "GLSL",
  110. "gn": "GN",
  111. "gni": "GN",
  112. "linker-script": "GNU Linker Script",
  113. "ld": "GNU Linker Script",
  114. "go-module": "Go module",
  115. "go-mod": "Go module",
  116. "graphql": "GraphQL",
  117. "hbs": "Handlebars",
  118. "hs": "Haskell",
  119. "hcl": "HCL",
  120. "hlsl": "HLSL",
  121. "http": "HTTP",
  122. "hpkp": "HTTP Public-Key-Pins",
  123. "hsts": "HTTP Strict-Transport-Security",
  124. "ichigojam": "IchigoJam",
  125. "icu-message-format": "ICU Message Format",
  126. "idr": "Idris",
  127. "ignore": ".ignore",
  128. "gitignore": ".gitignore",
  129. "hgignore": ".hgignore",
  130. "npmignore": ".npmignore",
  131. "inform7": "Inform 7",
  132. "javadoc": "JavaDoc",
  133. "javadoclike": "JavaDoc-like",
  134. "javastacktrace": "Java stack trace",
  135. "jq": "JQ",
  136. "jsdoc": "JSDoc",
  137. "js-extras": "JS Extras",
  138. "json": "JSON",
  139. "webmanifest": "Web App Manifest",
  140. "json5": "JSON5",
  141. "jsonp": "JSONP",
  142. "jsstacktrace": "JS stack trace",
  143. "js-templates": "JS Templates",
  144. "keepalived": "Keepalived Configure",
  145. "kts": "Kotlin Script",
  146. "kt": "Kotlin",
  147. "kumir": "KuMir (КуМир)",
  148. "kum": "KuMir (КуМир)",
  149. "latex": "LaTeX",
  150. "tex": "TeX",
  151. "context": "ConTeXt",
  152. "lilypond": "LilyPond",
  153. "ly": "LilyPond",
  154. "emacs": "Lisp",
  155. "elisp": "Lisp",
  156. "emacs-lisp": "Lisp",
  157. "llvm": "LLVM IR",
  158. "log": "Log file",
  159. "lolcode": "LOLCODE",
  160. "magma": "Magma (CAS)",
  161. "md": "Markdown",
  162. "markup-templating": "Markup templating",
  163. "matlab": "MATLAB",
  164. "maxscript": "MAXScript",
  165. "mel": "MEL",
  166. "metafont": "METAFONT",
  167. "mongodb": "MongoDB",
  168. "moon": "MoonScript",
  169. "n1ql": "N1QL",
  170. "n4js": "N4JS",
  171. "n4jsd": "N4JS",
  172. "nand2tetris-hdl": "Nand To Tetris HDL",
  173. "naniscript": "Naninovel Script",
  174. "nani": "Naninovel Script",
  175. "nasm": "NASM",
  176. "neon": "NEON",
  177. "nginx": "nginx",
  178. "nsis": "NSIS",
  179. "objectivec": "Objective-C",
  180. "objc": "Objective-C",
  181. "ocaml": "OCaml",
  182. "opencl": "OpenCL",
  183. "openqasm": "OpenQasm",
  184. "qasm": "OpenQasm",
  185. "parigp": "PARI/GP",
  186. "objectpascal": "Object Pascal",
  187. "psl": "PATROL Scripting Language",
  188. "pcaxis": "PC-Axis",
  189. "px": "PC-Axis",
  190. "peoplecode": "PeopleCode",
  191. "pcode": "PeopleCode",
  192. "php": "PHP",
  193. "phpdoc": "PHPDoc",
  194. "php-extras": "PHP Extras",
  195. "plant-uml": "PlantUML",
  196. "plantuml": "PlantUML",
  197. "plsql": "PL/SQL",
  198. "powerquery": "PowerQuery",
  199. "pq": "PowerQuery",
  200. "mscript": "PowerQuery",
  201. "powershell": "PowerShell",
  202. "promql": "PromQL",
  203. "properties": ".properties",
  204. "protobuf": "Protocol Buffers",
  205. "purebasic": "PureBasic",
  206. "pbfasm": "PureBasic",
  207. "purs": "PureScript",
  208. "py": "Python",
  209. "qsharp": "Q#",
  210. "qs": "Q#",
  211. "q": "Q (kdb+ database)",
  212. "qml": "QML",
  213. "rkt": "Racket",
  214. "cshtml": "Razor C#",
  215. "razor": "Razor C#",
  216. "jsx": "React JSX",
  217. "tsx": "React TSX",
  218. "renpy": "Ren'py",
  219. "rpy": "Ren'py",
  220. "res": "ReScript",
  221. "rest": "reST (reStructuredText)",
  222. "robotframework": "Robot Framework",
  223. "robot": "Robot Framework",
  224. "rb": "Ruby",
  225. "sas": "SAS",
  226. "sass": "Sass (Sass)",
  227. "scss": "Sass (SCSS)",
  228. "shell-session": "Shell session",
  229. "sh-session": "Shell session",
  230. "shellsession": "Shell session",
  231. "sml": "SML",
  232. "smlnj": "SML/NJ",
  233. "solidity": "Solidity (Ethereum)",
  234. "sol": "Solidity (Ethereum)",
  235. "solution-file": "Solution file",
  236. "sln": "Solution file",
  237. "soy": "Soy (Closure Template)",
  238. "sparql": "SPARQL",
  239. "rq": "SPARQL",
  240. "splunk-spl": "Splunk SPL",
  241. "sqf": "SQF: Status Quo Function (Arma 3)",
  242. "sql": "SQL",
  243. "stata": "Stata Ado",
  244. "iecst": "Structured Text (IEC 61131-3)",
  245. "supercollider": "SuperCollider",
  246. "sclang": "SuperCollider",
  247. "systemd": "Systemd configuration file",
  248. "t4-templating": "T4 templating",
  249. "t4-cs": "T4 Text Templates (C#)",
  250. "t4": "T4 Text Templates (C#)",
  251. "t4-vb": "T4 Text Templates (VB)",
  252. "tap": "TAP",
  253. "tt2": "Template Toolkit 2",
  254. "toml": "TOML",
  255. "trickle": "trickle",
  256. "troy": "troy",
  257. "trig": "TriG",
  258. "ts": "TypeScript",
  259. "tsconfig": "TSConfig",
  260. "uscript": "UnrealScript",
  261. "uc": "UnrealScript",
  262. "uorazor": "UO Razor Script",
  263. "uri": "URI",
  264. "url": "URL",
  265. "vbnet": "VB.Net",
  266. "vhdl": "VHDL",
  267. "vim": "vim",
  268. "visual-basic": "Visual Basic",
  269. "vba": "VBA",
  270. "vb": "Visual Basic",
  271. "wasm": "WebAssembly",
  272. "web-idl": "Web IDL",
  273. "webidl": "Web IDL",
  274. "wgsl": "WGSL",
  275. "wiki": "Wiki markup",
  276. "wolfram": "Wolfram language",
  277. "nb": "Mathematica Notebook",
  278. "wl": "Wolfram language",
  279. "xeoracube": "XeoraCube",
  280. "xml-doc": "XML doc (.net)",
  281. "xojo": "Xojo (REALbasic)",
  282. "xquery": "XQuery",
  283. "yaml": "YAML",
  284. "yml": "YAML",
  285. "yang": "YANG"
  286. }/*]*/;
  287. /* eslint-enable */
  288. Prism.plugins.toolbar.registerButton('show-language', function (env) {
  289. var pre = env.element.parentNode;
  290. if (!pre || !/pre/i.test(pre.nodeName)) {
  291. return;
  292. }
  293. /**
  294. * Tries to guess the name of a language given its id.
  295. *
  296. * @param {string} id The language id.
  297. * @returns {string}
  298. */
  299. function guessTitle(id) {
  300. if (!id) {
  301. return id;
  302. }
  303. return (id.substring(0, 1).toUpperCase() + id.substring(1)).replace(/s(?=cript)/, 'S');
  304. }
  305. var language = pre.getAttribute('data-language') || Languages[env.language] || guessTitle(env.language);
  306. if (!language) {
  307. return;
  308. }
  309. var element = document.createElement('span');
  310. element.textContent = language;
  311. return element;
  312. });
  313. }());