MediaWiki:Gadget-prism-language-coffeescript.js

来自萌娘共享
跳转至: 导航搜索

注意:在保存之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Internet Explorer:按住Ctrl的同时单击刷新,或按Ctrl-F5
  • Opera:前往菜单 → 设置(Mac为Opera → Preferences),然后隐私和安全 → 清除浏览数据 → 缓存的图片和文件
  1. /**
  2. * -------------------------------------------------------------------------
  3. * !!! DON'T MODIFY THIS PAGE MANUALLY, YOUR CHANGES WILL BE OVERWRITTEN !!!
  4. * -------------------------------------------------------------------------
  5. */
  6. var _addText = '{{GHIACode|page=GHIA:MoegirlPediaInterfaceCodes/blob/master/src/gadgets/prism-language-coffeescript/Gadget-prism-language-coffeescript.js|user=[[U:AnnAngela]]|co-authors=GH:github-actions[bot]|longId=103d1a563ea4ccc8ff29fb55c9bcd88329a56eb5|shortId=103d1a56|summary=feat: rename (#594)|body=<nowiki>Co-authored-by: github-actions[bot] <41898282+github-actions[bot]📧users.noreply.github.com></nowiki>}}';
  7. /* <pre> */
  8. "use strict";
  9. (function (Prism) {
  10. var comment = /#(?!\{).+/;
  11. var interpolation = {
  12. pattern: /#\{[^}]+\}/,
  13. alias: 'variable'
  14. };
  15. Prism.languages.coffeescript = Prism.languages.extend('javascript', {
  16. 'comment': comment,
  17. 'string': [
  18. {
  19. pattern: /'(?:\\[\s\S]|[^\\'])*'/,
  20. greedy: true
  21. },
  22. {
  23. pattern: /"(?:\\[\s\S]|[^\\"])*"/,
  24. greedy: true,
  25. inside: {
  26. 'interpolation': interpolation
  27. }
  28. }
  29. ],
  30. 'keyword': /\b(?:and|break|by|catch|class|continue|debugger|delete|do|each|else|extend|extends|false|finally|for|if|in|instanceof|is|isnt|let|loop|namespace|new|no|not|null|of|off|on|or|own|return|super|switch|then|this|throw|true|try|typeof|undefined|unless|until|when|while|window|with|yes|yield)\b/,
  31. 'class-member': {
  32. pattern: /@(?!\d)\w+/,
  33. alias: 'variable'
  34. }
  35. });
  36. Prism.languages.insertBefore('coffeescript', 'comment', {
  37. 'multiline-comment': {
  38. pattern: /###[\s\S]+?###/,
  39. alias: 'comment'
  40. },
  41. 'block-regex': {
  42. pattern: /\/{3}[\s\S]*?\/{3}/,
  43. alias: 'regex',
  44. inside: {
  45. 'comment': comment,
  46. 'interpolation': interpolation
  47. }
  48. }
  49. });
  50. Prism.languages.insertBefore('coffeescript', 'string', {
  51. 'inline-javascript': {
  52. pattern: /`(?:\\[\s\S]|[^\\`])*`/,
  53. inside: {
  54. 'delimiter': {
  55. pattern: /^`|`$/,
  56. alias: 'punctuation'
  57. },
  58. 'script': {
  59. pattern: /[\s\S]+/,
  60. alias: 'language-javascript',
  61. inside: Prism.languages.javascript
  62. }
  63. }
  64. },
  65. 'multiline-string': [
  66. {
  67. pattern: /'''[\s\S]*?'''/,
  68. greedy: true,
  69. alias: 'string'
  70. },
  71. {
  72. pattern: /"""[\s\S]*?"""/,
  73. greedy: true,
  74. alias: 'string',
  75. inside: {
  76. interpolation: interpolation
  77. }
  78. }
  79. ]
  80. });
  81. Prism.languages.insertBefore('coffeescript', 'keyword', {
  82. 'property': /(?!\d)\w+(?=\s*:(?!:))/
  83. });
  84. delete Prism.languages.coffeescript['template-string'];
  85. Prism.languages.coffee = Prism.languages.coffeescript;
  86. }(Prism));
  87. /* </pre> */