prism-show-language.js 7.5 KB

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