create-nextjs-cms 0.5.56 → 0.5.58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (337) hide show
  1. package/package.json +4 -4
  2. package/templates/default/CHANGELOG.md +140 -140
  3. package/templates/default/_gitignore +1 -0
  4. package/templates/default/app/(rootLayout)/admins/page.tsx +7 -2
  5. package/templates/default/app/(rootLayout)/advanced/page.tsx +8 -2
  6. package/templates/default/app/(rootLayout)/browse/[section]/[page]/page.tsx +17 -3
  7. package/templates/default/app/(rootLayout)/categorized/[section]/page.tsx +9 -1
  8. package/templates/default/app/(rootLayout)/dashboard-new/page.tsx +7 -0
  9. package/templates/default/app/(rootLayout)/edit/[section]/[itemId]/page.tsx +11 -1
  10. package/templates/default/app/(rootLayout)/layout.tsx +8 -1
  11. package/templates/default/app/(rootLayout)/new/[section]/page.tsx +9 -1
  12. package/templates/default/app/(rootLayout)/section/[section]/page.tsx +10 -1
  13. package/templates/default/app/(rootLayout)/settings/page.tsx +7 -1
  14. package/templates/default/app/api/trpc/[trpc]/route.ts +1 -1
  15. package/templates/default/app/api/video/route.ts +1 -1
  16. package/templates/default/app/layout.tsx +1 -1
  17. package/templates/default/app/providers.tsx +4 -4
  18. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/LICENSE +191 -0
  19. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/README.md +118 -0
  20. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/install/build.js +38 -0
  21. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/install/check.js +14 -0
  22. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/channel.js +177 -0
  23. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/colour.js +195 -0
  24. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/composite.js +212 -0
  25. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/constructor.js +499 -0
  26. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/index.d.ts +1971 -0
  27. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/index.js +16 -0
  28. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/input.js +809 -0
  29. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/is.js +143 -0
  30. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/libvips.js +207 -0
  31. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/operation.js +1016 -0
  32. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/output.js +1666 -0
  33. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/resize.js +595 -0
  34. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/sharp.js +121 -0
  35. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/utility.js +291 -0
  36. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/package.json +202 -0
  37. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/binding.gyp +298 -0
  38. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/common.cc +1130 -0
  39. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/common.h +402 -0
  40. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/metadata.cc +346 -0
  41. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/metadata.h +90 -0
  42. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/operations.cc +499 -0
  43. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/operations.h +137 -0
  44. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/pipeline.cc +1814 -0
  45. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/pipeline.h +408 -0
  46. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/sharp.cc +43 -0
  47. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/stats.cc +186 -0
  48. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/stats.h +62 -0
  49. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/utilities.cc +288 -0
  50. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/utilities.h +22 -0
  51. package/templates/default/components/BrowsePage.tsx +4 -4
  52. package/templates/default/components/DashboardNewPage.tsx +252 -0
  53. package/templates/default/components/LogPage.tsx +2 -3
  54. package/templates/default/components/SettingsPage.tsx +1 -1
  55. package/templates/default/components/form/Form.tsx +5 -5
  56. package/templates/default/components/form/helpers/util.ts +5 -5
  57. package/templates/default/dynamic-schemas/schema.ts +381 -381
  58. package/templates/default/next-env.d.ts +1 -1
  59. package/templates/default/next.config.ts +24 -0
  60. package/templates/default/package.json +23 -17
  61. package/templates/default/{middleware.ts → proxy.ts} +3 -4
  62. package/templates/default/test/prize.section.ts +58 -0
  63. package/templates/default/tsconfig.json +6 -3
  64. package/templates/default/app/api/placeholder/route.ts +0 -7
  65. package/templates/default/components/form/helpers/_section-hot-reload.js +0 -11
  66. package/templates/default/public/tinymce/CHANGELOG.md +0 -3940
  67. package/templates/default/public/tinymce/README.md +0 -77
  68. package/templates/default/public/tinymce/bower.json +0 -27
  69. package/templates/default/public/tinymce/composer.json +0 -52
  70. package/templates/default/public/tinymce/icons/default/icons.js +0 -239
  71. package/templates/default/public/tinymce/icons/default/icons.min.js +0 -1
  72. package/templates/default/public/tinymce/icons/default/index.js +0 -7
  73. package/templates/default/public/tinymce/license.md +0 -9
  74. package/templates/default/public/tinymce/models/dom/index.js +0 -7
  75. package/templates/default/public/tinymce/models/dom/model.js +0 -8980
  76. package/templates/default/public/tinymce/models/dom/model.min.js +0 -1
  77. package/templates/default/public/tinymce/notices.txt +0 -21
  78. package/templates/default/public/tinymce/package.json +0 -32
  79. package/templates/default/public/tinymce/plugins/accordion/index.js +0 -7
  80. package/templates/default/public/tinymce/plugins/accordion/plugin.js +0 -1373
  81. package/templates/default/public/tinymce/plugins/accordion/plugin.min.js +0 -1
  82. package/templates/default/public/tinymce/plugins/advlist/index.js +0 -7
  83. package/templates/default/public/tinymce/plugins/advlist/plugin.js +0 -473
  84. package/templates/default/public/tinymce/plugins/advlist/plugin.min.js +0 -1
  85. package/templates/default/public/tinymce/plugins/anchor/index.js +0 -7
  86. package/templates/default/public/tinymce/plugins/anchor/plugin.js +0 -237
  87. package/templates/default/public/tinymce/plugins/anchor/plugin.min.js +0 -1
  88. package/templates/default/public/tinymce/plugins/autolink/index.js +0 -7
  89. package/templates/default/public/tinymce/plugins/autolink/plugin.js +0 -315
  90. package/templates/default/public/tinymce/plugins/autolink/plugin.min.js +0 -1
  91. package/templates/default/public/tinymce/plugins/autoresize/index.js +0 -7
  92. package/templates/default/public/tinymce/plugins/autoresize/plugin.js +0 -221
  93. package/templates/default/public/tinymce/plugins/autoresize/plugin.min.js +0 -1
  94. package/templates/default/public/tinymce/plugins/autosave/index.js +0 -7
  95. package/templates/default/public/tinymce/plugins/autosave/plugin.js +0 -249
  96. package/templates/default/public/tinymce/plugins/autosave/plugin.min.js +0 -1
  97. package/templates/default/public/tinymce/plugins/charmap/index.js +0 -7
  98. package/templates/default/public/tinymce/plugins/charmap/plugin.js +0 -997
  99. package/templates/default/public/tinymce/plugins/charmap/plugin.min.js +0 -1
  100. package/templates/default/public/tinymce/plugins/code/index.js +0 -7
  101. package/templates/default/public/tinymce/plugins/code/plugin.js +0 -98
  102. package/templates/default/public/tinymce/plugins/code/plugin.min.js +0 -1
  103. package/templates/default/public/tinymce/plugins/codesample/index.js +0 -7
  104. package/templates/default/public/tinymce/plugins/codesample/plugin.js +0 -3655
  105. package/templates/default/public/tinymce/plugins/codesample/plugin.min.js +0 -9
  106. package/templates/default/public/tinymce/plugins/directionality/index.js +0 -7
  107. package/templates/default/public/tinymce/plugins/directionality/plugin.js +0 -634
  108. package/templates/default/public/tinymce/plugins/directionality/plugin.min.js +0 -1
  109. package/templates/default/public/tinymce/plugins/emoticons/index.js +0 -7
  110. package/templates/default/public/tinymce/plugins/emoticons/js/emojiimages.js +0 -1
  111. package/templates/default/public/tinymce/plugins/emoticons/js/emojiimages.min.js +0 -1
  112. package/templates/default/public/tinymce/plugins/emoticons/js/emojis.js +0 -1
  113. package/templates/default/public/tinymce/plugins/emoticons/js/emojis.min.js +0 -1
  114. package/templates/default/public/tinymce/plugins/emoticons/plugin.js +0 -809
  115. package/templates/default/public/tinymce/plugins/emoticons/plugin.min.js +0 -1
  116. package/templates/default/public/tinymce/plugins/fullscreen/index.js +0 -7
  117. package/templates/default/public/tinymce/plugins/fullscreen/plugin.js +0 -1607
  118. package/templates/default/public/tinymce/plugins/fullscreen/plugin.min.js +0 -1
  119. package/templates/default/public/tinymce/plugins/help/index.js +0 -7
  120. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/ar.js +0 -93
  121. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/bg-BG.js +0 -93
  122. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/bg_BG.js +0 -93
  123. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/ca.js +0 -93
  124. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/cs.js +0 -93
  125. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/da.js +0 -93
  126. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/de.js +0 -93
  127. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/el.js +0 -93
  128. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/en.js +0 -93
  129. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/es.js +0 -93
  130. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/eu.js +0 -93
  131. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/fa.js +0 -93
  132. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/fi.js +0 -93
  133. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/fr-FR.js +0 -93
  134. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/fr_FR.js +0 -93
  135. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/he-IL.js +0 -93
  136. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/he_IL.js +0 -93
  137. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/hi.js +0 -93
  138. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/hr.js +0 -93
  139. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/hu-HU.js +0 -93
  140. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/hu_HU.js +0 -93
  141. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/id.js +0 -93
  142. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/it.js +0 -93
  143. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/ja.js +0 -93
  144. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/kk.js +0 -93
  145. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/ko-KR.js +0 -93
  146. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/ko_KR.js +0 -93
  147. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/ms.js +0 -93
  148. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/nb-NO.js +0 -93
  149. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/nb_NO.js +0 -93
  150. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/nl.js +0 -93
  151. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/pl.js +0 -93
  152. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/pt-BR.js +0 -93
  153. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/pt-PT.js +0 -93
  154. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/pt_BR.js +0 -93
  155. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/pt_PT.js +0 -93
  156. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/ro.js +0 -93
  157. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/ru.js +0 -93
  158. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/sk.js +0 -93
  159. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/sl-SI.js +0 -93
  160. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/sl_SI.js +0 -93
  161. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/sv-SE.js +0 -93
  162. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/sv_SE.js +0 -93
  163. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/th-TH.js +0 -93
  164. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/th_TH.js +0 -93
  165. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/tr.js +0 -93
  166. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/uk.js +0 -93
  167. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/vi.js +0 -93
  168. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/zh-CN.js +0 -87
  169. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/zh-TW.js +0 -93
  170. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/zh_CN.js +0 -87
  171. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/zh_TW.js +0 -93
  172. package/templates/default/public/tinymce/plugins/help/plugin.js +0 -826
  173. package/templates/default/public/tinymce/plugins/help/plugin.min.js +0 -1
  174. package/templates/default/public/tinymce/plugins/image/index.js +0 -7
  175. package/templates/default/public/tinymce/plugins/image/plugin.js +0 -1691
  176. package/templates/default/public/tinymce/plugins/image/plugin.min.js +0 -1
  177. package/templates/default/public/tinymce/plugins/importcss/index.js +0 -7
  178. package/templates/default/public/tinymce/plugins/importcss/plugin.js +0 -401
  179. package/templates/default/public/tinymce/plugins/importcss/plugin.min.js +0 -1
  180. package/templates/default/public/tinymce/plugins/insertdatetime/index.js +0 -7
  181. package/templates/default/public/tinymce/plugins/insertdatetime/plugin.js +0 -187
  182. package/templates/default/public/tinymce/plugins/insertdatetime/plugin.min.js +0 -1
  183. package/templates/default/public/tinymce/plugins/link/index.js +0 -7
  184. package/templates/default/public/tinymce/plugins/link/plugin.js +0 -1709
  185. package/templates/default/public/tinymce/plugins/link/plugin.min.js +0 -1
  186. package/templates/default/public/tinymce/plugins/lists/index.js +0 -7
  187. package/templates/default/public/tinymce/plugins/lists/plugin.js +0 -602
  188. package/templates/default/public/tinymce/plugins/lists/plugin.min.js +0 -1
  189. package/templates/default/public/tinymce/plugins/media/index.js +0 -7
  190. package/templates/default/public/tinymce/plugins/media/plugin.js +0 -1442
  191. package/templates/default/public/tinymce/plugins/media/plugin.min.js +0 -1
  192. package/templates/default/public/tinymce/plugins/nonbreaking/index.js +0 -7
  193. package/templates/default/public/tinymce/plugins/nonbreaking/plugin.js +0 -128
  194. package/templates/default/public/tinymce/plugins/nonbreaking/plugin.min.js +0 -1
  195. package/templates/default/public/tinymce/plugins/pagebreak/index.js +0 -7
  196. package/templates/default/public/tinymce/plugins/pagebreak/plugin.js +0 -123
  197. package/templates/default/public/tinymce/plugins/pagebreak/plugin.min.js +0 -1
  198. package/templates/default/public/tinymce/plugins/preview/index.js +0 -7
  199. package/templates/default/public/tinymce/plugins/preview/plugin.js +0 -843
  200. package/templates/default/public/tinymce/plugins/preview/plugin.min.js +0 -1
  201. package/templates/default/public/tinymce/plugins/quickbars/index.js +0 -7
  202. package/templates/default/public/tinymce/plugins/quickbars/plugin.js +0 -654
  203. package/templates/default/public/tinymce/plugins/quickbars/plugin.min.js +0 -1
  204. package/templates/default/public/tinymce/plugins/save/index.js +0 -7
  205. package/templates/default/public/tinymce/plugins/save/plugin.js +0 -136
  206. package/templates/default/public/tinymce/plugins/save/plugin.min.js +0 -1
  207. package/templates/default/public/tinymce/plugins/searchreplace/index.js +0 -7
  208. package/templates/default/public/tinymce/plugins/searchreplace/plugin.js +0 -1367
  209. package/templates/default/public/tinymce/plugins/searchreplace/plugin.min.js +0 -1
  210. package/templates/default/public/tinymce/plugins/table/index.js +0 -7
  211. package/templates/default/public/tinymce/plugins/table/plugin.js +0 -4008
  212. package/templates/default/public/tinymce/plugins/table/plugin.min.js +0 -1
  213. package/templates/default/public/tinymce/plugins/visualblocks/index.js +0 -7
  214. package/templates/default/public/tinymce/plugins/visualblocks/plugin.js +0 -106
  215. package/templates/default/public/tinymce/plugins/visualblocks/plugin.min.js +0 -1
  216. package/templates/default/public/tinymce/plugins/visualchars/index.js +0 -7
  217. package/templates/default/public/tinymce/plugins/visualchars/plugin.js +0 -808
  218. package/templates/default/public/tinymce/plugins/visualchars/plugin.min.js +0 -1
  219. package/templates/default/public/tinymce/plugins/wordcount/index.js +0 -7
  220. package/templates/default/public/tinymce/plugins/wordcount/plugin.js +0 -480
  221. package/templates/default/public/tinymce/plugins/wordcount/plugin.min.js +0 -1
  222. package/templates/default/public/tinymce/skins/content/dark/content.css +0 -75
  223. package/templates/default/public/tinymce/skins/content/dark/content.js +0 -10
  224. package/templates/default/public/tinymce/skins/content/dark/content.min.css +0 -10
  225. package/templates/default/public/tinymce/skins/content/dark/content.min.ts +0 -3
  226. package/templates/default/public/tinymce/skins/content/dark/content.ts +0 -3
  227. package/templates/default/public/tinymce/skins/content/default/content.css +0 -70
  228. package/templates/default/public/tinymce/skins/content/default/content.js +0 -10
  229. package/templates/default/public/tinymce/skins/content/default/content.min.css +0 -10
  230. package/templates/default/public/tinymce/skins/content/default/content.min.ts +0 -3
  231. package/templates/default/public/tinymce/skins/content/default/content.ts +0 -3
  232. package/templates/default/public/tinymce/skins/content/document/content.css +0 -75
  233. package/templates/default/public/tinymce/skins/content/document/content.js +0 -10
  234. package/templates/default/public/tinymce/skins/content/document/content.min.css +0 -10
  235. package/templates/default/public/tinymce/skins/content/document/content.min.ts +0 -3
  236. package/templates/default/public/tinymce/skins/content/document/content.ts +0 -3
  237. package/templates/default/public/tinymce/skins/content/tinymce-5/content.css +0 -70
  238. package/templates/default/public/tinymce/skins/content/tinymce-5/content.js +0 -10
  239. package/templates/default/public/tinymce/skins/content/tinymce-5/content.min.css +0 -10
  240. package/templates/default/public/tinymce/skins/content/tinymce-5/content.min.ts +0 -3
  241. package/templates/default/public/tinymce/skins/content/tinymce-5/content.ts +0 -3
  242. package/templates/default/public/tinymce/skins/content/tinymce-5-dark/content.css +0 -75
  243. package/templates/default/public/tinymce/skins/content/tinymce-5-dark/content.js +0 -10
  244. package/templates/default/public/tinymce/skins/content/tinymce-5-dark/content.min.css +0 -10
  245. package/templates/default/public/tinymce/skins/content/tinymce-5-dark/content.min.ts +0 -3
  246. package/templates/default/public/tinymce/skins/content/tinymce-5-dark/content.ts +0 -3
  247. package/templates/default/public/tinymce/skins/content/writer/content.css +0 -71
  248. package/templates/default/public/tinymce/skins/content/writer/content.js +0 -10
  249. package/templates/default/public/tinymce/skins/content/writer/content.min.css +0 -10
  250. package/templates/default/public/tinymce/skins/content/writer/content.min.ts +0 -3
  251. package/templates/default/public/tinymce/skins/content/writer/content.ts +0 -3
  252. package/templates/default/public/tinymce/skins/ui/oxide/content.css +0 -1037
  253. package/templates/default/public/tinymce/skins/ui/oxide/content.inline.css +0 -1031
  254. package/templates/default/public/tinymce/skins/ui/oxide/content.inline.js +0 -10
  255. package/templates/default/public/tinymce/skins/ui/oxide/content.inline.min.css +0 -10
  256. package/templates/default/public/tinymce/skins/ui/oxide/content.inline.min.ts +0 -116
  257. package/templates/default/public/tinymce/skins/ui/oxide/content.inline.ts +0 -116
  258. package/templates/default/public/tinymce/skins/ui/oxide/content.js +0 -10
  259. package/templates/default/public/tinymce/skins/ui/oxide/content.min.css +0 -10
  260. package/templates/default/public/tinymce/skins/ui/oxide/content.min.ts +0 -116
  261. package/templates/default/public/tinymce/skins/ui/oxide/content.ts +0 -116
  262. package/templates/default/public/tinymce/skins/ui/oxide/skin.css +0 -5615
  263. package/templates/default/public/tinymce/skins/ui/oxide/skin.js +0 -1
  264. package/templates/default/public/tinymce/skins/ui/oxide/skin.min.css +0 -1
  265. package/templates/default/public/tinymce/skins/ui/oxide/skin.min.ts +0 -507
  266. package/templates/default/public/tinymce/skins/ui/oxide/skin.shadowdom.css +0 -30
  267. package/templates/default/public/tinymce/skins/ui/oxide/skin.shadowdom.js +0 -1
  268. package/templates/default/public/tinymce/skins/ui/oxide/skin.shadowdom.min.css +0 -1
  269. package/templates/default/public/tinymce/skins/ui/oxide/skin.shadowdom.min.ts +0 -9
  270. package/templates/default/public/tinymce/skins/ui/oxide/skin.shadowdom.ts +0 -9
  271. package/templates/default/public/tinymce/skins/ui/oxide/skin.ts +0 -507
  272. package/templates/default/public/tinymce/skins/ui/oxide-dark/content.css +0 -1025
  273. package/templates/default/public/tinymce/skins/ui/oxide-dark/content.inline.css +0 -1031
  274. package/templates/default/public/tinymce/skins/ui/oxide-dark/content.inline.js +0 -10
  275. package/templates/default/public/tinymce/skins/ui/oxide-dark/content.inline.min.css +0 -10
  276. package/templates/default/public/tinymce/skins/ui/oxide-dark/content.inline.min.ts +0 -116
  277. package/templates/default/public/tinymce/skins/ui/oxide-dark/content.inline.ts +0 -116
  278. package/templates/default/public/tinymce/skins/ui/oxide-dark/content.js +0 -10
  279. package/templates/default/public/tinymce/skins/ui/oxide-dark/content.min.css +0 -10
  280. package/templates/default/public/tinymce/skins/ui/oxide-dark/content.min.ts +0 -116
  281. package/templates/default/public/tinymce/skins/ui/oxide-dark/content.ts +0 -116
  282. package/templates/default/public/tinymce/skins/ui/oxide-dark/skin.css +0 -5618
  283. package/templates/default/public/tinymce/skins/ui/oxide-dark/skin.js +0 -1
  284. package/templates/default/public/tinymce/skins/ui/oxide-dark/skin.min.css +0 -1
  285. package/templates/default/public/tinymce/skins/ui/oxide-dark/skin.min.ts +0 -507
  286. package/templates/default/public/tinymce/skins/ui/oxide-dark/skin.shadowdom.css +0 -30
  287. package/templates/default/public/tinymce/skins/ui/oxide-dark/skin.shadowdom.js +0 -1
  288. package/templates/default/public/tinymce/skins/ui/oxide-dark/skin.shadowdom.min.css +0 -1
  289. package/templates/default/public/tinymce/skins/ui/oxide-dark/skin.shadowdom.min.ts +0 -9
  290. package/templates/default/public/tinymce/skins/ui/oxide-dark/skin.shadowdom.ts +0 -9
  291. package/templates/default/public/tinymce/skins/ui/oxide-dark/skin.ts +0 -507
  292. package/templates/default/public/tinymce/skins/ui/tinymce-5/content.css +0 -1037
  293. package/templates/default/public/tinymce/skins/ui/tinymce-5/content.inline.css +0 -1031
  294. package/templates/default/public/tinymce/skins/ui/tinymce-5/content.inline.js +0 -10
  295. package/templates/default/public/tinymce/skins/ui/tinymce-5/content.inline.min.css +0 -10
  296. package/templates/default/public/tinymce/skins/ui/tinymce-5/content.inline.min.ts +0 -116
  297. package/templates/default/public/tinymce/skins/ui/tinymce-5/content.inline.ts +0 -116
  298. package/templates/default/public/tinymce/skins/ui/tinymce-5/content.js +0 -10
  299. package/templates/default/public/tinymce/skins/ui/tinymce-5/content.min.css +0 -10
  300. package/templates/default/public/tinymce/skins/ui/tinymce-5/content.min.ts +0 -116
  301. package/templates/default/public/tinymce/skins/ui/tinymce-5/content.ts +0 -116
  302. package/templates/default/public/tinymce/skins/ui/tinymce-5/skin.css +0 -5734
  303. package/templates/default/public/tinymce/skins/ui/tinymce-5/skin.js +0 -1
  304. package/templates/default/public/tinymce/skins/ui/tinymce-5/skin.min.css +0 -1
  305. package/templates/default/public/tinymce/skins/ui/tinymce-5/skin.min.ts +0 -508
  306. package/templates/default/public/tinymce/skins/ui/tinymce-5/skin.shadowdom.css +0 -30
  307. package/templates/default/public/tinymce/skins/ui/tinymce-5/skin.shadowdom.js +0 -1
  308. package/templates/default/public/tinymce/skins/ui/tinymce-5/skin.shadowdom.min.css +0 -1
  309. package/templates/default/public/tinymce/skins/ui/tinymce-5/skin.shadowdom.min.ts +0 -9
  310. package/templates/default/public/tinymce/skins/ui/tinymce-5/skin.shadowdom.ts +0 -9
  311. package/templates/default/public/tinymce/skins/ui/tinymce-5/skin.ts +0 -508
  312. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/content.css +0 -1025
  313. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/content.inline.css +0 -1031
  314. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/content.inline.js +0 -10
  315. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/content.inline.min.css +0 -10
  316. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/content.inline.min.ts +0 -116
  317. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/content.inline.ts +0 -116
  318. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/content.js +0 -10
  319. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/content.min.css +0 -10
  320. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/content.min.ts +0 -116
  321. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/content.ts +0 -116
  322. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/skin.css +0 -5734
  323. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/skin.js +0 -1
  324. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/skin.min.css +0 -1
  325. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/skin.min.ts +0 -508
  326. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/skin.shadowdom.css +0 -30
  327. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/skin.shadowdom.js +0 -1
  328. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/skin.shadowdom.min.css +0 -1
  329. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/skin.shadowdom.min.ts +0 -9
  330. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/skin.shadowdom.ts +0 -9
  331. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/skin.ts +0 -508
  332. package/templates/default/public/tinymce/themes/silver/index.js +0 -7
  333. package/templates/default/public/tinymce/themes/silver/theme.js +0 -34748
  334. package/templates/default/public/tinymce/themes/silver/theme.min.js +0 -1
  335. package/templates/default/public/tinymce/tinymce.d.ts +0 -3413
  336. package/templates/default/public/tinymce/tinymce.js +0 -41518
  337. package/templates/default/public/tinymce/tinymce.min.js +0 -10
@@ -1,3655 +0,0 @@
1
- /**
2
- * TinyMCE version 8.3.1 (2025-12-17)
3
- */
4
-
5
- (function () {
6
- 'use strict';
7
-
8
- var global$2 = tinymce.util.Tools.resolve('tinymce.PluginManager');
9
-
10
- /* eslint-disable @typescript-eslint/no-wrapper-object-types */
11
- const isNullable = (a) => a === null || a === undefined;
12
- const isNonNullable = (a) => !isNullable(a);
13
-
14
- const noop = () => { };
15
- const constant = (value) => {
16
- return () => {
17
- return value;
18
- };
19
- };
20
-
21
- /**
22
- * The `Optional` type represents a value (of any type) that potentially does
23
- * not exist. Any `Optional<T>` can either be a `Some<T>` (in which case the
24
- * value does exist) or a `None` (in which case the value does not exist). This
25
- * module defines a whole lot of FP-inspired utility functions for dealing with
26
- * `Optional` objects.
27
- *
28
- * Comparison with null or undefined:
29
- * - We don't get fancy null coalescing operators with `Optional`
30
- * - We do get fancy helper functions with `Optional`
31
- * - `Optional` support nesting, and allow for the type to still be nullable (or
32
- * another `Optional`)
33
- * - There is no option to turn off strict-optional-checks like there is for
34
- * strict-null-checks
35
- */
36
- class Optional {
37
- tag;
38
- value;
39
- // Sneaky optimisation: every instance of Optional.none is identical, so just
40
- // reuse the same object
41
- static singletonNone = new Optional(false);
42
- // The internal representation has a `tag` and a `value`, but both are
43
- // private: able to be console.logged, but not able to be accessed by code
44
- constructor(tag, value) {
45
- this.tag = tag;
46
- this.value = value;
47
- }
48
- // --- Identities ---
49
- /**
50
- * Creates a new `Optional<T>` that **does** contain a value.
51
- */
52
- static some(value) {
53
- return new Optional(true, value);
54
- }
55
- /**
56
- * Create a new `Optional<T>` that **does not** contain a value. `T` can be
57
- * any type because we don't actually have a `T`.
58
- */
59
- static none() {
60
- return Optional.singletonNone;
61
- }
62
- /**
63
- * Perform a transform on an `Optional` type. Regardless of whether this
64
- * `Optional` contains a value or not, `fold` will return a value of type `U`.
65
- * If this `Optional` does not contain a value, the `U` will be created by
66
- * calling `onNone`. If this `Optional` does contain a value, the `U` will be
67
- * created by calling `onSome`.
68
- *
69
- * For the FP enthusiasts in the room, this function:
70
- * 1. Could be used to implement all of the functions below
71
- * 2. Forms a catamorphism
72
- */
73
- fold(onNone, onSome) {
74
- if (this.tag) {
75
- return onSome(this.value);
76
- }
77
- else {
78
- return onNone();
79
- }
80
- }
81
- /**
82
- * Determine if this `Optional` object contains a value.
83
- */
84
- isSome() {
85
- return this.tag;
86
- }
87
- /**
88
- * Determine if this `Optional` object **does not** contain a value.
89
- */
90
- isNone() {
91
- return !this.tag;
92
- }
93
- // --- Functor (name stolen from Haskell / maths) ---
94
- /**
95
- * Perform a transform on an `Optional` object, **if** there is a value. If
96
- * you provide a function to turn a T into a U, this is the function you use
97
- * to turn an `Optional<T>` into an `Optional<U>`. If this **does** contain
98
- * a value then the output will also contain a value (that value being the
99
- * output of `mapper(this.value)`), and if this **does not** contain a value
100
- * then neither will the output.
101
- */
102
- map(mapper) {
103
- if (this.tag) {
104
- return Optional.some(mapper(this.value));
105
- }
106
- else {
107
- return Optional.none();
108
- }
109
- }
110
- // --- Monad (name stolen from Haskell / maths) ---
111
- /**
112
- * Perform a transform on an `Optional` object, **if** there is a value.
113
- * Unlike `map`, here the transform itself also returns an `Optional`.
114
- */
115
- bind(binder) {
116
- if (this.tag) {
117
- return binder(this.value);
118
- }
119
- else {
120
- return Optional.none();
121
- }
122
- }
123
- // --- Traversable (name stolen from Haskell / maths) ---
124
- /**
125
- * For a given predicate, this function finds out if there **exists** a value
126
- * inside this `Optional` object that meets the predicate. In practice, this
127
- * means that for `Optional`s that do not contain a value it returns false (as
128
- * no predicate-meeting value exists).
129
- */
130
- exists(predicate) {
131
- return this.tag && predicate(this.value);
132
- }
133
- /**
134
- * For a given predicate, this function finds out if **all** the values inside
135
- * this `Optional` object meet the predicate. In practice, this means that
136
- * for `Optional`s that do not contain a value it returns true (as all 0
137
- * objects do meet the predicate).
138
- */
139
- forall(predicate) {
140
- return !this.tag || predicate(this.value);
141
- }
142
- filter(predicate) {
143
- if (!this.tag || predicate(this.value)) {
144
- return this;
145
- }
146
- else {
147
- return Optional.none();
148
- }
149
- }
150
- // --- Getters ---
151
- /**
152
- * Get the value out of the inside of the `Optional` object, using a default
153
- * `replacement` value if the provided `Optional` object does not contain a
154
- * value.
155
- */
156
- getOr(replacement) {
157
- return this.tag ? this.value : replacement;
158
- }
159
- /**
160
- * Get the value out of the inside of the `Optional` object, using a default
161
- * `replacement` value if the provided `Optional` object does not contain a
162
- * value. Unlike `getOr`, in this method the `replacement` object is also
163
- * `Optional` - meaning that this method will always return an `Optional`.
164
- */
165
- or(replacement) {
166
- return this.tag ? this : replacement;
167
- }
168
- /**
169
- * Get the value out of the inside of the `Optional` object, using a default
170
- * `replacement` value if the provided `Optional` object does not contain a
171
- * value. Unlike `getOr`, in this method the `replacement` value is
172
- * "thunked" - that is to say that you don't pass a value to `getOrThunk`, you
173
- * pass a function which (if called) will **return** the `value` you want to
174
- * use.
175
- */
176
- getOrThunk(thunk) {
177
- return this.tag ? this.value : thunk();
178
- }
179
- /**
180
- * Get the value out of the inside of the `Optional` object, using a default
181
- * `replacement` value if the provided Optional object does not contain a
182
- * value.
183
- *
184
- * Unlike `or`, in this method the `replacement` value is "thunked" - that is
185
- * to say that you don't pass a value to `orThunk`, you pass a function which
186
- * (if called) will **return** the `value` you want to use.
187
- *
188
- * Unlike `getOrThunk`, in this method the `replacement` value is also
189
- * `Optional`, meaning that this method will always return an `Optional`.
190
- */
191
- orThunk(thunk) {
192
- return this.tag ? this : thunk();
193
- }
194
- /**
195
- * Get the value out of the inside of the `Optional` object, throwing an
196
- * exception if the provided `Optional` object does not contain a value.
197
- *
198
- * WARNING:
199
- * You should only be using this function if you know that the `Optional`
200
- * object **is not** empty (otherwise you're throwing exceptions in production
201
- * code, which is bad).
202
- *
203
- * In tests this is more acceptable.
204
- *
205
- * Prefer other methods to this, such as `.each`.
206
- */
207
- getOrDie(message) {
208
- if (!this.tag) {
209
- throw new Error(message ?? 'Called getOrDie on None');
210
- }
211
- else {
212
- return this.value;
213
- }
214
- }
215
- // --- Interop with null and undefined ---
216
- /**
217
- * Creates an `Optional` value from a nullable (or undefined-able) input.
218
- * Null, or undefined, is converted to `None`, and anything else is converted
219
- * to `Some`.
220
- */
221
- static from(value) {
222
- return isNonNullable(value) ? Optional.some(value) : Optional.none();
223
- }
224
- /**
225
- * Converts an `Optional` to a nullable type, by getting the value if it
226
- * exists, or returning `null` if it does not.
227
- */
228
- getOrNull() {
229
- return this.tag ? this.value : null;
230
- }
231
- /**
232
- * Converts an `Optional` to an undefined-able type, by getting the value if
233
- * it exists, or returning `undefined` if it does not.
234
- */
235
- getOrUndefined() {
236
- return this.value;
237
- }
238
- // --- Utilities ---
239
- /**
240
- * If the `Optional` contains a value, perform an action on that value.
241
- * Unlike the rest of the methods on this type, `.each` has side-effects. If
242
- * you want to transform an `Optional<T>` **into** something, then this is not
243
- * the method for you. If you want to use an `Optional<T>` to **do**
244
- * something, then this is the method for you - provided you're okay with not
245
- * doing anything in the case where the `Optional` doesn't have a value inside
246
- * it. If you're not sure whether your use-case fits into transforming
247
- * **into** something or **doing** something, check whether it has a return
248
- * value. If it does, you should be performing a transform.
249
- */
250
- each(worker) {
251
- if (this.tag) {
252
- worker(this.value);
253
- }
254
- }
255
- /**
256
- * Turn the `Optional` object into an array that contains all of the values
257
- * stored inside the `Optional`. In practice, this means the output will have
258
- * either 0 or 1 elements.
259
- */
260
- toArray() {
261
- return this.tag ? [this.value] : [];
262
- }
263
- /**
264
- * Turn the `Optional` object into a string for debugging or printing. Not
265
- * recommended for production code, but good for debugging. Also note that
266
- * these days an `Optional` object can be logged to the console directly, and
267
- * its inner value (if it exists) will be visible.
268
- */
269
- toString() {
270
- return this.tag ? `some(${this.value})` : 'none()';
271
- }
272
- }
273
-
274
- const get$1 = (xs, i) => i >= 0 && i < xs.length ? Optional.some(xs[i]) : Optional.none();
275
- const head = (xs) => get$1(xs, 0);
276
-
277
- // Use window object as the global if it's available since CSP will block script evals
278
- // eslint-disable-next-line @typescript-eslint/no-implied-eval
279
- const Global = typeof window !== 'undefined' ? window : Function('return this;')();
280
-
281
- const blank = (r) => (s) => s.replace(r, '');
282
- /** removes all leading and trailing spaces */
283
- const trim = blank(/^\s+|\s+$/g);
284
-
285
- var global$1 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
286
-
287
- const prismjs = function(global, module, exports) {
288
- // preserve the global if it has already been loaded
289
- const oldprism = window.Prism;
290
- window.Prism = { manual: true };
291
- /// <reference lib="WebWorker"/>
292
-
293
- var _self = (typeof window !== 'undefined')
294
- ? window // if in browser
295
- : (
296
- (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
297
- ? self // if in worker
298
- : {} // if in node js
299
- );
300
-
301
- /**
302
- * Prism: Lightweight, robust, elegant syntax highlighting
303
- *
304
- * @license MIT <https://opensource.org/licenses/MIT>
305
- * @author Lea Verou <https://lea.verou.me>
306
- * @namespace
307
- * @public
308
- */
309
- var Prism = (function (_self) {
310
-
311
- // Private helper vars
312
- var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i;
313
- var uniqueId = 0;
314
-
315
- // The grammar object for plaintext
316
- var plainTextGrammar = {};
317
-
318
-
319
- var _ = {
320
- /**
321
- * By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
322
- * current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
323
- * additional languages or plugins yourself.
324
- *
325
- * By setting this value to `true`, Prism will not automatically highlight all code elements on the page.
326
- *
327
- * You obviously have to change this value before the automatic highlighting started. To do this, you can add an
328
- * empty Prism object into the global scope before loading the Prism script like this:
329
- *
330
- * ```js
331
- * window.Prism = window.Prism || {};
332
- * Prism.manual = true;
333
- * // add a new <script> to load Prism's script
334
- * ```
335
- *
336
- * @default false
337
- * @type {boolean}
338
- * @memberof Prism
339
- * @public
340
- */
341
- manual: _self.Prism && _self.Prism.manual,
342
- /**
343
- * By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses
344
- * `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your
345
- * own worker, you don't want it to do this.
346
- *
347
- * By setting this value to `true`, Prism will not add its own listeners to the worker.
348
- *
349
- * You obviously have to change this value before Prism executes. To do this, you can add an
350
- * empty Prism object into the global scope before loading the Prism script like this:
351
- *
352
- * ```js
353
- * window.Prism = window.Prism || {};
354
- * Prism.disableWorkerMessageHandler = true;
355
- * // Load Prism's script
356
- * ```
357
- *
358
- * @default false
359
- * @type {boolean}
360
- * @memberof Prism
361
- * @public
362
- */
363
- disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
364
-
365
- /**
366
- * A namespace for utility methods.
367
- *
368
- * All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
369
- * change or disappear at any time.
370
- *
371
- * @namespace
372
- * @memberof Prism
373
- */
374
- util: {
375
- encode: function encode(tokens) {
376
- if (tokens instanceof Token) {
377
- return new Token(tokens.type, encode(tokens.content), tokens.alias);
378
- } else if (Array.isArray(tokens)) {
379
- return tokens.map(encode);
380
- } else {
381
- return tokens.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/\u00a0/g, ' ');
382
- }
383
- },
384
-
385
- /**
386
- * Returns the name of the type of the given value.
387
- *
388
- * @param {any} o
389
- * @returns {string}
390
- * @example
391
- * type(null) === 'Null'
392
- * type(undefined) === 'Undefined'
393
- * type(123) === 'Number'
394
- * type('foo') === 'String'
395
- * type(true) === 'Boolean'
396
- * type([1, 2]) === 'Array'
397
- * type({}) === 'Object'
398
- * type(String) === 'Function'
399
- * type(/abc+/) === 'RegExp'
400
- */
401
- type: function (o) {
402
- return Object.prototype.toString.call(o).slice(8, -1);
403
- },
404
-
405
- /**
406
- * Returns a unique number for the given object. Later calls will still return the same number.
407
- *
408
- * @param {Object} obj
409
- * @returns {number}
410
- */
411
- objId: function (obj) {
412
- if (!obj['__id']) {
413
- Object.defineProperty(obj, '__id', { value: ++uniqueId });
414
- }
415
- return obj['__id'];
416
- },
417
-
418
- /**
419
- * Creates a deep clone of the given object.
420
- *
421
- * The main intended use of this function is to clone language definitions.
422
- *
423
- * @param {T} o
424
- * @param {Record<number, any>} [visited]
425
- * @returns {T}
426
- * @template T
427
- */
428
- clone: function deepClone(o, visited) {
429
- visited = visited || {};
430
-
431
- var clone; var id;
432
- switch (_.util.type(o)) {
433
- case 'Object':
434
- id = _.util.objId(o);
435
- if (visited[id]) {
436
- return visited[id];
437
- }
438
- clone = /** @type {Record<string, any>} */ ({});
439
- visited[id] = clone;
440
-
441
- for (var key in o) {
442
- if (o.hasOwnProperty(key)) {
443
- clone[key] = deepClone(o[key], visited);
444
- }
445
- }
446
-
447
- return /** @type {any} */ (clone);
448
-
449
- case 'Array':
450
- id = _.util.objId(o);
451
- if (visited[id]) {
452
- return visited[id];
453
- }
454
- clone = [];
455
- visited[id] = clone;
456
-
457
- (/** @type {Array} */(/** @type {any} */(o))).forEach(function (v, i) {
458
- clone[i] = deepClone(v, visited);
459
- });
460
-
461
- return /** @type {any} */ (clone);
462
-
463
- default:
464
- return o;
465
- }
466
- },
467
-
468
- /**
469
- * Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class.
470
- *
471
- * If no language is set for the element or the element is `null` or `undefined`, `none` will be returned.
472
- *
473
- * @param {Element} element
474
- * @returns {string}
475
- */
476
- getLanguage: function (element) {
477
- while (element) {
478
- var m = lang.exec(element.className);
479
- if (m) {
480
- return m[1].toLowerCase();
481
- }
482
- element = element.parentElement;
483
- }
484
- return 'none';
485
- },
486
-
487
- /**
488
- * Sets the Prism `language-xxxx` class of the given element.
489
- *
490
- * @param {Element} element
491
- * @param {string} language
492
- * @returns {void}
493
- */
494
- setLanguage: function (element, language) {
495
- // remove all `language-xxxx` classes
496
- // (this might leave behind a leading space)
497
- element.className = element.className.replace(RegExp(lang, 'gi'), '');
498
-
499
- // add the new `language-xxxx` class
500
- // (using `classList` will automatically clean up spaces for us)
501
- element.classList.add('language-' + language);
502
- },
503
-
504
- /**
505
- * Returns the script element that is currently executing.
506
- *
507
- * This does __not__ work for line script element.
508
- *
509
- * @returns {HTMLScriptElement | null}
510
- */
511
- currentScript: function () {
512
- if (typeof document === 'undefined') {
513
- return null;
514
- }
515
- if ('currentScript' in document && 1 < 2 /* hack to trip TS' flow analysis */) {
516
- return /** @type {any} */ (document.currentScript);
517
- }
518
-
519
- // IE11 workaround
520
- // we'll get the src of the current script by parsing IE11's error stack trace
521
- // this will not work for inline scripts
522
-
523
- try {
524
- throw new Error();
525
- } catch (err) {
526
- // Get file src url from stack. Specifically works with the format of stack traces in IE.
527
- // A stack will look like this:
528
- //
529
- // Error
530
- // at _.util.currentScript (http://localhost/components/prism-core.js:119:5)
531
- // at Global code (http://localhost/components/prism-core.js:606:1)
532
-
533
- var src = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(err.stack) || [])[1];
534
- if (src) {
535
- var scripts = document.getElementsByTagName('script');
536
- for (var i in scripts) {
537
- if (scripts[i].src == src) {
538
- return scripts[i];
539
- }
540
- }
541
- }
542
- return null;
543
- }
544
- },
545
-
546
- /**
547
- * Returns whether a given class is active for `element`.
548
- *
549
- * The class can be activated if `element` or one of its ancestors has the given class and it can be deactivated
550
- * if `element` or one of its ancestors has the negated version of the given class. The _negated version_ of the
551
- * given class is just the given class with a `no-` prefix.
552
- *
553
- * Whether the class is active is determined by the closest ancestor of `element` (where `element` itself is
554
- * closest ancestor) that has the given class or the negated version of it. If neither `element` nor any of its
555
- * ancestors have the given class or the negated version of it, then the default activation will be returned.
556
- *
557
- * In the paradoxical situation where the closest ancestor contains __both__ the given class and the negated
558
- * version of it, the class is considered active.
559
- *
560
- * @param {Element} element
561
- * @param {string} className
562
- * @param {boolean} [defaultActivation=false]
563
- * @returns {boolean}
564
- */
565
- isActive: function (element, className, defaultActivation) {
566
- var no = 'no-' + className;
567
-
568
- while (element) {
569
- var classList = element.classList;
570
- if (classList.contains(className)) {
571
- return true;
572
- }
573
- if (classList.contains(no)) {
574
- return false;
575
- }
576
- element = element.parentElement;
577
- }
578
- return !!defaultActivation;
579
- }
580
- },
581
-
582
- /**
583
- * This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
584
- *
585
- * @namespace
586
- * @memberof Prism
587
- * @public
588
- */
589
- languages: {
590
- /**
591
- * The grammar for plain, unformatted text.
592
- */
593
- plain: plainTextGrammar,
594
- plaintext: plainTextGrammar,
595
- text: plainTextGrammar,
596
- txt: plainTextGrammar,
597
-
598
- /**
599
- * Creates a deep copy of the language with the given id and appends the given tokens.
600
- *
601
- * If a token in `redef` also appears in the copied language, then the existing token in the copied language
602
- * will be overwritten at its original position.
603
- *
604
- * ## Best practices
605
- *
606
- * Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)
607
- * doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to
608
- * understand the language definition because, normally, the order of tokens matters in Prism grammars.
609
- *
610
- * Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.
611
- * Furthermore, all non-overwriting tokens should be placed after the overwriting ones.
612
- *
613
- * @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.
614
- * @param {Grammar} redef The new tokens to append.
615
- * @returns {Grammar} The new language created.
616
- * @public
617
- * @example
618
- * Prism.languages['css-with-colors'] = Prism.languages.extend('css', {
619
- * // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
620
- * // at its original position
621
- * 'comment': { ... },
622
- * // CSS doesn't have a 'color' token, so this token will be appended
623
- * 'color': /\b(?:red|green|blue)\b/
624
- * });
625
- */
626
- extend: function (id, redef) {
627
- var lang = _.util.clone(_.languages[id]);
628
-
629
- for (var key in redef) {
630
- lang[key] = redef[key];
631
- }
632
-
633
- return lang;
634
- },
635
-
636
- /**
637
- * Inserts tokens _before_ another token in a language definition or any other grammar.
638
- *
639
- * ## Usage
640
- *
641
- * This helper method makes it easy to modify existing languages. For example, the CSS language definition
642
- * not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded
643
- * in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the
644
- * appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do
645
- * this:
646
- *
647
- * ```js
648
- * Prism.languages.markup.style = {
649
- * // token
650
- * };
651
- * ```
652
- *
653
- * then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens
654
- * before existing tokens. For the CSS example above, you would use it like this:
655
- *
656
- * ```js
657
- * Prism.languages.insertBefore('markup', 'cdata', {
658
- * 'style': {
659
- * // token
660
- * }
661
- * });
662
- * ```
663
- *
664
- * ## Special cases
665
- *
666
- * If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar
667
- * will be ignored.
668
- *
669
- * This behavior can be used to insert tokens after `before`:
670
- *
671
- * ```js
672
- * Prism.languages.insertBefore('markup', 'comment', {
673
- * 'comment': Prism.languages.markup.comment,
674
- * // tokens after 'comment'
675
- * });
676
- * ```
677
- *
678
- * ## Limitations
679
- *
680
- * The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object
681
- * properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave
682
- * differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily
683
- * deleting properties which is necessary to insert at arbitrary positions.
684
- *
685
- * To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object.
686
- * Instead, it will create a new object and replace all references to the target object with the new one. This
687
- * can be done without temporarily deleting properties, so the iteration order is well-defined.
688
- *
689
- * However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if
690
- * you hold the target object in a variable, then the value of the variable will not change.
691
- *
692
- * ```js
693
- * var oldMarkup = Prism.languages.markup;
694
- * var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... });
695
- *
696
- * assert(oldMarkup !== Prism.languages.markup);
697
- * assert(newMarkup === Prism.languages.markup);
698
- * ```
699
- *
700
- * @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the
701
- * object to be modified.
702
- * @param {string} before The key to insert before.
703
- * @param {Grammar} insert An object containing the key-value pairs to be inserted.
704
- * @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the
705
- * object to be modified.
706
- *
707
- * Defaults to `Prism.languages`.
708
- * @returns {Grammar} The new grammar object.
709
- * @public
710
- */
711
- insertBefore: function (inside, before, insert, root) {
712
- root = root || /** @type {any} */ (_.languages);
713
- var grammar = root[inside];
714
- /** @type {Grammar} */
715
- var ret = {};
716
-
717
- for (var token in grammar) {
718
- if (grammar.hasOwnProperty(token)) {
719
-
720
- if (token == before) {
721
- for (var newToken in insert) {
722
- if (insert.hasOwnProperty(newToken)) {
723
- ret[newToken] = insert[newToken];
724
- }
725
- }
726
- }
727
-
728
- // Do not insert token which also occur in insert. See #1525
729
- if (!insert.hasOwnProperty(token)) {
730
- ret[token] = grammar[token];
731
- }
732
- }
733
- }
734
-
735
- var old = root[inside];
736
- root[inside] = ret;
737
-
738
- // Update references in other language definitions
739
- _.languages.DFS(_.languages, function (key, value) {
740
- if (value === old && key != inside) {
741
- this[key] = ret;
742
- }
743
- });
744
-
745
- return ret;
746
- },
747
-
748
- // Traverse a language definition with Depth First Search
749
- DFS: function DFS(o, callback, type, visited) {
750
- visited = visited || {};
751
-
752
- var objId = _.util.objId;
753
-
754
- for (var i in o) {
755
- if (o.hasOwnProperty(i)) {
756
- callback.call(o, i, o[i], type || i);
757
-
758
- var property = o[i];
759
- var propertyType = _.util.type(property);
760
-
761
- if (propertyType === 'Object' && !visited[objId(property)]) {
762
- visited[objId(property)] = true;
763
- DFS(property, callback, null, visited);
764
- } else if (propertyType === 'Array' && !visited[objId(property)]) {
765
- visited[objId(property)] = true;
766
- DFS(property, callback, i, visited);
767
- }
768
- }
769
- }
770
- }
771
- },
772
-
773
- plugins: {},
774
-
775
- /**
776
- * This is the most high-level function in Prism’s API.
777
- * It fetches all the elements that have a `.language-xxxx` class and then calls {@link Prism.highlightElement} on
778
- * each one of them.
779
- *
780
- * This is equivalent to `Prism.highlightAllUnder(document, async, callback)`.
781
- *
782
- * @param {boolean} [async=false] Same as in {@link Prism.highlightAllUnder}.
783
- * @param {HighlightCallback} [callback] Same as in {@link Prism.highlightAllUnder}.
784
- * @memberof Prism
785
- * @public
786
- */
787
- highlightAll: function (async, callback) {
788
- _.highlightAllUnder(document, async, callback);
789
- },
790
-
791
- /**
792
- * Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
793
- * {@link Prism.highlightElement} on each one of them.
794
- *
795
- * The following hooks will be run:
796
- * 1. `before-highlightall`
797
- * 2. `before-all-elements-highlight`
798
- * 3. All hooks of {@link Prism.highlightElement} for each element.
799
- *
800
- * @param {ParentNode} container The root element, whose descendants that have a `.language-xxxx` class will be highlighted.
801
- * @param {boolean} [async=false] Whether each element is to be highlighted asynchronously using Web Workers.
802
- * @param {HighlightCallback} [callback] An optional callback to be invoked on each element after its highlighting is done.
803
- * @memberof Prism
804
- * @public
805
- */
806
- highlightAllUnder: function (container, async, callback) {
807
- var env = {
808
- callback: callback,
809
- container: container,
810
- selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
811
- };
812
-
813
- _.hooks.run('before-highlightall', env);
814
-
815
- env.elements = Array.prototype.slice.apply(env.container.querySelectorAll(env.selector));
816
-
817
- _.hooks.run('before-all-elements-highlight', env);
818
-
819
- for (var i = 0, element; (element = env.elements[i++]);) {
820
- _.highlightElement(element, async === true, env.callback);
821
- }
822
- },
823
-
824
- /**
825
- * Highlights the code inside a single element.
826
- *
827
- * The following hooks will be run:
828
- * 1. `before-sanity-check`
829
- * 2. `before-highlight`
830
- * 3. All hooks of {@link Prism.highlight}. These hooks will be run by an asynchronous worker if `async` is `true`.
831
- * 4. `before-insert`
832
- * 5. `after-highlight`
833
- * 6. `complete`
834
- *
835
- * Some the above hooks will be skipped if the element doesn't contain any text or there is no grammar loaded for
836
- * the element's language.
837
- *
838
- * @param {Element} element The element containing the code.
839
- * It must have a class of `language-xxxx` to be processed, where `xxxx` is a valid language identifier.
840
- * @param {boolean} [async=false] Whether the element is to be highlighted asynchronously using Web Workers
841
- * to improve performance and avoid blocking the UI when highlighting very large chunks of code. This option is
842
- * [disabled by default](https://prismjs.com/faq.html#why-is-asynchronous-highlighting-disabled-by-default).
843
- *
844
- * Note: All language definitions required to highlight the code must be included in the main `prism.js` file for
845
- * asynchronous highlighting to work. You can build your own bundle on the
846
- * [Download page](https://prismjs.com/download.html).
847
- * @param {HighlightCallback} [callback] An optional callback to be invoked after the highlighting is done.
848
- * Mostly useful when `async` is `true`, since in that case, the highlighting is done asynchronously.
849
- * @memberof Prism
850
- * @public
851
- */
852
- highlightElement: function (element, async, callback) {
853
- // Find language
854
- var language = _.util.getLanguage(element);
855
- var grammar = _.languages[language];
856
-
857
- // Set language on the element, if not present
858
- _.util.setLanguage(element, language);
859
-
860
- // Set language on the parent, for styling
861
- var parent = element.parentElement;
862
- if (parent && parent.nodeName.toLowerCase() === 'pre') {
863
- _.util.setLanguage(parent, language);
864
- }
865
-
866
- var code = element.textContent;
867
-
868
- var env = {
869
- element: element,
870
- language: language,
871
- grammar: grammar,
872
- code: code
873
- };
874
-
875
- function insertHighlightedCode(highlightedCode) {
876
- env.highlightedCode = highlightedCode;
877
-
878
- _.hooks.run('before-insert', env);
879
-
880
- env.element.innerHTML = env.highlightedCode;
881
-
882
- _.hooks.run('after-highlight', env);
883
- _.hooks.run('complete', env);
884
- callback && callback.call(env.element);
885
- }
886
-
887
- _.hooks.run('before-sanity-check', env);
888
-
889
- // plugins may change/add the parent/element
890
- parent = env.element.parentElement;
891
- if (parent && parent.nodeName.toLowerCase() === 'pre' && !parent.hasAttribute('tabindex')) {
892
- parent.setAttribute('tabindex', '0');
893
- }
894
-
895
- if (!env.code) {
896
- _.hooks.run('complete', env);
897
- callback && callback.call(env.element);
898
- return;
899
- }
900
-
901
- _.hooks.run('before-highlight', env);
902
-
903
- if (!env.grammar) {
904
- insertHighlightedCode(_.util.encode(env.code));
905
- return;
906
- }
907
-
908
- if (async && _self.Worker) {
909
- var worker = new Worker(_.filename);
910
-
911
- worker.onmessage = function (evt) {
912
- insertHighlightedCode(evt.data);
913
- };
914
-
915
- worker.postMessage(JSON.stringify({
916
- language: env.language,
917
- code: env.code,
918
- immediateClose: true
919
- }));
920
- } else {
921
- insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
922
- }
923
- },
924
-
925
- /**
926
- * Low-level function, only use if you know what you’re doing. It accepts a string of text as input
927
- * and the language definitions to use, and returns a string with the HTML produced.
928
- *
929
- * The following hooks will be run:
930
- * 1. `before-tokenize`
931
- * 2. `after-tokenize`
932
- * 3. `wrap`: On each {@link Token}.
933
- *
934
- * @param {string} text A string with the code to be highlighted.
935
- * @param {Grammar} grammar An object containing the tokens to use.
936
- *
937
- * Usually a language definition like `Prism.languages.markup`.
938
- * @param {string} language The name of the language definition passed to `grammar`.
939
- * @returns {string} The highlighted HTML.
940
- * @memberof Prism
941
- * @public
942
- * @example
943
- * Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
944
- */
945
- highlight: function (text, grammar, language) {
946
- var env = {
947
- code: text,
948
- grammar: grammar,
949
- language: language
950
- };
951
- _.hooks.run('before-tokenize', env);
952
- if (!env.grammar) {
953
- throw new Error('The language "' + env.language + '" has no grammar.');
954
- }
955
- env.tokens = _.tokenize(env.code, env.grammar);
956
- _.hooks.run('after-tokenize', env);
957
- return Token.stringify(_.util.encode(env.tokens), env.language);
958
- },
959
-
960
- /**
961
- * This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
962
- * and the language definitions to use, and returns an array with the tokenized code.
963
- *
964
- * When the language definition includes nested tokens, the function is called recursively on each of these tokens.
965
- *
966
- * This method could be useful in other contexts as well, as a very crude parser.
967
- *
968
- * @param {string} text A string with the code to be highlighted.
969
- * @param {Grammar} grammar An object containing the tokens to use.
970
- *
971
- * Usually a language definition like `Prism.languages.markup`.
972
- * @returns {TokenStream} An array of strings and tokens, a token stream.
973
- * @memberof Prism
974
- * @public
975
- * @example
976
- * let code = `var foo = 0;`;
977
- * let tokens = Prism.tokenize(code, Prism.languages.javascript);
978
- * tokens.forEach(token => {
979
- * if (token instanceof Prism.Token && token.type === 'number') {
980
- * console.log(`Found numeric literal: ${token.content}`);
981
- * }
982
- * });
983
- */
984
- tokenize: function (text, grammar) {
985
- var rest = grammar.rest;
986
- if (rest) {
987
- for (var token in rest) {
988
- grammar[token] = rest[token];
989
- }
990
-
991
- delete grammar.rest;
992
- }
993
-
994
- var tokenList = new LinkedList();
995
- addAfter(tokenList, tokenList.head, text);
996
-
997
- matchGrammar(text, tokenList, grammar, tokenList.head, 0);
998
-
999
- return toArray(tokenList);
1000
- },
1001
-
1002
- /**
1003
- * @namespace
1004
- * @memberof Prism
1005
- * @public
1006
- */
1007
- hooks: {
1008
- all: {},
1009
-
1010
- /**
1011
- * Adds the given callback to the list of callbacks for the given hook.
1012
- *
1013
- * The callback will be invoked when the hook it is registered for is run.
1014
- * Hooks are usually directly run by a highlight function but you can also run hooks yourself.
1015
- *
1016
- * One callback function can be registered to multiple hooks and the same hook multiple times.
1017
- *
1018
- * @param {string} name The name of the hook.
1019
- * @param {HookCallback} callback The callback function which is given environment variables.
1020
- * @public
1021
- */
1022
- add: function (name, callback) {
1023
- var hooks = _.hooks.all;
1024
-
1025
- hooks[name] = hooks[name] || [];
1026
-
1027
- hooks[name].push(callback);
1028
- },
1029
-
1030
- /**
1031
- * Runs a hook invoking all registered callbacks with the given environment variables.
1032
- *
1033
- * Callbacks will be invoked synchronously and in the order in which they were registered.
1034
- *
1035
- * @param {string} name The name of the hook.
1036
- * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
1037
- * @public
1038
- */
1039
- run: function (name, env) {
1040
- var callbacks = _.hooks.all[name];
1041
-
1042
- if (!callbacks || !callbacks.length) {
1043
- return;
1044
- }
1045
-
1046
- for (var i = 0, callback; (callback = callbacks[i++]);) {
1047
- callback(env);
1048
- }
1049
- }
1050
- },
1051
-
1052
- Token: Token
1053
- };
1054
- _self.Prism = _;
1055
-
1056
-
1057
- // Typescript note:
1058
- // The following can be used to import the Token type in JSDoc:
1059
- //
1060
- // @typedef {InstanceType<import("./prism-core")["Token"]>} Token
1061
-
1062
- /**
1063
- * Creates a new token.
1064
- *
1065
- * @param {string} type See {@link Token#type type}
1066
- * @param {string | TokenStream} content See {@link Token#content content}
1067
- * @param {string|string[]} [alias] The alias(es) of the token.
1068
- * @param {string} [matchedStr=""] A copy of the full string this token was created from.
1069
- * @class
1070
- * @global
1071
- * @public
1072
- */
1073
- function Token(type, content, alias, matchedStr) {
1074
- /**
1075
- * The type of the token.
1076
- *
1077
- * This is usually the key of a pattern in a {@link Grammar}.
1078
- *
1079
- * @type {string}
1080
- * @see GrammarToken
1081
- * @public
1082
- */
1083
- this.type = type;
1084
- /**
1085
- * The strings or tokens contained by this token.
1086
- *
1087
- * This will be a token stream if the pattern matched also defined an `inside` grammar.
1088
- *
1089
- * @type {string | TokenStream}
1090
- * @public
1091
- */
1092
- this.content = content;
1093
- /**
1094
- * The alias(es) of the token.
1095
- *
1096
- * @type {string|string[]}
1097
- * @see GrammarToken
1098
- * @public
1099
- */
1100
- this.alias = alias;
1101
- // Copy of the full string this token was created from
1102
- this.length = (matchedStr || '').length | 0;
1103
- }
1104
-
1105
- /**
1106
- * A token stream is an array of strings and {@link Token Token} objects.
1107
- *
1108
- * Token streams have to fulfill a few properties that are assumed by most functions (mostly internal ones) that process
1109
- * them.
1110
- *
1111
- * 1. No adjacent strings.
1112
- * 2. No empty strings.
1113
- *
1114
- * The only exception here is the token stream that only contains the empty string and nothing else.
1115
- *
1116
- * @typedef {Array<string | Token>} TokenStream
1117
- * @global
1118
- * @public
1119
- */
1120
-
1121
- /**
1122
- * Converts the given token or token stream to an HTML representation.
1123
- *
1124
- * The following hooks will be run:
1125
- * 1. `wrap`: On each {@link Token}.
1126
- *
1127
- * @param {string | Token | TokenStream} o The token or token stream to be converted.
1128
- * @param {string} language The name of current language.
1129
- * @returns {string} The HTML representation of the token or token stream.
1130
- * @memberof Token
1131
- * @static
1132
- */
1133
- Token.stringify = function stringify(o, language) {
1134
- if (typeof o == 'string') {
1135
- return o;
1136
- }
1137
- if (Array.isArray(o)) {
1138
- var s = '';
1139
- o.forEach(function (e) {
1140
- s += stringify(e, language);
1141
- });
1142
- return s;
1143
- }
1144
-
1145
- var env = {
1146
- type: o.type,
1147
- content: stringify(o.content, language),
1148
- tag: 'span',
1149
- classes: ['token', o.type],
1150
- attributes: {},
1151
- language: language
1152
- };
1153
-
1154
- var aliases = o.alias;
1155
- if (aliases) {
1156
- if (Array.isArray(aliases)) {
1157
- Array.prototype.push.apply(env.classes, aliases);
1158
- } else {
1159
- env.classes.push(aliases);
1160
- }
1161
- }
1162
-
1163
- _.hooks.run('wrap', env);
1164
-
1165
- var attributes = '';
1166
- for (var name in env.attributes) {
1167
- attributes += ' ' + name + '="' + (env.attributes[name] || '').replace(/"/g, '&quot;') + '"';
1168
- }
1169
-
1170
- return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + attributes + '>' + env.content + '</' + env.tag + '>';
1171
- };
1172
-
1173
- /**
1174
- * @param {RegExp} pattern
1175
- * @param {number} pos
1176
- * @param {string} text
1177
- * @param {boolean} lookbehind
1178
- * @returns {RegExpExecArray | null}
1179
- */
1180
- function matchPattern(pattern, pos, text, lookbehind) {
1181
- pattern.lastIndex = pos;
1182
- var match = pattern.exec(text);
1183
- if (match && lookbehind && match[1]) {
1184
- // change the match to remove the text matched by the Prism lookbehind group
1185
- var lookbehindLength = match[1].length;
1186
- match.index += lookbehindLength;
1187
- match[0] = match[0].slice(lookbehindLength);
1188
- }
1189
- return match;
1190
- }
1191
-
1192
- /**
1193
- * @param {string} text
1194
- * @param {LinkedList<string | Token>} tokenList
1195
- * @param {any} grammar
1196
- * @param {LinkedListNode<string | Token>} startNode
1197
- * @param {number} startPos
1198
- * @param {RematchOptions} [rematch]
1199
- * @returns {void}
1200
- * @private
1201
- *
1202
- * @typedef RematchOptions
1203
- * @property {string} cause
1204
- * @property {number} reach
1205
- */
1206
- function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) {
1207
- for (var token in grammar) {
1208
- if (!grammar.hasOwnProperty(token) || !grammar[token]) {
1209
- continue;
1210
- }
1211
-
1212
- var patterns = grammar[token];
1213
- patterns = Array.isArray(patterns) ? patterns : [patterns];
1214
-
1215
- for (var j = 0; j < patterns.length; ++j) {
1216
- if (rematch && rematch.cause == token + ',' + j) {
1217
- return;
1218
- }
1219
-
1220
- var patternObj = patterns[j];
1221
- var inside = patternObj.inside;
1222
- var lookbehind = !!patternObj.lookbehind;
1223
- var greedy = !!patternObj.greedy;
1224
- var alias = patternObj.alias;
1225
-
1226
- if (greedy && !patternObj.pattern.global) {
1227
- // Without the global flag, lastIndex won't work
1228
- var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0];
1229
- patternObj.pattern = RegExp(patternObj.pattern.source, flags + 'g');
1230
- }
1231
-
1232
- /** @type {RegExp} */
1233
- var pattern = patternObj.pattern || patternObj;
1234
-
1235
- for ( // iterate the token list and keep track of the current token/string position
1236
- var currentNode = startNode.next, pos = startPos;
1237
- currentNode !== tokenList.tail;
1238
- pos += currentNode.value.length, currentNode = currentNode.next
1239
- ) {
1240
-
1241
- if (rematch && pos >= rematch.reach) {
1242
- break;
1243
- }
1244
-
1245
- var str = currentNode.value;
1246
-
1247
- if (tokenList.length > text.length) {
1248
- // Something went terribly wrong, ABORT, ABORT!
1249
- return;
1250
- }
1251
-
1252
- if (str instanceof Token) {
1253
- continue;
1254
- }
1255
-
1256
- var removeCount = 1; // this is the to parameter of removeBetween
1257
- var match;
1258
-
1259
- if (greedy) {
1260
- match = matchPattern(pattern, pos, text, lookbehind);
1261
- if (!match || match.index >= text.length) {
1262
- break;
1263
- }
1264
-
1265
- var from = match.index;
1266
- var to = match.index + match[0].length;
1267
- var p = pos;
1268
-
1269
- // find the node that contains the match
1270
- p += currentNode.value.length;
1271
- while (from >= p) {
1272
- currentNode = currentNode.next;
1273
- p += currentNode.value.length;
1274
- }
1275
- // adjust pos (and p)
1276
- p -= currentNode.value.length;
1277
- pos = p;
1278
-
1279
- // the current node is a Token, then the match starts inside another Token, which is invalid
1280
- if (currentNode.value instanceof Token) {
1281
- continue;
1282
- }
1283
-
1284
- // find the last node which is affected by this match
1285
- for (
1286
- var k = currentNode;
1287
- k !== tokenList.tail && (p < to || typeof k.value === 'string');
1288
- k = k.next
1289
- ) {
1290
- removeCount++;
1291
- p += k.value.length;
1292
- }
1293
- removeCount--;
1294
-
1295
- // replace with the new match
1296
- str = text.slice(pos, p);
1297
- match.index -= pos;
1298
- } else {
1299
- match = matchPattern(pattern, 0, str, lookbehind);
1300
- if (!match) {
1301
- continue;
1302
- }
1303
- }
1304
-
1305
- // eslint-disable-next-line no-redeclare
1306
- var from = match.index;
1307
- var matchStr = match[0];
1308
- var before = str.slice(0, from);
1309
- var after = str.slice(from + matchStr.length);
1310
-
1311
- var reach = pos + str.length;
1312
- if (rematch && reach > rematch.reach) {
1313
- rematch.reach = reach;
1314
- }
1315
-
1316
- var removeFrom = currentNode.prev;
1317
-
1318
- if (before) {
1319
- removeFrom = addAfter(tokenList, removeFrom, before);
1320
- pos += before.length;
1321
- }
1322
-
1323
- removeRange(tokenList, removeFrom, removeCount);
1324
-
1325
- var wrapped = new Token(token, inside ? _.tokenize(matchStr, inside) : matchStr, alias, matchStr);
1326
- currentNode = addAfter(tokenList, removeFrom, wrapped);
1327
-
1328
- if (after) {
1329
- addAfter(tokenList, currentNode, after);
1330
- }
1331
-
1332
- if (removeCount > 1) {
1333
- // at least one Token object was removed, so we have to do some rematching
1334
- // this can only happen if the current pattern is greedy
1335
-
1336
- /** @type {RematchOptions} */
1337
- var nestedRematch = {
1338
- cause: token + ',' + j,
1339
- reach: reach
1340
- };
1341
- matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch);
1342
-
1343
- // the reach might have been extended because of the rematching
1344
- if (rematch && nestedRematch.reach > rematch.reach) {
1345
- rematch.reach = nestedRematch.reach;
1346
- }
1347
- }
1348
- }
1349
- }
1350
- }
1351
- }
1352
-
1353
- /**
1354
- * @typedef LinkedListNode
1355
- * @property {T} value
1356
- * @property {LinkedListNode<T> | null} prev The previous node.
1357
- * @property {LinkedListNode<T> | null} next The next node.
1358
- * @template T
1359
- * @private
1360
- */
1361
-
1362
- /**
1363
- * @template T
1364
- * @private
1365
- */
1366
- function LinkedList() {
1367
- /** @type {LinkedListNode<T>} */
1368
- var head = { value: null, prev: null, next: null };
1369
- /** @type {LinkedListNode<T>} */
1370
- var tail = { value: null, prev: head, next: null };
1371
- head.next = tail;
1372
-
1373
- /** @type {LinkedListNode<T>} */
1374
- this.head = head;
1375
- /** @type {LinkedListNode<T>} */
1376
- this.tail = tail;
1377
- this.length = 0;
1378
- }
1379
-
1380
- /**
1381
- * Adds a new node with the given value to the list.
1382
- *
1383
- * @param {LinkedList<T>} list
1384
- * @param {LinkedListNode<T>} node
1385
- * @param {T} value
1386
- * @returns {LinkedListNode<T>} The added node.
1387
- * @template T
1388
- */
1389
- function addAfter(list, node, value) {
1390
- // assumes that node != list.tail && values.length >= 0
1391
- var next = node.next;
1392
-
1393
- var newNode = { value: value, prev: node, next: next };
1394
- node.next = newNode;
1395
- next.prev = newNode;
1396
- list.length++;
1397
-
1398
- return newNode;
1399
- }
1400
- /**
1401
- * Removes `count` nodes after the given node. The given node will not be removed.
1402
- *
1403
- * @param {LinkedList<T>} list
1404
- * @param {LinkedListNode<T>} node
1405
- * @param {number} count
1406
- * @template T
1407
- */
1408
- function removeRange(list, node, count) {
1409
- var next = node.next;
1410
- for (var i = 0; i < count && next !== list.tail; i++) {
1411
- next = next.next;
1412
- }
1413
- node.next = next;
1414
- next.prev = node;
1415
- list.length -= i;
1416
- }
1417
- /**
1418
- * @param {LinkedList<T>} list
1419
- * @returns {T[]}
1420
- * @template T
1421
- */
1422
- function toArray(list) {
1423
- var array = [];
1424
- var node = list.head.next;
1425
- while (node !== list.tail) {
1426
- array.push(node.value);
1427
- node = node.next;
1428
- }
1429
- return array;
1430
- }
1431
-
1432
-
1433
- if (!_self.document) {
1434
- if (!_self.addEventListener) {
1435
- // in Node.js
1436
- return _;
1437
- }
1438
-
1439
- if (!_.disableWorkerMessageHandler) {
1440
- // In worker
1441
- _self.addEventListener('message', function (evt) {
1442
- var message = JSON.parse(evt.data);
1443
- var lang = message.language;
1444
- var code = message.code;
1445
- var immediateClose = message.immediateClose;
1446
-
1447
- _self.postMessage(_.highlight(code, _.languages[lang], lang));
1448
- if (immediateClose) {
1449
- _self.close();
1450
- }
1451
- }, false);
1452
- }
1453
-
1454
- return _;
1455
- }
1456
-
1457
- // Get current script and highlight
1458
- var script = _.util.currentScript();
1459
-
1460
- if (script) {
1461
- _.filename = script.src;
1462
-
1463
- if (script.hasAttribute('data-manual')) {
1464
- _.manual = true;
1465
- }
1466
- }
1467
-
1468
- function highlightAutomaticallyCallback() {
1469
- if (!_.manual) {
1470
- _.highlightAll();
1471
- }
1472
- }
1473
-
1474
- if (!_.manual) {
1475
- // If the document state is "loading", then we'll use DOMContentLoaded.
1476
- // If the document state is "interactive" and the prism.js script is deferred, then we'll also use the
1477
- // DOMContentLoaded event because there might be some plugins or languages which have also been deferred and they
1478
- // might take longer one animation frame to execute which can create a race condition where only some plugins have
1479
- // been loaded when Prism.highlightAll() is executed, depending on how fast resources are loaded.
1480
- // See https://github.com/PrismJS/prism/issues/2102
1481
- var readyState = document.readyState;
1482
- if (readyState === 'loading' || readyState === 'interactive' && script && script.defer) {
1483
- document.addEventListener('DOMContentLoaded', highlightAutomaticallyCallback);
1484
- } else {
1485
- if (window.requestAnimationFrame) {
1486
- window.requestAnimationFrame(highlightAutomaticallyCallback);
1487
- } else {
1488
- window.setTimeout(highlightAutomaticallyCallback, 16);
1489
- }
1490
- }
1491
- }
1492
-
1493
- return _;
1494
-
1495
- }(_self));
1496
-
1497
- if (typeof module !== 'undefined' && module.exports) {
1498
- module.exports = Prism;
1499
- }
1500
-
1501
- // hack for components to work correctly in node.js
1502
- if (typeof global !== 'undefined') {
1503
- global.Prism = Prism;
1504
- }
1505
-
1506
- // some additional documentation/types
1507
-
1508
- /**
1509
- * The expansion of a simple `RegExp` literal to support additional properties.
1510
- *
1511
- * @typedef GrammarToken
1512
- * @property {RegExp} pattern The regular expression of the token.
1513
- * @property {boolean} [lookbehind=false] If `true`, then the first capturing group of `pattern` will (effectively)
1514
- * behave as a lookbehind group meaning that the captured text will not be part of the matched text of the new token.
1515
- * @property {boolean} [greedy=false] Whether the token is greedy.
1516
- * @property {string|string[]} [alias] An optional alias or list of aliases.
1517
- * @property {Grammar} [inside] The nested grammar of this token.
1518
- *
1519
- * The `inside` grammar will be used to tokenize the text value of each token of this kind.
1520
- *
1521
- * This can be used to make nested and even recursive language definitions.
1522
- *
1523
- * Note: This can cause infinite recursion. Be careful when you embed different languages or even the same language into
1524
- * each another.
1525
- * @global
1526
- * @public
1527
- */
1528
-
1529
- /**
1530
- * @typedef Grammar
1531
- * @type {Object<string, RegExp | GrammarToken | Array<RegExp | GrammarToken>>}
1532
- * @property {Grammar} [rest] An optional grammar object that will be appended to this grammar.
1533
- * @global
1534
- * @public
1535
- */
1536
-
1537
- /**
1538
- * A function which will invoked after an element was successfully highlighted.
1539
- *
1540
- * @callback HighlightCallback
1541
- * @param {Element} element The element successfully highlighted.
1542
- * @returns {void}
1543
- * @global
1544
- * @public
1545
- */
1546
-
1547
- /**
1548
- * @callback HookCallback
1549
- * @param {Object<string, any>} env The environment variables of the hook.
1550
- * @returns {void}
1551
- * @global
1552
- * @public
1553
- */
1554
-
1555
- Prism.languages.clike = {
1556
- 'comment': [
1557
- {
1558
- pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
1559
- lookbehind: true,
1560
- greedy: true
1561
- },
1562
- {
1563
- pattern: /(^|[^\\:])\/\/.*/,
1564
- lookbehind: true,
1565
- greedy: true
1566
- }
1567
- ],
1568
- 'string': {
1569
- pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
1570
- greedy: true
1571
- },
1572
- 'class-name': {
1573
- pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
1574
- lookbehind: true,
1575
- inside: {
1576
- 'punctuation': /[.\\]/
1577
- }
1578
- },
1579
- 'keyword': /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
1580
- 'boolean': /\b(?:false|true)\b/,
1581
- 'function': /\b\w+(?=\()/,
1582
- 'number': /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
1583
- 'operator': /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
1584
- 'punctuation': /[{}[\];(),.:]/
1585
- };
1586
-
1587
- (function (Prism) {
1588
-
1589
- /**
1590
- * Returns the placeholder for the given language id and index.
1591
- *
1592
- * @param {string} language
1593
- * @param {string|number} index
1594
- * @returns {string}
1595
- */
1596
- function getPlaceholder(language, index) {
1597
- return '___' + language.toUpperCase() + index + '___';
1598
- }
1599
-
1600
- Object.defineProperties(Prism.languages['markup-templating'] = {}, {
1601
- buildPlaceholders: {
1602
- /**
1603
- * Tokenize all inline templating expressions matching `placeholderPattern`.
1604
- *
1605
- * If `replaceFilter` is provided, only matches of `placeholderPattern` for which `replaceFilter` returns
1606
- * `true` will be replaced.
1607
- *
1608
- * @param {object} env The environment of the `before-tokenize` hook.
1609
- * @param {string} language The language id.
1610
- * @param {RegExp} placeholderPattern The matches of this pattern will be replaced by placeholders.
1611
- * @param {(match: string) => boolean} [replaceFilter]
1612
- */
1613
- value: function (env, language, placeholderPattern, replaceFilter) {
1614
- if (env.language !== language) {
1615
- return;
1616
- }
1617
-
1618
- var tokenStack = env.tokenStack = [];
1619
-
1620
- env.code = env.code.replace(placeholderPattern, function (match) {
1621
- if (typeof replaceFilter === 'function' && !replaceFilter(match)) {
1622
- return match;
1623
- }
1624
- var i = tokenStack.length;
1625
- var placeholder;
1626
-
1627
- // Check for existing strings
1628
- while (env.code.indexOf(placeholder = getPlaceholder(language, i)) !== -1) {
1629
- ++i;
1630
- }
1631
-
1632
- // Create a sparse array
1633
- tokenStack[i] = match;
1634
-
1635
- return placeholder;
1636
- });
1637
-
1638
- // Switch the grammar to markup
1639
- env.grammar = Prism.languages.markup;
1640
- }
1641
- },
1642
- tokenizePlaceholders: {
1643
- /**
1644
- * Replace placeholders with proper tokens after tokenizing.
1645
- *
1646
- * @param {object} env The environment of the `after-tokenize` hook.
1647
- * @param {string} language The language id.
1648
- */
1649
- value: function (env, language) {
1650
- if (env.language !== language || !env.tokenStack) {
1651
- return;
1652
- }
1653
-
1654
- // Switch the grammar back
1655
- env.grammar = Prism.languages[language];
1656
-
1657
- var j = 0;
1658
- var keys = Object.keys(env.tokenStack);
1659
-
1660
- function walkTokens(tokens) {
1661
- for (var i = 0; i < tokens.length; i++) {
1662
- // all placeholders are replaced already
1663
- if (j >= keys.length) {
1664
- break;
1665
- }
1666
-
1667
- var token = tokens[i];
1668
- if (typeof token === 'string' || (token.content && typeof token.content === 'string')) {
1669
- var k = keys[j];
1670
- var t = env.tokenStack[k];
1671
- var s = typeof token === 'string' ? token : token.content;
1672
- var placeholder = getPlaceholder(language, k);
1673
-
1674
- var index = s.indexOf(placeholder);
1675
- if (index > -1) {
1676
- ++j;
1677
-
1678
- var before = s.substring(0, index);
1679
- var middle = new Prism.Token(language, Prism.tokenize(t, env.grammar), 'language-' + language, t);
1680
- var after = s.substring(index + placeholder.length);
1681
-
1682
- var replacement = [];
1683
- if (before) {
1684
- replacement.push.apply(replacement, walkTokens([before]));
1685
- }
1686
- replacement.push(middle);
1687
- if (after) {
1688
- replacement.push.apply(replacement, walkTokens([after]));
1689
- }
1690
-
1691
- if (typeof token === 'string') {
1692
- tokens.splice.apply(tokens, [i, 1].concat(replacement));
1693
- } else {
1694
- token.content = replacement;
1695
- }
1696
- }
1697
- } else if (token.content /* && typeof token.content !== 'string' */) {
1698
- walkTokens(token.content);
1699
- }
1700
- }
1701
-
1702
- return tokens;
1703
- }
1704
-
1705
- walkTokens(env.tokens);
1706
- }
1707
- }
1708
- });
1709
-
1710
- }(Prism));
1711
-
1712
- Prism.languages.c = Prism.languages.extend('clike', {
1713
- 'comment': {
1714
- pattern: /\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,
1715
- greedy: true
1716
- },
1717
- 'string': {
1718
- // https://en.cppreference.com/w/c/language/string_literal
1719
- pattern: /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,
1720
- greedy: true
1721
- },
1722
- 'class-name': {
1723
- pattern: /(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,
1724
- lookbehind: true
1725
- },
1726
- 'keyword': /\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/,
1727
- 'function': /\b[a-z_]\w*(?=\s*\()/i,
1728
- 'number': /(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,
1729
- 'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/
1730
- });
1731
-
1732
- Prism.languages.insertBefore('c', 'string', {
1733
- 'char': {
1734
- // https://en.cppreference.com/w/c/language/character_constant
1735
- pattern: /'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,
1736
- greedy: true
1737
- }
1738
- });
1739
-
1740
- Prism.languages.insertBefore('c', 'string', {
1741
- 'macro': {
1742
- // allow for multiline macro definitions
1743
- // spaces after the # character compile fine with gcc
1744
- pattern: /(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,
1745
- lookbehind: true,
1746
- greedy: true,
1747
- alias: 'property',
1748
- inside: {
1749
- 'string': [
1750
- {
1751
- // highlight the path of the include statement as a string
1752
- pattern: /^(#\s*include\s*)<[^>]+>/,
1753
- lookbehind: true
1754
- },
1755
- Prism.languages.c['string']
1756
- ],
1757
- 'char': Prism.languages.c['char'],
1758
- 'comment': Prism.languages.c['comment'],
1759
- 'macro-name': [
1760
- {
1761
- pattern: /(^#\s*define\s+)\w+\b(?!\()/i,
1762
- lookbehind: true
1763
- },
1764
- {
1765
- pattern: /(^#\s*define\s+)\w+\b(?=\()/i,
1766
- lookbehind: true,
1767
- alias: 'function'
1768
- }
1769
- ],
1770
- // highlight macro directives as keywords
1771
- 'directive': {
1772
- pattern: /^(#\s*)[a-z]+/,
1773
- lookbehind: true,
1774
- alias: 'keyword'
1775
- },
1776
- 'directive-hash': /^#/,
1777
- 'punctuation': /##|\\(?=[\r\n])/,
1778
- 'expression': {
1779
- pattern: /\S[\s\S]*/,
1780
- inside: Prism.languages.c
1781
- }
1782
- }
1783
- }
1784
- });
1785
-
1786
- Prism.languages.insertBefore('c', 'function', {
1787
- // highlight predefined macros as constants
1788
- 'constant': /\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/
1789
- });
1790
-
1791
- delete Prism.languages.c['boolean'];
1792
-
1793
- (function (Prism) {
1794
-
1795
- var keyword = /\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|char8_t|class|co_await|co_return|co_yield|compl|concept|const|const_cast|consteval|constexpr|constinit|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|final|float|for|friend|goto|if|import|inline|int|int16_t|int32_t|int64_t|int8_t|long|module|mutable|namespace|new|noexcept|nullptr|operator|override|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|uint16_t|uint32_t|uint64_t|uint8_t|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/;
1796
- var modName = /\b(?!<keyword>)\w+(?:\s*\.\s*\w+)*\b/.source.replace(/<keyword>/g, function () { return keyword.source; });
1797
-
1798
- Prism.languages.cpp = Prism.languages.extend('c', {
1799
- 'class-name': [
1800
- {
1801
- pattern: RegExp(/(\b(?:class|concept|enum|struct|typename)\s+)(?!<keyword>)\w+/.source
1802
- .replace(/<keyword>/g, function () { return keyword.source; })),
1803
- lookbehind: true
1804
- },
1805
- // This is intended to capture the class name of method implementations like:
1806
- // void foo::bar() const {}
1807
- // However! The `foo` in the above example could also be a namespace, so we only capture the class name if
1808
- // it starts with an uppercase letter. This approximation should give decent results.
1809
- /\b[A-Z]\w*(?=\s*::\s*\w+\s*\()/,
1810
- // This will capture the class name before destructors like:
1811
- // Foo::~Foo() {}
1812
- /\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i,
1813
- // This also intends to capture the class name of method implementations but here the class has template
1814
- // parameters, so it can't be a namespace (until C++ adds generic namespaces).
1815
- /\b\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/
1816
- ],
1817
- 'keyword': keyword,
1818
- 'number': {
1819
- pattern: /(?:\b0b[01']+|\b0x(?:[\da-f']+(?:\.[\da-f']*)?|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+(?:\.[\d']*)?|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]{0,4}/i,
1820
- greedy: true
1821
- },
1822
- 'operator': />>=?|<<=?|->|--|\+\+|&&|\|\||[?:~]|<=>|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,
1823
- 'boolean': /\b(?:false|true)\b/
1824
- });
1825
-
1826
- Prism.languages.insertBefore('cpp', 'string', {
1827
- 'module': {
1828
- // https://en.cppreference.com/w/cpp/language/modules
1829
- pattern: RegExp(
1830
- /(\b(?:import|module)\s+)/.source +
1831
- '(?:' +
1832
- // header-name
1833
- /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|<[^<>\r\n]*>/.source +
1834
- '|' +
1835
- // module name or partition or both
1836
- /<mod-name>(?:\s*:\s*<mod-name>)?|:\s*<mod-name>/.source.replace(/<mod-name>/g, function () { return modName; }) +
1837
- ')'
1838
- ),
1839
- lookbehind: true,
1840
- greedy: true,
1841
- inside: {
1842
- 'string': /^[<"][\s\S]+/,
1843
- 'operator': /:/,
1844
- 'punctuation': /\./
1845
- }
1846
- },
1847
- 'raw-string': {
1848
- pattern: /R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,
1849
- alias: 'string',
1850
- greedy: true
1851
- }
1852
- });
1853
-
1854
- Prism.languages.insertBefore('cpp', 'keyword', {
1855
- 'generic-function': {
1856
- pattern: /\b(?!operator\b)[a-z_]\w*\s*<(?:[^<>]|<[^<>]*>)*>(?=\s*\()/i,
1857
- inside: {
1858
- 'function': /^\w+/,
1859
- 'generic': {
1860
- pattern: /<[\s\S]+/,
1861
- alias: 'class-name',
1862
- inside: Prism.languages.cpp
1863
- }
1864
- }
1865
- }
1866
- });
1867
-
1868
- Prism.languages.insertBefore('cpp', 'operator', {
1869
- 'double-colon': {
1870
- pattern: /::/,
1871
- alias: 'punctuation'
1872
- }
1873
- });
1874
-
1875
- Prism.languages.insertBefore('cpp', 'class-name', {
1876
- // the base clause is an optional list of parent classes
1877
- // https://en.cppreference.com/w/cpp/language/class
1878
- 'base-clause': {
1879
- pattern: /(\b(?:class|struct)\s+\w+\s*:\s*)[^;{}"'\s]+(?:\s+[^;{}"'\s]+)*(?=\s*[;{])/,
1880
- lookbehind: true,
1881
- greedy: true,
1882
- inside: Prism.languages.extend('cpp', {})
1883
- }
1884
- });
1885
-
1886
- Prism.languages.insertBefore('inside', 'double-colon', {
1887
- // All untokenized words that are not namespaces should be class names
1888
- 'class-name': /\b[a-z_]\w*\b(?!\s*::)/i
1889
- }, Prism.languages.cpp['base-clause']);
1890
-
1891
- }(Prism));
1892
-
1893
- (function (Prism) {
1894
-
1895
- /**
1896
- * Replaces all placeholders "<<n>>" of given pattern with the n-th replacement (zero based).
1897
- *
1898
- * Note: This is a simple text based replacement. Be careful when using backreferences!
1899
- *
1900
- * @param {string} pattern the given pattern.
1901
- * @param {string[]} replacements a list of replacement which can be inserted into the given pattern.
1902
- * @returns {string} the pattern with all placeholders replaced with their corresponding replacements.
1903
- * @example replace(/a<<0>>a/.source, [/b+/.source]) === /a(?:b+)a/.source
1904
- */
1905
- function replace(pattern, replacements) {
1906
- return pattern.replace(/<<(\d+)>>/g, function (m, index) {
1907
- return '(?:' + replacements[+index] + ')';
1908
- });
1909
- }
1910
- /**
1911
- * @param {string} pattern
1912
- * @param {string[]} replacements
1913
- * @param {string} [flags]
1914
- * @returns {RegExp}
1915
- */
1916
- function re(pattern, replacements, flags) {
1917
- return RegExp(replace(pattern, replacements), flags || '');
1918
- }
1919
-
1920
- /**
1921
- * Creates a nested pattern where all occurrences of the string `<<self>>` are replaced with the pattern itself.
1922
- *
1923
- * @param {string} pattern
1924
- * @param {number} depthLog2
1925
- * @returns {string}
1926
- */
1927
- function nested(pattern, depthLog2) {
1928
- for (var i = 0; i < depthLog2; i++) {
1929
- pattern = pattern.replace(/<<self>>/g, function () { return '(?:' + pattern + ')'; });
1930
- }
1931
- return pattern.replace(/<<self>>/g, '[^\\s\\S]');
1932
- }
1933
-
1934
- // https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/
1935
- var keywordKinds = {
1936
- // keywords which represent a return or variable type
1937
- type: 'bool byte char decimal double dynamic float int long object sbyte short string uint ulong ushort var void',
1938
- // keywords which are used to declare a type
1939
- typeDeclaration: 'class enum interface record struct',
1940
- // contextual keywords
1941
- // ("var" and "dynamic" are missing because they are used like types)
1942
- contextual: 'add alias and ascending async await by descending from(?=\\s*(?:\\w|$)) get global group into init(?=\\s*;) join let nameof not notnull on or orderby partial remove select set unmanaged value when where with(?=\\s*{)',
1943
- // all other keywords
1944
- other: 'abstract as base break case catch checked const continue default delegate do else event explicit extern finally fixed for foreach goto if implicit in internal is lock namespace new null operator out override params private protected public readonly ref return sealed sizeof stackalloc static switch this throw try typeof unchecked unsafe using virtual volatile while yield'
1945
- };
1946
-
1947
- // keywords
1948
- function keywordsToPattern(words) {
1949
- return '\\b(?:' + words.trim().replace(/ /g, '|') + ')\\b';
1950
- }
1951
- var typeDeclarationKeywords = keywordsToPattern(keywordKinds.typeDeclaration);
1952
- var keywords = RegExp(keywordsToPattern(keywordKinds.type + ' ' + keywordKinds.typeDeclaration + ' ' + keywordKinds.contextual + ' ' + keywordKinds.other));
1953
- var nonTypeKeywords = keywordsToPattern(keywordKinds.typeDeclaration + ' ' + keywordKinds.contextual + ' ' + keywordKinds.other);
1954
- var nonContextualKeywords = keywordsToPattern(keywordKinds.type + ' ' + keywordKinds.typeDeclaration + ' ' + keywordKinds.other);
1955
-
1956
- // types
1957
- var generic = nested(/<(?:[^<>;=+\-*/%&|^]|<<self>>)*>/.source, 2); // the idea behind the other forbidden characters is to prevent false positives. Same for tupleElement.
1958
- var nestedRound = nested(/\((?:[^()]|<<self>>)*\)/.source, 2);
1959
- var name = /@?\b[A-Za-z_]\w*\b/.source;
1960
- var genericName = replace(/<<0>>(?:\s*<<1>>)?/.source, [name, generic]);
1961
- var identifier = replace(/(?!<<0>>)<<1>>(?:\s*\.\s*<<1>>)*/.source, [nonTypeKeywords, genericName]);
1962
- var array = /\[\s*(?:,\s*)*\]/.source;
1963
- var typeExpressionWithoutTuple = replace(/<<0>>(?:\s*(?:\?\s*)?<<1>>)*(?:\s*\?)?/.source, [identifier, array]);
1964
- var tupleElement = replace(/[^,()<>[\];=+\-*/%&|^]|<<0>>|<<1>>|<<2>>/.source, [generic, nestedRound, array]);
1965
- var tuple = replace(/\(<<0>>+(?:,<<0>>+)+\)/.source, [tupleElement]);
1966
- var typeExpression = replace(/(?:<<0>>|<<1>>)(?:\s*(?:\?\s*)?<<2>>)*(?:\s*\?)?/.source, [tuple, identifier, array]);
1967
-
1968
- var typeInside = {
1969
- 'keyword': keywords,
1970
- 'punctuation': /[<>()?,.:[\]]/
1971
- };
1972
-
1973
- // strings & characters
1974
- // https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#character-literals
1975
- // https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#string-literals
1976
- var character = /'(?:[^\r\n'\\]|\\.|\\[Uux][\da-fA-F]{1,8})'/.source; // simplified pattern
1977
- var regularString = /"(?:\\.|[^\\"\r\n])*"/.source;
1978
- var verbatimString = /@"(?:""|\\[\s\S]|[^\\"])*"(?!")/.source;
1979
-
1980
-
1981
- Prism.languages.csharp = Prism.languages.extend('clike', {
1982
- 'string': [
1983
- {
1984
- pattern: re(/(^|[^$\\])<<0>>/.source, [verbatimString]),
1985
- lookbehind: true,
1986
- greedy: true
1987
- },
1988
- {
1989
- pattern: re(/(^|[^@$\\])<<0>>/.source, [regularString]),
1990
- lookbehind: true,
1991
- greedy: true
1992
- }
1993
- ],
1994
- 'class-name': [
1995
- {
1996
- // Using static
1997
- // using static System.Math;
1998
- pattern: re(/(\busing\s+static\s+)<<0>>(?=\s*;)/.source, [identifier]),
1999
- lookbehind: true,
2000
- inside: typeInside
2001
- },
2002
- {
2003
- // Using alias (type)
2004
- // using Project = PC.MyCompany.Project;
2005
- pattern: re(/(\busing\s+<<0>>\s*=\s*)<<1>>(?=\s*;)/.source, [name, typeExpression]),
2006
- lookbehind: true,
2007
- inside: typeInside
2008
- },
2009
- {
2010
- // Using alias (alias)
2011
- // using Project = PC.MyCompany.Project;
2012
- pattern: re(/(\busing\s+)<<0>>(?=\s*=)/.source, [name]),
2013
- lookbehind: true
2014
- },
2015
- {
2016
- // Type declarations
2017
- // class Foo<A, B>
2018
- // interface Foo<out A, B>
2019
- pattern: re(/(\b<<0>>\s+)<<1>>/.source, [typeDeclarationKeywords, genericName]),
2020
- lookbehind: true,
2021
- inside: typeInside
2022
- },
2023
- {
2024
- // Single catch exception declaration
2025
- // catch(Foo)
2026
- // (things like catch(Foo e) is covered by variable declaration)
2027
- pattern: re(/(\bcatch\s*\(\s*)<<0>>/.source, [identifier]),
2028
- lookbehind: true,
2029
- inside: typeInside
2030
- },
2031
- {
2032
- // Name of the type parameter of generic constraints
2033
- // where Foo : class
2034
- pattern: re(/(\bwhere\s+)<<0>>/.source, [name]),
2035
- lookbehind: true
2036
- },
2037
- {
2038
- // Casts and checks via as and is.
2039
- // as Foo<A>, is Bar<B>
2040
- // (things like if(a is Foo b) is covered by variable declaration)
2041
- pattern: re(/(\b(?:is(?:\s+not)?|as)\s+)<<0>>/.source, [typeExpressionWithoutTuple]),
2042
- lookbehind: true,
2043
- inside: typeInside
2044
- },
2045
- {
2046
- // Variable, field and parameter declaration
2047
- // (Foo bar, Bar baz, Foo[,,] bay, Foo<Bar, FooBar<Bar>> bax)
2048
- pattern: re(/\b<<0>>(?=\s+(?!<<1>>|with\s*\{)<<2>>(?:\s*[=,;:{)\]]|\s+(?:in|when)\b))/.source, [typeExpression, nonContextualKeywords, name]),
2049
- inside: typeInside
2050
- }
2051
- ],
2052
- 'keyword': keywords,
2053
- // https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#literals
2054
- 'number': /(?:\b0(?:x[\da-f_]*[\da-f]|b[01_]*[01])|(?:\B\.\d+(?:_+\d+)*|\b\d+(?:_+\d+)*(?:\.\d+(?:_+\d+)*)?)(?:e[-+]?\d+(?:_+\d+)*)?)(?:[dflmu]|lu|ul)?\b/i,
2055
- 'operator': />>=?|<<=?|[-=]>|([-+&|])\1|~|\?\?=?|[-+*/%&|^!=<>]=?/,
2056
- 'punctuation': /\?\.?|::|[{}[\];(),.:]/
2057
- });
2058
-
2059
- Prism.languages.insertBefore('csharp', 'number', {
2060
- 'range': {
2061
- pattern: /\.\./,
2062
- alias: 'operator'
2063
- }
2064
- });
2065
-
2066
- Prism.languages.insertBefore('csharp', 'punctuation', {
2067
- 'named-parameter': {
2068
- pattern: re(/([(,]\s*)<<0>>(?=\s*:)/.source, [name]),
2069
- lookbehind: true,
2070
- alias: 'punctuation'
2071
- }
2072
- });
2073
-
2074
- Prism.languages.insertBefore('csharp', 'class-name', {
2075
- 'namespace': {
2076
- // namespace Foo.Bar {}
2077
- // using Foo.Bar;
2078
- pattern: re(/(\b(?:namespace|using)\s+)<<0>>(?:\s*\.\s*<<0>>)*(?=\s*[;{])/.source, [name]),
2079
- lookbehind: true,
2080
- inside: {
2081
- 'punctuation': /\./
2082
- }
2083
- },
2084
- 'type-expression': {
2085
- // default(Foo), typeof(Foo<Bar>), sizeof(int)
2086
- pattern: re(/(\b(?:default|sizeof|typeof)\s*\(\s*(?!\s))(?:[^()\s]|\s(?!\s)|<<0>>)*(?=\s*\))/.source, [nestedRound]),
2087
- lookbehind: true,
2088
- alias: 'class-name',
2089
- inside: typeInside
2090
- },
2091
- 'return-type': {
2092
- // Foo<Bar> ForBar(); Foo IFoo.Bar() => 0
2093
- // int this[int index] => 0; T IReadOnlyList<T>.this[int index] => this[index];
2094
- // int Foo => 0; int Foo { get; set } = 0;
2095
- pattern: re(/<<0>>(?=\s+(?:<<1>>\s*(?:=>|[({]|\.\s*this\s*\[)|this\s*\[))/.source, [typeExpression, identifier]),
2096
- inside: typeInside,
2097
- alias: 'class-name'
2098
- },
2099
- 'constructor-invocation': {
2100
- // new List<Foo<Bar[]>> { }
2101
- pattern: re(/(\bnew\s+)<<0>>(?=\s*[[({])/.source, [typeExpression]),
2102
- lookbehind: true,
2103
- inside: typeInside,
2104
- alias: 'class-name'
2105
- },
2106
- /*'explicit-implementation': {
2107
- // int IFoo<Foo>.Bar => 0; void IFoo<Foo<Foo>>.Foo<T>();
2108
- pattern: replace(/\b<<0>>(?=\.<<1>>)/, className, methodOrPropertyDeclaration),
2109
- inside: classNameInside,
2110
- alias: 'class-name'
2111
- },*/
2112
- 'generic-method': {
2113
- // foo<Bar>()
2114
- pattern: re(/<<0>>\s*<<1>>(?=\s*\()/.source, [name, generic]),
2115
- inside: {
2116
- 'function': re(/^<<0>>/.source, [name]),
2117
- 'generic': {
2118
- pattern: RegExp(generic),
2119
- alias: 'class-name',
2120
- inside: typeInside
2121
- }
2122
- }
2123
- },
2124
- 'type-list': {
2125
- // The list of types inherited or of generic constraints
2126
- // class Foo<F> : Bar, IList<FooBar>
2127
- // where F : Bar, IList<int>
2128
- pattern: re(
2129
- /\b((?:<<0>>\s+<<1>>|record\s+<<1>>\s*<<5>>|where\s+<<2>>)\s*:\s*)(?:<<3>>|<<4>>|<<1>>\s*<<5>>|<<6>>)(?:\s*,\s*(?:<<3>>|<<4>>|<<6>>))*(?=\s*(?:where|[{;]|=>|$))/.source,
2130
- [typeDeclarationKeywords, genericName, name, typeExpression, keywords.source, nestedRound, /\bnew\s*\(\s*\)/.source]
2131
- ),
2132
- lookbehind: true,
2133
- inside: {
2134
- 'record-arguments': {
2135
- pattern: re(/(^(?!new\s*\()<<0>>\s*)<<1>>/.source, [genericName, nestedRound]),
2136
- lookbehind: true,
2137
- greedy: true,
2138
- inside: Prism.languages.csharp
2139
- },
2140
- 'keyword': keywords,
2141
- 'class-name': {
2142
- pattern: RegExp(typeExpression),
2143
- greedy: true,
2144
- inside: typeInside
2145
- },
2146
- 'punctuation': /[,()]/
2147
- }
2148
- },
2149
- 'preprocessor': {
2150
- pattern: /(^[\t ]*)#.*/m,
2151
- lookbehind: true,
2152
- alias: 'property',
2153
- inside: {
2154
- // highlight preprocessor directives as keywords
2155
- 'directive': {
2156
- pattern: /(#)\b(?:define|elif|else|endif|endregion|error|if|line|nullable|pragma|region|undef|warning)\b/,
2157
- lookbehind: true,
2158
- alias: 'keyword'
2159
- }
2160
- }
2161
- }
2162
- });
2163
-
2164
- // attributes
2165
- var regularStringOrCharacter = regularString + '|' + character;
2166
- var regularStringCharacterOrComment = replace(/\/(?![*/])|\/\/[^\r\n]*[\r\n]|\/\*(?:[^*]|\*(?!\/))*\*\/|<<0>>/.source, [regularStringOrCharacter]);
2167
- var roundExpression = nested(replace(/[^"'/()]|<<0>>|\(<<self>>*\)/.source, [regularStringCharacterOrComment]), 2);
2168
-
2169
- // https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/attributes/#attribute-targets
2170
- var attrTarget = /\b(?:assembly|event|field|method|module|param|property|return|type)\b/.source;
2171
- var attr = replace(/<<0>>(?:\s*\(<<1>>*\))?/.source, [identifier, roundExpression]);
2172
-
2173
- Prism.languages.insertBefore('csharp', 'class-name', {
2174
- 'attribute': {
2175
- // Attributes
2176
- // [Foo], [Foo(1), Bar(2, Prop = "foo")], [return: Foo(1), Bar(2)], [assembly: Foo(Bar)]
2177
- pattern: re(/((?:^|[^\s\w>)?])\s*\[\s*)(?:<<0>>\s*:\s*)?<<1>>(?:\s*,\s*<<1>>)*(?=\s*\])/.source, [attrTarget, attr]),
2178
- lookbehind: true,
2179
- greedy: true,
2180
- inside: {
2181
- 'target': {
2182
- pattern: re(/^<<0>>(?=\s*:)/.source, [attrTarget]),
2183
- alias: 'keyword'
2184
- },
2185
- 'attribute-arguments': {
2186
- pattern: re(/\(<<0>>*\)/.source, [roundExpression]),
2187
- inside: Prism.languages.csharp
2188
- },
2189
- 'class-name': {
2190
- pattern: RegExp(identifier),
2191
- inside: {
2192
- 'punctuation': /\./
2193
- }
2194
- },
2195
- 'punctuation': /[:,]/
2196
- }
2197
- }
2198
- });
2199
-
2200
-
2201
- // string interpolation
2202
- var formatString = /:[^}\r\n]+/.source;
2203
- // multi line
2204
- var mInterpolationRound = nested(replace(/[^"'/()]|<<0>>|\(<<self>>*\)/.source, [regularStringCharacterOrComment]), 2);
2205
- var mInterpolation = replace(/\{(?!\{)(?:(?![}:])<<0>>)*<<1>>?\}/.source, [mInterpolationRound, formatString]);
2206
- // single line
2207
- var sInterpolationRound = nested(replace(/[^"'/()]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|<<0>>|\(<<self>>*\)/.source, [regularStringOrCharacter]), 2);
2208
- var sInterpolation = replace(/\{(?!\{)(?:(?![}:])<<0>>)*<<1>>?\}/.source, [sInterpolationRound, formatString]);
2209
-
2210
- function createInterpolationInside(interpolation, interpolationRound) {
2211
- return {
2212
- 'interpolation': {
2213
- pattern: re(/((?:^|[^{])(?:\{\{)*)<<0>>/.source, [interpolation]),
2214
- lookbehind: true,
2215
- inside: {
2216
- 'format-string': {
2217
- pattern: re(/(^\{(?:(?![}:])<<0>>)*)<<1>>(?=\}$)/.source, [interpolationRound, formatString]),
2218
- lookbehind: true,
2219
- inside: {
2220
- 'punctuation': /^:/
2221
- }
2222
- },
2223
- 'punctuation': /^\{|\}$/,
2224
- 'expression': {
2225
- pattern: /[\s\S]+/,
2226
- alias: 'language-csharp',
2227
- inside: Prism.languages.csharp
2228
- }
2229
- }
2230
- },
2231
- 'string': /[\s\S]+/
2232
- };
2233
- }
2234
-
2235
- Prism.languages.insertBefore('csharp', 'string', {
2236
- 'interpolation-string': [
2237
- {
2238
- pattern: re(/(^|[^\\])(?:\$@|@\$)"(?:""|\\[\s\S]|\{\{|<<0>>|[^\\{"])*"/.source, [mInterpolation]),
2239
- lookbehind: true,
2240
- greedy: true,
2241
- inside: createInterpolationInside(mInterpolation, mInterpolationRound),
2242
- },
2243
- {
2244
- pattern: re(/(^|[^@\\])\$"(?:\\.|\{\{|<<0>>|[^\\"{])*"/.source, [sInterpolation]),
2245
- lookbehind: true,
2246
- greedy: true,
2247
- inside: createInterpolationInside(sInterpolation, sInterpolationRound),
2248
- }
2249
- ],
2250
- 'char': {
2251
- pattern: RegExp(character),
2252
- greedy: true
2253
- }
2254
- });
2255
-
2256
- Prism.languages.dotnet = Prism.languages.cs = Prism.languages.csharp;
2257
-
2258
- }(Prism));
2259
-
2260
- (function (Prism) {
2261
-
2262
- var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
2263
-
2264
- Prism.languages.css = {
2265
- 'comment': /\/\*[\s\S]*?\*\//,
2266
- 'atrule': {
2267
- pattern: RegExp('@[\\w-](?:' + /[^;{\s"']|\s+(?!\s)/.source + '|' + string.source + ')*?' + /(?:;|(?=\s*\{))/.source),
2268
- inside: {
2269
- 'rule': /^@[\w-]+/,
2270
- 'selector-function-argument': {
2271
- pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
2272
- lookbehind: true,
2273
- alias: 'selector'
2274
- },
2275
- 'keyword': {
2276
- pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
2277
- lookbehind: true
2278
- }
2279
- // See rest below
2280
- }
2281
- },
2282
- 'url': {
2283
- // https://drafts.csswg.org/css-values-3/#urls
2284
- pattern: RegExp('\\burl\\((?:' + string.source + '|' + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ')\\)', 'i'),
2285
- greedy: true,
2286
- inside: {
2287
- 'function': /^url/i,
2288
- 'punctuation': /^\(|\)$/,
2289
- 'string': {
2290
- pattern: RegExp('^' + string.source + '$'),
2291
- alias: 'url'
2292
- }
2293
- }
2294
- },
2295
- 'selector': {
2296
- pattern: RegExp('(^|[{}\\s])[^{}\\s](?:[^{};"\'\\s]|\\s+(?![\\s{])|' + string.source + ')*(?=\\s*\\{)'),
2297
- lookbehind: true
2298
- },
2299
- 'string': {
2300
- pattern: string,
2301
- greedy: true
2302
- },
2303
- 'property': {
2304
- pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
2305
- lookbehind: true
2306
- },
2307
- 'important': /!important\b/i,
2308
- 'function': {
2309
- pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
2310
- lookbehind: true
2311
- },
2312
- 'punctuation': /[(){};:,]/
2313
- };
2314
-
2315
- Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
2316
-
2317
- var markup = Prism.languages.markup;
2318
- if (markup) {
2319
- markup.tag.addInlined('style', 'css');
2320
- markup.tag.addAttribute('style', 'css');
2321
- }
2322
-
2323
- }(Prism));
2324
-
2325
- (function (Prism) {
2326
-
2327
- var keywords = /\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/;
2328
-
2329
- // full package (optional) + parent classes (optional)
2330
- var classNamePrefix = /(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source;
2331
-
2332
- // based on the java naming conventions
2333
- var className = {
2334
- pattern: RegExp(/(^|[^\w.])/.source + classNamePrefix + /[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),
2335
- lookbehind: true,
2336
- inside: {
2337
- 'namespace': {
2338
- pattern: /^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,
2339
- inside: {
2340
- 'punctuation': /\./
2341
- }
2342
- },
2343
- 'punctuation': /\./
2344
- }
2345
- };
2346
-
2347
- Prism.languages.java = Prism.languages.extend('clike', {
2348
- 'string': {
2349
- pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,
2350
- lookbehind: true,
2351
- greedy: true
2352
- },
2353
- 'class-name': [
2354
- className,
2355
- {
2356
- // variables, parameters, and constructor references
2357
- // this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
2358
- pattern: RegExp(/(^|[^\w.])/.source + classNamePrefix + /[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),
2359
- lookbehind: true,
2360
- inside: className.inside
2361
- },
2362
- {
2363
- // class names based on keyword
2364
- // this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
2365
- pattern: RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source + classNamePrefix + /[A-Z]\w*\b/.source),
2366
- lookbehind: true,
2367
- inside: className.inside
2368
- }
2369
- ],
2370
- 'keyword': keywords,
2371
- 'function': [
2372
- Prism.languages.clike.function,
2373
- {
2374
- pattern: /(::\s*)[a-z_]\w*/,
2375
- lookbehind: true
2376
- }
2377
- ],
2378
- 'number': /\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,
2379
- 'operator': {
2380
- pattern: /(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,
2381
- lookbehind: true
2382
- },
2383
- 'constant': /\b[A-Z][A-Z_\d]+\b/
2384
- });
2385
-
2386
- Prism.languages.insertBefore('java', 'string', {
2387
- 'triple-quoted-string': {
2388
- // http://openjdk.java.net/jeps/355#Description
2389
- pattern: /"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,
2390
- greedy: true,
2391
- alias: 'string'
2392
- },
2393
- 'char': {
2394
- pattern: /'(?:\\.|[^'\\\r\n]){1,6}'/,
2395
- greedy: true
2396
- }
2397
- });
2398
-
2399
- Prism.languages.insertBefore('java', 'class-name', {
2400
- 'annotation': {
2401
- pattern: /(^|[^.])@\w+(?:\s*\.\s*\w+)*/,
2402
- lookbehind: true,
2403
- alias: 'punctuation'
2404
- },
2405
- 'generics': {
2406
- pattern: /<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,
2407
- inside: {
2408
- 'class-name': className,
2409
- 'keyword': keywords,
2410
- 'punctuation': /[<>(),.:]/,
2411
- 'operator': /[?&|]/
2412
- }
2413
- },
2414
- 'import': [
2415
- {
2416
- pattern: RegExp(/(\bimport\s+)/.source + classNamePrefix + /(?:[A-Z]\w*|\*)(?=\s*;)/.source),
2417
- lookbehind: true,
2418
- inside: {
2419
- 'namespace': className.inside.namespace,
2420
- 'punctuation': /\./,
2421
- 'operator': /\*/,
2422
- 'class-name': /\w+/
2423
- }
2424
- },
2425
- {
2426
- pattern: RegExp(/(\bimport\s+static\s+)/.source + classNamePrefix + /(?:\w+|\*)(?=\s*;)/.source),
2427
- lookbehind: true,
2428
- alias: 'static',
2429
- inside: {
2430
- 'namespace': className.inside.namespace,
2431
- 'static': /\b\w+$/,
2432
- 'punctuation': /\./,
2433
- 'operator': /\*/,
2434
- 'class-name': /\w+/
2435
- }
2436
- }
2437
- ],
2438
- 'namespace': {
2439
- pattern: RegExp(
2440
- /(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!<keyword>)[a-z]\w*(?:\.[a-z]\w*)*\.?/
2441
- .source.replace(/<keyword>/g, function () { return keywords.source; })),
2442
- lookbehind: true,
2443
- inside: {
2444
- 'punctuation': /\./,
2445
- }
2446
- }
2447
- });
2448
- }(Prism));
2449
-
2450
- Prism.languages.javascript = Prism.languages.extend('clike', {
2451
- 'class-name': [
2452
- Prism.languages.clike['class-name'],
2453
- {
2454
- pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
2455
- lookbehind: true
2456
- }
2457
- ],
2458
- 'keyword': [
2459
- {
2460
- pattern: /((?:^|\})\s*)catch\b/,
2461
- lookbehind: true
2462
- },
2463
- {
2464
- pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
2465
- lookbehind: true
2466
- },
2467
- ],
2468
- // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
2469
- 'function': /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
2470
- 'number': {
2471
- pattern: RegExp(
2472
- /(^|[^\w$])/.source +
2473
- '(?:' +
2474
- (
2475
- // constant
2476
- /NaN|Infinity/.source +
2477
- '|' +
2478
- // binary integer
2479
- /0[bB][01]+(?:_[01]+)*n?/.source +
2480
- '|' +
2481
- // octal integer
2482
- /0[oO][0-7]+(?:_[0-7]+)*n?/.source +
2483
- '|' +
2484
- // hexadecimal integer
2485
- /0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source +
2486
- '|' +
2487
- // decimal bigint
2488
- /\d+(?:_\d+)*n/.source +
2489
- '|' +
2490
- // decimal number (integer or float) but no bigint
2491
- /(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source
2492
- ) +
2493
- ')' +
2494
- /(?![\w$])/.source
2495
- ),
2496
- lookbehind: true
2497
- },
2498
- 'operator': /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
2499
- });
2500
-
2501
- Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
2502
-
2503
- Prism.languages.insertBefore('javascript', 'keyword', {
2504
- 'regex': {
2505
- pattern: RegExp(
2506
- // lookbehind
2507
- // eslint-disable-next-line regexp/no-dupe-characters-character-class
2508
- /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source +
2509
- // Regex pattern:
2510
- // There are 2 regex patterns here. The RegExp set notation proposal added support for nested character
2511
- // classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible
2512
- // with the only syntax, so we have to define 2 different regex patterns.
2513
- /\//.source +
2514
- '(?:' +
2515
- /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source +
2516
- '|' +
2517
- // `v` flag syntax. This supports 3 levels of nested character classes.
2518
- /(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source +
2519
- ')' +
2520
- // lookahead
2521
- /(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
2522
- ),
2523
- lookbehind: true,
2524
- greedy: true,
2525
- inside: {
2526
- 'regex-source': {
2527
- pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
2528
- lookbehind: true,
2529
- alias: 'language-regex',
2530
- inside: Prism.languages.regex
2531
- },
2532
- 'regex-delimiter': /^\/|\/$/,
2533
- 'regex-flags': /^[a-z]+$/,
2534
- }
2535
- },
2536
- // This must be declared before keyword because we use "function" inside the look-forward
2537
- 'function-variable': {
2538
- pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,
2539
- alias: 'function'
2540
- },
2541
- 'parameter': [
2542
- {
2543
- pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
2544
- lookbehind: true,
2545
- inside: Prism.languages.javascript
2546
- },
2547
- {
2548
- pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
2549
- lookbehind: true,
2550
- inside: Prism.languages.javascript
2551
- },
2552
- {
2553
- pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
2554
- lookbehind: true,
2555
- inside: Prism.languages.javascript
2556
- },
2557
- {
2558
- pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,
2559
- lookbehind: true,
2560
- inside: Prism.languages.javascript
2561
- }
2562
- ],
2563
- 'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/
2564
- });
2565
-
2566
- Prism.languages.insertBefore('javascript', 'string', {
2567
- 'hashbang': {
2568
- pattern: /^#!.*/,
2569
- greedy: true,
2570
- alias: 'comment'
2571
- },
2572
- 'template-string': {
2573
- pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
2574
- greedy: true,
2575
- inside: {
2576
- 'template-punctuation': {
2577
- pattern: /^`|`$/,
2578
- alias: 'string'
2579
- },
2580
- 'interpolation': {
2581
- pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
2582
- lookbehind: true,
2583
- inside: {
2584
- 'interpolation-punctuation': {
2585
- pattern: /^\$\{|\}$/,
2586
- alias: 'punctuation'
2587
- },
2588
- rest: Prism.languages.javascript
2589
- }
2590
- },
2591
- 'string': /[\s\S]+/
2592
- }
2593
- },
2594
- 'string-property': {
2595
- pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
2596
- lookbehind: true,
2597
- greedy: true,
2598
- alias: 'property'
2599
- }
2600
- });
2601
-
2602
- Prism.languages.insertBefore('javascript', 'operator', {
2603
- 'literal-property': {
2604
- pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
2605
- lookbehind: true,
2606
- alias: 'property'
2607
- },
2608
- });
2609
-
2610
- if (Prism.languages.markup) {
2611
- Prism.languages.markup.tag.addInlined('script', 'javascript');
2612
-
2613
- // add attribute support for all DOM events.
2614
- // https://developer.mozilla.org/en-US/docs/Web/Events#Standard_events
2615
- Prism.languages.markup.tag.addAttribute(
2616
- /on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,
2617
- 'javascript'
2618
- );
2619
- }
2620
-
2621
- Prism.languages.js = Prism.languages.javascript;
2622
-
2623
- Prism.languages.markup = {
2624
- 'comment': {
2625
- pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
2626
- greedy: true
2627
- },
2628
- 'prolog': {
2629
- pattern: /<\?[\s\S]+?\?>/,
2630
- greedy: true
2631
- },
2632
- 'doctype': {
2633
- // https://www.w3.org/TR/xml/#NT-doctypedecl
2634
- pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
2635
- greedy: true,
2636
- inside: {
2637
- 'internal-subset': {
2638
- pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
2639
- lookbehind: true,
2640
- greedy: true,
2641
- inside: null // see below
2642
- },
2643
- 'string': {
2644
- pattern: /"[^"]*"|'[^']*'/,
2645
- greedy: true
2646
- },
2647
- 'punctuation': /^<!|>$|[[\]]/,
2648
- 'doctype-tag': /^DOCTYPE/i,
2649
- 'name': /[^\s<>'"]+/
2650
- }
2651
- },
2652
- 'cdata': {
2653
- pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
2654
- greedy: true
2655
- },
2656
- 'tag': {
2657
- pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
2658
- greedy: true,
2659
- inside: {
2660
- 'tag': {
2661
- pattern: /^<\/?[^\s>\/]+/,
2662
- inside: {
2663
- 'punctuation': /^<\/?/,
2664
- 'namespace': /^[^\s>\/:]+:/
2665
- }
2666
- },
2667
- 'special-attr': [],
2668
- 'attr-value': {
2669
- pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
2670
- inside: {
2671
- 'punctuation': [
2672
- {
2673
- pattern: /^=/,
2674
- alias: 'attr-equals'
2675
- },
2676
- {
2677
- pattern: /^(\s*)["']|["']$/,
2678
- lookbehind: true
2679
- }
2680
- ]
2681
- }
2682
- },
2683
- 'punctuation': /\/?>/,
2684
- 'attr-name': {
2685
- pattern: /[^\s>\/]+/,
2686
- inside: {
2687
- 'namespace': /^[^\s>\/:]+:/
2688
- }
2689
- }
2690
-
2691
- }
2692
- },
2693
- 'entity': [
2694
- {
2695
- pattern: /&[\da-z]{1,8};/i,
2696
- alias: 'named-entity'
2697
- },
2698
- /&#x?[\da-f]{1,8};/i
2699
- ]
2700
- };
2701
-
2702
- Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] =
2703
- Prism.languages.markup['entity'];
2704
- Prism.languages.markup['doctype'].inside['internal-subset'].inside = Prism.languages.markup;
2705
-
2706
- // Plugin to make entity title show the real entity, idea by Roman Komarov
2707
- Prism.hooks.add('wrap', function (env) {
2708
-
2709
- if (env.type === 'entity') {
2710
- env.attributes['title'] = env.content.replace(/&amp;/, '&');
2711
- }
2712
- });
2713
-
2714
- Object.defineProperty(Prism.languages.markup.tag, 'addInlined', {
2715
- /**
2716
- * Adds an inlined language to markup.
2717
- *
2718
- * An example of an inlined language is CSS with `<style>` tags.
2719
- *
2720
- * @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
2721
- * case insensitive.
2722
- * @param {string} lang The language key.
2723
- * @example
2724
- * addInlined('style', 'css');
2725
- */
2726
- value: function addInlined(tagName, lang) {
2727
- var includedCdataInside = {};
2728
- includedCdataInside['language-' + lang] = {
2729
- pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
2730
- lookbehind: true,
2731
- inside: Prism.languages[lang]
2732
- };
2733
- includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i;
2734
-
2735
- var inside = {
2736
- 'included-cdata': {
2737
- pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
2738
- inside: includedCdataInside
2739
- }
2740
- };
2741
- inside['language-' + lang] = {
2742
- pattern: /[\s\S]+/,
2743
- inside: Prism.languages[lang]
2744
- };
2745
-
2746
- var def = {};
2747
- def[tagName] = {
2748
- pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function () { return tagName; }), 'i'),
2749
- lookbehind: true,
2750
- greedy: true,
2751
- inside: inside
2752
- };
2753
-
2754
- Prism.languages.insertBefore('markup', 'cdata', def);
2755
- }
2756
- });
2757
- Object.defineProperty(Prism.languages.markup.tag, 'addAttribute', {
2758
- /**
2759
- * Adds an pattern to highlight languages embedded in HTML attributes.
2760
- *
2761
- * An example of an inlined language is CSS with `style` attributes.
2762
- *
2763
- * @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as
2764
- * case insensitive.
2765
- * @param {string} lang The language key.
2766
- * @example
2767
- * addAttribute('style', 'css');
2768
- */
2769
- value: function (attrName, lang) {
2770
- Prism.languages.markup.tag.inside['special-attr'].push({
2771
- pattern: RegExp(
2772
- /(^|["'\s])/.source + '(?:' + attrName + ')' + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
2773
- 'i'
2774
- ),
2775
- lookbehind: true,
2776
- inside: {
2777
- 'attr-name': /^[^\s=]+/,
2778
- 'attr-value': {
2779
- pattern: /=[\s\S]+/,
2780
- inside: {
2781
- 'value': {
2782
- pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
2783
- lookbehind: true,
2784
- alias: [lang, 'language-' + lang],
2785
- inside: Prism.languages[lang]
2786
- },
2787
- 'punctuation': [
2788
- {
2789
- pattern: /^=/,
2790
- alias: 'attr-equals'
2791
- },
2792
- /"|'/
2793
- ]
2794
- }
2795
- }
2796
- }
2797
- });
2798
- }
2799
- });
2800
-
2801
- Prism.languages.html = Prism.languages.markup;
2802
- Prism.languages.mathml = Prism.languages.markup;
2803
- Prism.languages.svg = Prism.languages.markup;
2804
-
2805
- Prism.languages.xml = Prism.languages.extend('markup', {});
2806
- Prism.languages.ssml = Prism.languages.xml;
2807
- Prism.languages.atom = Prism.languages.xml;
2808
- Prism.languages.rss = Prism.languages.xml;
2809
-
2810
- /**
2811
- * Original by Aaron Harun: http://aahacreative.com/2012/07/31/php-syntax-highlighting-prism/
2812
- * Modified by Miles Johnson: http://milesj.me
2813
- * Rewritten by Tom Pavelec
2814
- *
2815
- * Supports PHP 5.3 - 8.0
2816
- */
2817
- (function (Prism) {
2818
- var comment = /\/\*[\s\S]*?\*\/|\/\/.*|#(?!\[).*/;
2819
- var constant = [
2820
- {
2821
- pattern: /\b(?:false|true)\b/i,
2822
- alias: 'boolean'
2823
- },
2824
- {
2825
- pattern: /(::\s*)\b[a-z_]\w*\b(?!\s*\()/i,
2826
- greedy: true,
2827
- lookbehind: true,
2828
- },
2829
- {
2830
- pattern: /(\b(?:case|const)\s+)\b[a-z_]\w*(?=\s*[;=])/i,
2831
- greedy: true,
2832
- lookbehind: true,
2833
- },
2834
- /\b(?:null)\b/i,
2835
- /\b[A-Z_][A-Z0-9_]*\b(?!\s*\()/,
2836
- ];
2837
- var number = /\b0b[01]+(?:_[01]+)*\b|\b0o[0-7]+(?:_[0-7]+)*\b|\b0x[\da-f]+(?:_[\da-f]+)*\b|(?:\b\d+(?:_\d+)*\.?(?:\d+(?:_\d+)*)?|\B\.\d+)(?:e[+-]?\d+)?/i;
2838
- var operator = /<?=>|\?\?=?|\.{3}|\??->|[!=]=?=?|::|\*\*=?|--|\+\+|&&|\|\||<<|>>|[?~]|[/^|%*&<>.+-]=?/;
2839
- var punctuation = /[{}\[\](),:;]/;
2840
-
2841
- Prism.languages.php = {
2842
- 'delimiter': {
2843
- pattern: /\?>$|^<\?(?:php(?=\s)|=)?/i,
2844
- alias: 'important'
2845
- },
2846
- 'comment': comment,
2847
- 'variable': /\$+(?:\w+\b|(?=\{))/,
2848
- 'package': {
2849
- pattern: /(namespace\s+|use\s+(?:function\s+)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,
2850
- lookbehind: true,
2851
- inside: {
2852
- 'punctuation': /\\/
2853
- }
2854
- },
2855
- 'class-name-definition': {
2856
- pattern: /(\b(?:class|enum|interface|trait)\s+)\b[a-z_]\w*(?!\\)\b/i,
2857
- lookbehind: true,
2858
- alias: 'class-name'
2859
- },
2860
- 'function-definition': {
2861
- pattern: /(\bfunction\s+)[a-z_]\w*(?=\s*\()/i,
2862
- lookbehind: true,
2863
- alias: 'function'
2864
- },
2865
- 'keyword': [
2866
- {
2867
- pattern: /(\(\s*)\b(?:array|bool|boolean|float|int|integer|object|string)\b(?=\s*\))/i,
2868
- alias: 'type-casting',
2869
- greedy: true,
2870
- lookbehind: true
2871
- },
2872
- {
2873
- pattern: /([(,?]\s*)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|object|self|static|string)\b(?=\s*\$)/i,
2874
- alias: 'type-hint',
2875
- greedy: true,
2876
- lookbehind: true
2877
- },
2878
- {
2879
- pattern: /(\)\s*:\s*(?:\?\s*)?)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|never|object|self|static|string|void)\b/i,
2880
- alias: 'return-type',
2881
- greedy: true,
2882
- lookbehind: true
2883
- },
2884
- {
2885
- pattern: /\b(?:array(?!\s*\()|bool|float|int|iterable|mixed|object|string|void)\b/i,
2886
- alias: 'type-declaration',
2887
- greedy: true
2888
- },
2889
- {
2890
- pattern: /(\|\s*)(?:false|null)\b|\b(?:false|null)(?=\s*\|)/i,
2891
- alias: 'type-declaration',
2892
- greedy: true,
2893
- lookbehind: true
2894
- },
2895
- {
2896
- pattern: /\b(?:parent|self|static)(?=\s*::)/i,
2897
- alias: 'static-context',
2898
- greedy: true
2899
- },
2900
- {
2901
- // yield from
2902
- pattern: /(\byield\s+)from\b/i,
2903
- lookbehind: true
2904
- },
2905
- // `class` is always a keyword unlike other keywords
2906
- /\bclass\b/i,
2907
- {
2908
- // https://www.php.net/manual/en/reserved.keywords.php
2909
- //
2910
- // keywords cannot be preceded by "->"
2911
- // the complex lookbehind means `(?<!(?:->|::)\s*)`
2912
- pattern: /((?:^|[^\s>:]|(?:^|[^-])>|(?:^|[^:]):)\s*)\b(?:abstract|and|array|as|break|callable|case|catch|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|enum|eval|exit|extends|final|finally|fn|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|match|namespace|never|new|or|parent|print|private|protected|public|readonly|require|require_once|return|self|static|switch|throw|trait|try|unset|use|var|while|xor|yield|__halt_compiler)\b/i,
2913
- lookbehind: true
2914
- }
2915
- ],
2916
- 'argument-name': {
2917
- pattern: /([(,]\s*)\b[a-z_]\w*(?=\s*:(?!:))/i,
2918
- lookbehind: true
2919
- },
2920
- 'class-name': [
2921
- {
2922
- pattern: /(\b(?:extends|implements|instanceof|new(?!\s+self|\s+static))\s+|\bcatch\s*\()\b[a-z_]\w*(?!\\)\b/i,
2923
- greedy: true,
2924
- lookbehind: true
2925
- },
2926
- {
2927
- pattern: /(\|\s*)\b[a-z_]\w*(?!\\)\b/i,
2928
- greedy: true,
2929
- lookbehind: true
2930
- },
2931
- {
2932
- pattern: /\b[a-z_]\w*(?!\\)\b(?=\s*\|)/i,
2933
- greedy: true
2934
- },
2935
- {
2936
- pattern: /(\|\s*)(?:\\?\b[a-z_]\w*)+\b/i,
2937
- alias: 'class-name-fully-qualified',
2938
- greedy: true,
2939
- lookbehind: true,
2940
- inside: {
2941
- 'punctuation': /\\/
2942
- }
2943
- },
2944
- {
2945
- pattern: /(?:\\?\b[a-z_]\w*)+\b(?=\s*\|)/i,
2946
- alias: 'class-name-fully-qualified',
2947
- greedy: true,
2948
- inside: {
2949
- 'punctuation': /\\/
2950
- }
2951
- },
2952
- {
2953
- pattern: /(\b(?:extends|implements|instanceof|new(?!\s+self\b|\s+static\b))\s+|\bcatch\s*\()(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,
2954
- alias: 'class-name-fully-qualified',
2955
- greedy: true,
2956
- lookbehind: true,
2957
- inside: {
2958
- 'punctuation': /\\/
2959
- }
2960
- },
2961
- {
2962
- pattern: /\b[a-z_]\w*(?=\s*\$)/i,
2963
- alias: 'type-declaration',
2964
- greedy: true
2965
- },
2966
- {
2967
- pattern: /(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,
2968
- alias: ['class-name-fully-qualified', 'type-declaration'],
2969
- greedy: true,
2970
- inside: {
2971
- 'punctuation': /\\/
2972
- }
2973
- },
2974
- {
2975
- pattern: /\b[a-z_]\w*(?=\s*::)/i,
2976
- alias: 'static-context',
2977
- greedy: true
2978
- },
2979
- {
2980
- pattern: /(?:\\?\b[a-z_]\w*)+(?=\s*::)/i,
2981
- alias: ['class-name-fully-qualified', 'static-context'],
2982
- greedy: true,
2983
- inside: {
2984
- 'punctuation': /\\/
2985
- }
2986
- },
2987
- {
2988
- pattern: /([(,?]\s*)[a-z_]\w*(?=\s*\$)/i,
2989
- alias: 'type-hint',
2990
- greedy: true,
2991
- lookbehind: true
2992
- },
2993
- {
2994
- pattern: /([(,?]\s*)(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,
2995
- alias: ['class-name-fully-qualified', 'type-hint'],
2996
- greedy: true,
2997
- lookbehind: true,
2998
- inside: {
2999
- 'punctuation': /\\/
3000
- }
3001
- },
3002
- {
3003
- pattern: /(\)\s*:\s*(?:\?\s*)?)\b[a-z_]\w*(?!\\)\b/i,
3004
- alias: 'return-type',
3005
- greedy: true,
3006
- lookbehind: true
3007
- },
3008
- {
3009
- pattern: /(\)\s*:\s*(?:\?\s*)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,
3010
- alias: ['class-name-fully-qualified', 'return-type'],
3011
- greedy: true,
3012
- lookbehind: true,
3013
- inside: {
3014
- 'punctuation': /\\/
3015
- }
3016
- }
3017
- ],
3018
- 'constant': constant,
3019
- 'function': {
3020
- pattern: /(^|[^\\\w])\\?[a-z_](?:[\w\\]*\w)?(?=\s*\()/i,
3021
- lookbehind: true,
3022
- inside: {
3023
- 'punctuation': /\\/
3024
- }
3025
- },
3026
- 'property': {
3027
- pattern: /(->\s*)\w+/,
3028
- lookbehind: true
3029
- },
3030
- 'number': number,
3031
- 'operator': operator,
3032
- 'punctuation': punctuation
3033
- };
3034
-
3035
- var string_interpolation = {
3036
- pattern: /\{\$(?:\{(?:\{[^{}]+\}|[^{}]+)\}|[^{}])+\}|(^|[^\\{])\$+(?:\w+(?:\[[^\r\n\[\]]+\]|->\w+)?)/,
3037
- lookbehind: true,
3038
- inside: Prism.languages.php
3039
- };
3040
-
3041
- var string = [
3042
- {
3043
- pattern: /<<<'([^']+)'[\r\n](?:.*[\r\n])*?\1;/,
3044
- alias: 'nowdoc-string',
3045
- greedy: true,
3046
- inside: {
3047
- 'delimiter': {
3048
- pattern: /^<<<'[^']+'|[a-z_]\w*;$/i,
3049
- alias: 'symbol',
3050
- inside: {
3051
- 'punctuation': /^<<<'?|[';]$/
3052
- }
3053
- }
3054
- }
3055
- },
3056
- {
3057
- pattern: /<<<(?:"([^"]+)"[\r\n](?:.*[\r\n])*?\1;|([a-z_]\w*)[\r\n](?:.*[\r\n])*?\2;)/i,
3058
- alias: 'heredoc-string',
3059
- greedy: true,
3060
- inside: {
3061
- 'delimiter': {
3062
- pattern: /^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,
3063
- alias: 'symbol',
3064
- inside: {
3065
- 'punctuation': /^<<<"?|[";]$/
3066
- }
3067
- },
3068
- 'interpolation': string_interpolation
3069
- }
3070
- },
3071
- {
3072
- pattern: /`(?:\\[\s\S]|[^\\`])*`/,
3073
- alias: 'backtick-quoted-string',
3074
- greedy: true
3075
- },
3076
- {
3077
- pattern: /'(?:\\[\s\S]|[^\\'])*'/,
3078
- alias: 'single-quoted-string',
3079
- greedy: true
3080
- },
3081
- {
3082
- pattern: /"(?:\\[\s\S]|[^\\"])*"/,
3083
- alias: 'double-quoted-string',
3084
- greedy: true,
3085
- inside: {
3086
- 'interpolation': string_interpolation
3087
- }
3088
- }
3089
- ];
3090
-
3091
- Prism.languages.insertBefore('php', 'variable', {
3092
- 'string': string,
3093
- 'attribute': {
3094
- pattern: /#\[(?:[^"'\/#]|\/(?![*/])|\/\/.*$|#(?!\[).*$|\/\*(?:[^*]|\*(?!\/))*\*\/|"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*')+\](?=\s*[a-z$#])/im,
3095
- greedy: true,
3096
- inside: {
3097
- 'attribute-content': {
3098
- pattern: /^(#\[)[\s\S]+(?=\]$)/,
3099
- lookbehind: true,
3100
- // inside can appear subset of php
3101
- inside: {
3102
- 'comment': comment,
3103
- 'string': string,
3104
- 'attribute-class-name': [
3105
- {
3106
- pattern: /([^:]|^)\b[a-z_]\w*(?!\\)\b/i,
3107
- alias: 'class-name',
3108
- greedy: true,
3109
- lookbehind: true
3110
- },
3111
- {
3112
- pattern: /([^:]|^)(?:\\?\b[a-z_]\w*)+/i,
3113
- alias: [
3114
- 'class-name',
3115
- 'class-name-fully-qualified'
3116
- ],
3117
- greedy: true,
3118
- lookbehind: true,
3119
- inside: {
3120
- 'punctuation': /\\/
3121
- }
3122
- }
3123
- ],
3124
- 'constant': constant,
3125
- 'number': number,
3126
- 'operator': operator,
3127
- 'punctuation': punctuation
3128
- }
3129
- },
3130
- 'delimiter': {
3131
- pattern: /^#\[|\]$/,
3132
- alias: 'punctuation'
3133
- }
3134
- }
3135
- },
3136
- });
3137
-
3138
- Prism.hooks.add('before-tokenize', function (env) {
3139
- if (!/<\?/.test(env.code)) {
3140
- return;
3141
- }
3142
-
3143
- var phpPattern = /<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#(?!\[))(?:[^?\n\r]|\?(?!>))*(?=$|\?>|[\r\n])|#\[|\/\*(?:[^*]|\*(?!\/))*(?:\*\/|$))*?(?:\?>|$)/g;
3144
- Prism.languages['markup-templating'].buildPlaceholders(env, 'php', phpPattern);
3145
- });
3146
-
3147
- Prism.hooks.add('after-tokenize', function (env) {
3148
- Prism.languages['markup-templating'].tokenizePlaceholders(env, 'php');
3149
- });
3150
-
3151
- }(Prism));
3152
-
3153
- Prism.languages.python = {
3154
- 'comment': {
3155
- pattern: /(^|[^\\])#.*/,
3156
- lookbehind: true,
3157
- greedy: true
3158
- },
3159
- 'string-interpolation': {
3160
- pattern: /(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
3161
- greedy: true,
3162
- inside: {
3163
- 'interpolation': {
3164
- // "{" <expression> <optional "!s", "!r", or "!a"> <optional ":" format specifier> "}"
3165
- pattern: /((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,
3166
- lookbehind: true,
3167
- inside: {
3168
- 'format-spec': {
3169
- pattern: /(:)[^:(){}]+(?=\}$)/,
3170
- lookbehind: true
3171
- },
3172
- 'conversion-option': {
3173
- pattern: /![sra](?=[:}]$)/,
3174
- alias: 'punctuation'
3175
- },
3176
- rest: null
3177
- }
3178
- },
3179
- 'string': /[\s\S]+/
3180
- }
3181
- },
3182
- 'triple-quoted-string': {
3183
- pattern: /(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,
3184
- greedy: true,
3185
- alias: 'string'
3186
- },
3187
- 'string': {
3188
- pattern: /(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,
3189
- greedy: true
3190
- },
3191
- 'function': {
3192
- pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,
3193
- lookbehind: true
3194
- },
3195
- 'class-name': {
3196
- pattern: /(\bclass\s+)\w+/i,
3197
- lookbehind: true
3198
- },
3199
- 'decorator': {
3200
- pattern: /(^[\t ]*)@\w+(?:\.\w+)*/m,
3201
- lookbehind: true,
3202
- alias: ['annotation', 'punctuation'],
3203
- inside: {
3204
- 'punctuation': /\./
3205
- }
3206
- },
3207
- 'keyword': /\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,
3208
- 'builtin': /\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,
3209
- 'boolean': /\b(?:False|None|True)\b/,
3210
- 'number': /\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,
3211
- 'operator': /[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
3212
- 'punctuation': /[{}[\];(),.:]/
3213
- };
3214
-
3215
- Prism.languages.python['string-interpolation'].inside['interpolation'].inside.rest = Prism.languages.python;
3216
-
3217
- Prism.languages.py = Prism.languages.python;
3218
-
3219
- /**
3220
- * Original by Samuel Flores
3221
- *
3222
- * Adds the following new token classes:
3223
- * constant, builtin, variable, symbol, regex
3224
- */
3225
- (function (Prism) {
3226
- Prism.languages.ruby = Prism.languages.extend('clike', {
3227
- 'comment': {
3228
- pattern: /#.*|^=begin\s[\s\S]*?^=end/m,
3229
- greedy: true
3230
- },
3231
- 'class-name': {
3232
- pattern: /(\b(?:class|module)\s+|\bcatch\s+\()[\w.\\]+|\b[A-Z_]\w*(?=\s*\.\s*new\b)/,
3233
- lookbehind: true,
3234
- inside: {
3235
- 'punctuation': /[.\\]/
3236
- }
3237
- },
3238
- 'keyword': /\b(?:BEGIN|END|alias|and|begin|break|case|class|def|define_method|defined|do|each|else|elsif|end|ensure|extend|for|if|in|include|module|new|next|nil|not|or|prepend|private|protected|public|raise|redo|require|rescue|retry|return|self|super|then|throw|undef|unless|until|when|while|yield)\b/,
3239
- 'operator': /\.{2,3}|&\.|===|<?=>|[!=]?~|(?:&&|\|\||<<|>>|\*\*|[+\-*/%<>!^&|=])=?|[?:]/,
3240
- 'punctuation': /[(){}[\].,;]/,
3241
- });
3242
-
3243
- Prism.languages.insertBefore('ruby', 'operator', {
3244
- 'double-colon': {
3245
- pattern: /::/,
3246
- alias: 'punctuation'
3247
- },
3248
- });
3249
-
3250
- var interpolation = {
3251
- pattern: /((?:^|[^\\])(?:\\{2})*)#\{(?:[^{}]|\{[^{}]*\})*\}/,
3252
- lookbehind: true,
3253
- inside: {
3254
- 'content': {
3255
- pattern: /^(#\{)[\s\S]+(?=\}$)/,
3256
- lookbehind: true,
3257
- inside: Prism.languages.ruby
3258
- },
3259
- 'delimiter': {
3260
- pattern: /^#\{|\}$/,
3261
- alias: 'punctuation'
3262
- }
3263
- }
3264
- };
3265
-
3266
- delete Prism.languages.ruby.function;
3267
-
3268
- var percentExpression = '(?:' + [
3269
- /([^a-zA-Z0-9\s{(\[<=])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,
3270
- /\((?:[^()\\]|\\[\s\S]|\((?:[^()\\]|\\[\s\S])*\))*\)/.source,
3271
- /\{(?:[^{}\\]|\\[\s\S]|\{(?:[^{}\\]|\\[\s\S])*\})*\}/.source,
3272
- /\[(?:[^\[\]\\]|\\[\s\S]|\[(?:[^\[\]\\]|\\[\s\S])*\])*\]/.source,
3273
- /<(?:[^<>\\]|\\[\s\S]|<(?:[^<>\\]|\\[\s\S])*>)*>/.source
3274
- ].join('|') + ')';
3275
-
3276
- var symbolName = /(?:"(?:\\.|[^"\\\r\n])*"|(?:\b[a-zA-Z_]\w*|[^\s\0-\x7F]+)[?!]?|\$.)/.source;
3277
-
3278
- Prism.languages.insertBefore('ruby', 'keyword', {
3279
- 'regex-literal': [
3280
- {
3281
- pattern: RegExp(/%r/.source + percentExpression + /[egimnosux]{0,6}/.source),
3282
- greedy: true,
3283
- inside: {
3284
- 'interpolation': interpolation,
3285
- 'regex': /[\s\S]+/
3286
- }
3287
- },
3288
- {
3289
- pattern: /(^|[^/])\/(?!\/)(?:\[[^\r\n\]]+\]|\\.|[^[/\\\r\n])+\/[egimnosux]{0,6}(?=\s*(?:$|[\r\n,.;})#]))/,
3290
- lookbehind: true,
3291
- greedy: true,
3292
- inside: {
3293
- 'interpolation': interpolation,
3294
- 'regex': /[\s\S]+/
3295
- }
3296
- }
3297
- ],
3298
- 'variable': /[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,
3299
- 'symbol': [
3300
- {
3301
- pattern: RegExp(/(^|[^:]):/.source + symbolName),
3302
- lookbehind: true,
3303
- greedy: true
3304
- },
3305
- {
3306
- pattern: RegExp(/([\r\n{(,][ \t]*)/.source + symbolName + /(?=:(?!:))/.source),
3307
- lookbehind: true,
3308
- greedy: true
3309
- },
3310
- ],
3311
- 'method-definition': {
3312
- pattern: /(\bdef\s+)\w+(?:\s*\.\s*\w+)?/,
3313
- lookbehind: true,
3314
- inside: {
3315
- 'function': /\b\w+$/,
3316
- 'keyword': /^self\b/,
3317
- 'class-name': /^\w+/,
3318
- 'punctuation': /\./
3319
- }
3320
- }
3321
- });
3322
-
3323
- Prism.languages.insertBefore('ruby', 'string', {
3324
- 'string-literal': [
3325
- {
3326
- pattern: RegExp(/%[qQiIwWs]?/.source + percentExpression),
3327
- greedy: true,
3328
- inside: {
3329
- 'interpolation': interpolation,
3330
- 'string': /[\s\S]+/
3331
- }
3332
- },
3333
- {
3334
- pattern: /("|')(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|(?!\1)[^\\#\r\n])*\1/,
3335
- greedy: true,
3336
- inside: {
3337
- 'interpolation': interpolation,
3338
- 'string': /[\s\S]+/
3339
- }
3340
- },
3341
- {
3342
- pattern: /<<[-~]?([a-z_]\w*)[\r\n](?:.*[\r\n])*?[\t ]*\1/i,
3343
- alias: 'heredoc-string',
3344
- greedy: true,
3345
- inside: {
3346
- 'delimiter': {
3347
- pattern: /^<<[-~]?[a-z_]\w*|\b[a-z_]\w*$/i,
3348
- inside: {
3349
- 'symbol': /\b\w+/,
3350
- 'punctuation': /^<<[-~]?/
3351
- }
3352
- },
3353
- 'interpolation': interpolation,
3354
- 'string': /[\s\S]+/
3355
- }
3356
- },
3357
- {
3358
- pattern: /<<[-~]?'([a-z_]\w*)'[\r\n](?:.*[\r\n])*?[\t ]*\1/i,
3359
- alias: 'heredoc-string',
3360
- greedy: true,
3361
- inside: {
3362
- 'delimiter': {
3363
- pattern: /^<<[-~]?'[a-z_]\w*'|\b[a-z_]\w*$/i,
3364
- inside: {
3365
- 'symbol': /\b\w+/,
3366
- 'punctuation': /^<<[-~]?'|'$/,
3367
- }
3368
- },
3369
- 'string': /[\s\S]+/
3370
- }
3371
- }
3372
- ],
3373
- 'command-literal': [
3374
- {
3375
- pattern: RegExp(/%x/.source + percentExpression),
3376
- greedy: true,
3377
- inside: {
3378
- 'interpolation': interpolation,
3379
- 'command': {
3380
- pattern: /[\s\S]+/,
3381
- alias: 'string'
3382
- }
3383
- }
3384
- },
3385
- {
3386
- pattern: /`(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|[^\\`#\r\n])*`/,
3387
- greedy: true,
3388
- inside: {
3389
- 'interpolation': interpolation,
3390
- 'command': {
3391
- pattern: /[\s\S]+/,
3392
- alias: 'string'
3393
- }
3394
- }
3395
- }
3396
- ]
3397
- });
3398
-
3399
- delete Prism.languages.ruby.string;
3400
-
3401
- Prism.languages.insertBefore('ruby', 'number', {
3402
- 'builtin': /\b(?:Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Fixnum|Float|Hash|IO|Integer|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|Stat|String|Struct|Symbol|TMS|Thread|ThreadGroup|Time|TrueClass)\b/,
3403
- 'constant': /\b[A-Z][A-Z0-9_]*(?:[?!]|\b)/
3404
- });
3405
-
3406
- Prism.languages.rb = Prism.languages.ruby;
3407
- }(Prism));
3408
-
3409
- // restore the original Prism reference
3410
- window.Prism = oldprism;
3411
- return Prism;
3412
- }(undefined, undefined);
3413
-
3414
- const option = (name) => (editor) => editor.options.get(name);
3415
- const register$2 = (editor) => {
3416
- const registerOption = editor.options.register;
3417
- registerOption('codesample_languages', {
3418
- processor: 'object[]'
3419
- });
3420
- registerOption('codesample_global_prismjs', {
3421
- processor: 'boolean',
3422
- default: false
3423
- });
3424
- };
3425
- const getLanguages$1 = option('codesample_languages');
3426
- const useGlobalPrismJS = option('codesample_global_prismjs');
3427
-
3428
- const get = (editor) => Global.Prism && useGlobalPrismJS(editor) ? Global.Prism : prismjs;
3429
-
3430
- const isCodeSample = (elm) => {
3431
- return isNonNullable(elm) && elm.nodeName === 'PRE' && elm.className.indexOf('language-') !== -1;
3432
- };
3433
-
3434
- const getSelectedCodeSample = (editor) => {
3435
- const node = editor.selection ? editor.selection.getNode() : null;
3436
- return isCodeSample(node) ? Optional.some(node) : Optional.none();
3437
- };
3438
- const insertCodeSample = (editor, language, code) => {
3439
- const dom = editor.dom;
3440
- editor.undoManager.transact(() => {
3441
- const node = getSelectedCodeSample(editor);
3442
- code = global$1.DOM.encode(code);
3443
- return node.fold(() => {
3444
- editor.insertContent('<pre id="__new" class="language-' + language + '">' + code + '</pre>');
3445
- const newPre = dom.select('#__new')[0];
3446
- dom.setAttrib(newPre, 'id', null);
3447
- editor.selection.select(newPre);
3448
- }, (n) => {
3449
- dom.setAttrib(n, 'class', 'language-' + language);
3450
- n.innerHTML = code;
3451
- get(editor).highlightElement(n);
3452
- editor.selection.select(n);
3453
- });
3454
- });
3455
- };
3456
- const getCurrentCode = (editor) => {
3457
- const node = getSelectedCodeSample(editor);
3458
- return node.bind((n) => Optional.from(n.textContent)).getOr('');
3459
- };
3460
-
3461
- const getLanguages = (editor) => {
3462
- const defaultLanguages = [
3463
- { text: 'HTML/XML', value: 'markup' },
3464
- { text: 'JavaScript', value: 'javascript' },
3465
- { text: 'CSS', value: 'css' },
3466
- { text: 'PHP', value: 'php' },
3467
- { text: 'Ruby', value: 'ruby' },
3468
- { text: 'Python', value: 'python' },
3469
- { text: 'Java', value: 'java' },
3470
- { text: 'C', value: 'c' },
3471
- { text: 'C#', value: 'csharp' },
3472
- { text: 'C++', value: 'cpp' }
3473
- ];
3474
- const customLanguages = getLanguages$1(editor);
3475
- return customLanguages ? customLanguages : defaultLanguages;
3476
- };
3477
- const getCurrentLanguage = (editor, fallback) => {
3478
- const node = getSelectedCodeSample(editor);
3479
- return node.fold(() => fallback, (n) => {
3480
- const matches = n.className.match(/language-(\w+)/);
3481
- return matches ? matches[1] : fallback;
3482
- });
3483
- };
3484
-
3485
- const open = (editor) => {
3486
- const languages = getLanguages(editor);
3487
- const defaultLanguage = head(languages).fold(constant(''), (l) => l.value);
3488
- const currentLanguage = getCurrentLanguage(editor, defaultLanguage);
3489
- const currentCode = getCurrentCode(editor);
3490
- editor.windowManager.open({
3491
- title: 'Insert/Edit Code Sample',
3492
- size: 'large',
3493
- body: {
3494
- type: 'panel',
3495
- items: [
3496
- {
3497
- type: 'listbox',
3498
- name: 'language',
3499
- label: 'Language',
3500
- items: languages
3501
- },
3502
- {
3503
- type: 'textarea',
3504
- name: 'code',
3505
- label: 'Code view',
3506
- spellcheck: false,
3507
- }
3508
- ]
3509
- },
3510
- buttons: [
3511
- {
3512
- type: 'cancel',
3513
- name: 'cancel',
3514
- text: 'Cancel'
3515
- },
3516
- {
3517
- type: 'submit',
3518
- name: 'save',
3519
- text: 'Save',
3520
- primary: true
3521
- }
3522
- ],
3523
- initialData: {
3524
- language: currentLanguage,
3525
- code: currentCode
3526
- },
3527
- onSubmit: (api) => {
3528
- const data = api.getData();
3529
- insertCodeSample(editor, data.language, data.code);
3530
- api.close();
3531
- }
3532
- });
3533
- };
3534
-
3535
- const register$1 = (editor) => {
3536
- editor.addCommand('codesample', () => {
3537
- const node = editor.selection.getNode();
3538
- if (editor.selection.isCollapsed() || isCodeSample(node)) {
3539
- open(editor);
3540
- }
3541
- else {
3542
- editor.formatter.toggle('code');
3543
- }
3544
- });
3545
- };
3546
-
3547
- var global = tinymce.util.Tools.resolve('tinymce.util.Tools');
3548
-
3549
- const setup = (editor) => {
3550
- editor.on('PreProcess', (e) => {
3551
- const dom = editor.dom;
3552
- const pres = dom.select('pre[contenteditable=false]', e.node);
3553
- global.each(global.grep(pres, isCodeSample), (elm) => {
3554
- const code = elm.textContent;
3555
- dom.setAttrib(elm, 'class', trim(dom.getAttrib(elm, 'class')));
3556
- dom.setAttrib(elm, 'contentEditable', null);
3557
- dom.setAttrib(elm, 'data-mce-highlighted', null);
3558
- // Empty the pre element
3559
- let child;
3560
- while ((child = elm.firstChild)) {
3561
- elm.removeChild(child);
3562
- }
3563
- const codeElm = dom.add(elm, 'code');
3564
- // Needs to be textContent since innerText produces BR:s
3565
- codeElm.textContent = code;
3566
- });
3567
- });
3568
- editor.on('SetContent', () => {
3569
- const dom = editor.dom;
3570
- const unprocessedCodeSamples = global.grep(dom.select('pre'), (elm) => {
3571
- return isCodeSample(elm) && dom.getAttrib(elm, 'data-mce-highlighted') !== 'true';
3572
- });
3573
- if (unprocessedCodeSamples.length) {
3574
- editor.undoManager.transact(() => {
3575
- global.each(unprocessedCodeSamples, (elm) => {
3576
- global.each(dom.select('br', elm), (elm) => {
3577
- dom.replace(editor.getDoc().createTextNode('\n'), elm);
3578
- });
3579
- elm.innerHTML = dom.encode(elm.textContent ?? '');
3580
- get(editor).highlightElement(elm);
3581
- dom.setAttrib(elm, 'data-mce-highlighted', true);
3582
- elm.className = trim(elm.className);
3583
- });
3584
- });
3585
- }
3586
- });
3587
- editor.on('PreInit', () => {
3588
- editor.parser.addNodeFilter('pre', (nodes) => {
3589
- for (let i = 0, l = nodes.length; i < l; i++) {
3590
- const node = nodes[i];
3591
- const isCodeSample = (node.attr('class') ?? '').indexOf('language-') !== -1;
3592
- if (isCodeSample) {
3593
- node.attr('contenteditable', 'false');
3594
- node.attr('data-mce-highlighted', 'false');
3595
- }
3596
- }
3597
- });
3598
- });
3599
- };
3600
-
3601
- const onSetupEditable = (editor, onChanged = noop) => (api) => {
3602
- const nodeChanged = () => {
3603
- api.setEnabled(editor.selection.isEditable());
3604
- onChanged(api);
3605
- };
3606
- editor.on('NodeChange', nodeChanged);
3607
- nodeChanged();
3608
- return () => {
3609
- editor.off('NodeChange', nodeChanged);
3610
- };
3611
- };
3612
- const isCodeSampleSelection = (editor) => {
3613
- const node = editor.selection.getStart();
3614
- return editor.dom.is(node, 'pre[class*="language-"]');
3615
- };
3616
- const register = (editor) => {
3617
- const onAction = () => editor.execCommand('codesample');
3618
- editor.ui.registry.addToggleButton('codesample', {
3619
- icon: 'code-sample',
3620
- tooltip: 'Insert/edit code sample',
3621
- onAction,
3622
- onSetup: onSetupEditable(editor, (api) => {
3623
- api.setActive(isCodeSampleSelection(editor));
3624
- })
3625
- });
3626
- editor.ui.registry.addMenuItem('codesample', {
3627
- text: 'Code sample...',
3628
- icon: 'code-sample',
3629
- onAction,
3630
- onSetup: onSetupEditable(editor)
3631
- });
3632
- };
3633
-
3634
- var Plugin = () => {
3635
- global$2.add('codesample', (editor) => {
3636
- register$2(editor);
3637
- setup(editor);
3638
- register(editor);
3639
- register$1(editor);
3640
- editor.on('dblclick', (ev) => {
3641
- if (isCodeSample(ev.target)) {
3642
- open(editor);
3643
- }
3644
- });
3645
- });
3646
- };
3647
-
3648
- Plugin();
3649
- /** *****
3650
- * DO NOT EXPORT ANYTHING
3651
- *
3652
- * IF YOU DO ROLLUP WILL LEAVE A GLOBAL ON THE PAGE
3653
- *******/
3654
-
3655
- })();