hermium 0.1.10 → 0.2.0

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 (212) hide show
  1. package/README.md +56 -0
  2. package/bin/hermium.mjs +185 -164
  3. package/dist/api.mjs +3513 -0
  4. package/dist/public/assets/css/index-Dfs9RUU9.css +1 -0
  5. package/dist/public/assets/css/styles-B8p6jk5Z.css +1 -0
  6. package/dist/public/assets/js/ChatInputBlock-Bw7AL70H.js +1 -0
  7. package/dist/public/assets/js/MarkdownMessage-8d7Y6VL-.js +1 -0
  8. package/dist/public/assets/js/base-ui-BvQbAt_1.js +1 -0
  9. package/dist/public/assets/js/chat._sessionId-BG6lVraH.js +1 -0
  10. package/dist/public/assets/js/chat.index-D2zdMPTT.js +1 -0
  11. package/dist/public/assets/js/index-C0AK45FU.js +60 -0
  12. package/dist/public/assets/js/index-Cx5En4FK.js +1 -0
  13. package/dist/public/assets/js/memory-CeSRdTkW.js +3 -0
  14. package/dist/public/assets/js/router-8uDKazL-.js +1 -0
  15. package/dist/public/assets/js/settings-Bc3Y5zXO.js +1 -0
  16. package/dist/public/assets/js/skills-DZv7sA_5.js +1 -0
  17. package/dist/public/assets/js/theme-CPkdkpaj.js +1 -0
  18. package/dist/public/assets/js/usage-DXQsT9_b.js +1 -0
  19. package/dist/public/assets/woff2/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  20. package/dist/public/assets/woff2/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  21. package/dist/public/assets/woff2/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  22. package/dist/public/assets/woff2/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  23. package/dist/public/assets/woff2/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  24. package/dist/public/favicon.ico +0 -0
  25. package/dist/public/logo.png +0 -0
  26. package/package.json +1 -1
  27. package/dist/public/assets/IconAlertCircle-BW147gsG.js +0 -1
  28. package/dist/public/assets/IconAlertTriangle-DCoTLVSd.js +0 -1
  29. package/dist/public/assets/IconCheck-DAO7Fpl9.js +0 -1
  30. package/dist/public/assets/IconCode-BqfTl5wU.js +0 -1
  31. package/dist/public/assets/IconLoader2-B_pehSXN.js +0 -1
  32. package/dist/public/assets/IconRefresh-BbMGoMV8.js +0 -1
  33. package/dist/public/assets/geist-cyrillic-wght-normal-CHSlOQsW.woff2 +0 -0
  34. package/dist/public/assets/geist-latin-ext-wght-normal-DMtmJ5ZE.woff2 +0 -0
  35. package/dist/public/assets/geist-latin-wght-normal-Dm3htQBi.woff2 +0 -0
  36. package/dist/public/assets/index-BL9a2Xg9.js +0 -1
  37. package/dist/public/assets/index-BSwXjgjr.js +0 -1
  38. package/dist/public/assets/index-BWl8tn18.js +0 -1
  39. package/dist/public/assets/index-CQh8SXb2.js +0 -94
  40. package/dist/public/assets/index-Cxd-kSUY.js +0 -1
  41. package/dist/public/assets/index-DA5SH--7.js +0 -2
  42. package/dist/public/assets/index-DCHbvtBS.js +0 -1
  43. package/dist/public/assets/index-DCYXJZEe.js +0 -1
  44. package/dist/public/assets/index-DFDfp0ca.js +0 -1
  45. package/dist/public/assets/index-GuAAqSCJ.js +0 -14
  46. package/dist/public/assets/index-WIDirTHx.js +0 -29
  47. package/dist/public/assets/index-X3XZcAzy.js +0 -1
  48. package/dist/public/assets/input-7TQEEJq6.js +0 -1
  49. package/dist/public/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
  50. package/dist/public/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
  51. package/dist/public/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
  52. package/dist/public/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
  53. package/dist/public/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
  54. package/dist/public/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
  55. package/dist/public/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
  56. package/dist/public/assets/models-BlUb1eaf.js +0 -1
  57. package/dist/public/assets/styles-PHtUFHUr.css +0 -1
  58. package/dist/public/assets/switch-B_iYUUM3.js +0 -1
  59. package/dist/public/assets/syntax-highlighter-DcBYfnEK.js +0 -6
  60. package/dist/public/assets/textarea-Dm4aaRqS.js +0 -1
  61. package/dist/public/favicon.png +0 -0
  62. package/dist/public/nous-logo.png +0 -0
  63. package/dist/server/index.mjs +0 -244
  64. package/dist/web-server/__23tanstack-start-plugin-adapters-Cwee5PKy.mjs +0 -6
  65. package/dist/web-server/_chunks/ssr-renderer.mjs +0 -22
  66. package/dist/web-server/_libs/babel__runtime.mjs +0 -237
  67. package/dist/web-server/_libs/bail.mjs +0 -8
  68. package/dist/web-server/_libs/base-ui__react.mjs +0 -9554
  69. package/dist/web-server/_libs/base-ui__utils.mjs +0 -1101
  70. package/dist/web-server/_libs/ccount.mjs +0 -16
  71. package/dist/web-server/_libs/character-entities-legacy.mjs +0 -111
  72. package/dist/web-server/_libs/character-entities.mjs +0 -2130
  73. package/dist/web-server/_libs/character-reference-invalid.mjs +0 -33
  74. package/dist/web-server/_libs/class-variance-authority.mjs +0 -44
  75. package/dist/web-server/_libs/clsx.mjs +0 -16
  76. package/dist/web-server/_libs/comma-separated-tokens.mjs +0 -31
  77. package/dist/web-server/_libs/cookie-es.mjs +0 -44
  78. package/dist/web-server/_libs/croner.mjs +0 -1
  79. package/dist/web-server/_libs/crossws.mjs +0 -1
  80. package/dist/web-server/_libs/decode-named-character-reference+[...].mjs +0 -8
  81. package/dist/web-server/_libs/devlop.mjs +0 -8
  82. package/dist/web-server/_libs/escape-string-regexp.mjs +0 -9
  83. package/dist/web-server/_libs/estree-util-is-identifier-name.mjs +0 -11
  84. package/dist/web-server/_libs/extend.mjs +0 -97
  85. package/dist/web-server/_libs/fault.mjs +0 -1
  86. package/dist/web-server/_libs/floating-ui__core.mjs +0 -663
  87. package/dist/web-server/_libs/floating-ui__dom.mjs +0 -624
  88. package/dist/web-server/_libs/floating-ui__react-dom.mjs +0 -279
  89. package/dist/web-server/_libs/floating-ui__utils.mjs +0 -322
  90. package/dist/web-server/_libs/format.mjs +0 -1
  91. package/dist/web-server/_libs/h3.mjs +0 -408
  92. package/dist/web-server/_libs/hast-util-parse-selector.mjs +0 -39
  93. package/dist/web-server/_libs/hast-util-to-jsx-runtime.mjs +0 -388
  94. package/dist/web-server/_libs/hast-util-whitespace.mjs +0 -10
  95. package/dist/web-server/_libs/hastscript.mjs +0 -200
  96. package/dist/web-server/_libs/highlight.js.mjs +0 -1
  97. package/dist/web-server/_libs/hookable.mjs +0 -1
  98. package/dist/web-server/_libs/html-url-attributes.mjs +0 -26
  99. package/dist/web-server/_libs/inline-style-parser.mjs +0 -142
  100. package/dist/web-server/_libs/is-alphabetical.mjs +0 -7
  101. package/dist/web-server/_libs/is-alphanumerical.mjs +0 -8
  102. package/dist/web-server/_libs/is-decimal.mjs +0 -7
  103. package/dist/web-server/_libs/is-hexadecimal.mjs +0 -7
  104. package/dist/web-server/_libs/is-plain-obj.mjs +0 -10
  105. package/dist/web-server/_libs/isbot.mjs +0 -21
  106. package/dist/web-server/_libs/longest-streak.mjs +0 -25
  107. package/dist/web-server/_libs/lowlight.mjs +0 -1
  108. package/dist/web-server/_libs/markdown-table.mjs +0 -142
  109. package/dist/web-server/_libs/mdast-util-find-and-replace.mjs +0 -109
  110. package/dist/web-server/_libs/mdast-util-from-markdown.mjs +0 -717
  111. package/dist/web-server/_libs/mdast-util-gfm-autolink-literal+[...].mjs +0 -156
  112. package/dist/web-server/_libs/mdast-util-gfm-footnote.mjs +0 -117
  113. package/dist/web-server/_libs/mdast-util-gfm-strikethrough.mjs +0 -54
  114. package/dist/web-server/_libs/mdast-util-gfm-table.mjs +0 -157
  115. package/dist/web-server/_libs/mdast-util-gfm-task-list-item.mjs +0 -77
  116. package/dist/web-server/_libs/mdast-util-gfm.mjs +0 -29
  117. package/dist/web-server/_libs/mdast-util-phrasing.mjs +0 -30
  118. package/dist/web-server/_libs/mdast-util-to-hast.mjs +0 -710
  119. package/dist/web-server/_libs/mdast-util-to-markdown.mjs +0 -798
  120. package/dist/web-server/_libs/mdast-util-to-string.mjs +0 -38
  121. package/dist/web-server/_libs/micromark-core-commonmark.mjs +0 -2259
  122. package/dist/web-server/_libs/micromark-extension-gfm-autolink-literal+[...].mjs +0 -344
  123. package/dist/web-server/_libs/micromark-extension-gfm-footnote+[...].mjs +0 -279
  124. package/dist/web-server/_libs/micromark-extension-gfm-strikethrough+[...].mjs +0 -98
  125. package/dist/web-server/_libs/micromark-extension-gfm-table.mjs +0 -491
  126. package/dist/web-server/_libs/micromark-extension-gfm-tagfilter+[...].mjs +0 -1
  127. package/dist/web-server/_libs/micromark-extension-gfm-task-list-item+[...].mjs +0 -77
  128. package/dist/web-server/_libs/micromark-extension-gfm.mjs +0 -18
  129. package/dist/web-server/_libs/micromark-factory-destination.mjs +0 -94
  130. package/dist/web-server/_libs/micromark-factory-label.mjs +0 -63
  131. package/dist/web-server/_libs/micromark-factory-space.mjs +0 -24
  132. package/dist/web-server/_libs/micromark-factory-title.mjs +0 -65
  133. package/dist/web-server/_libs/micromark-factory-whitespace.mjs +0 -22
  134. package/dist/web-server/_libs/micromark-util-character.mjs +0 -44
  135. package/dist/web-server/_libs/micromark-util-chunked.mjs +0 -36
  136. package/dist/web-server/_libs/micromark-util-classify-character+[...].mjs +0 -12
  137. package/dist/web-server/_libs/micromark-util-combine-extensions+[...].mjs +0 -41
  138. package/dist/web-server/_libs/micromark-util-decode-numeric-character-reference+[...].mjs +0 -19
  139. package/dist/web-server/_libs/micromark-util-decode-string.mjs +0 -21
  140. package/dist/web-server/_libs/micromark-util-encode.mjs +0 -1
  141. package/dist/web-server/_libs/micromark-util-html-tag-name.mjs +0 -69
  142. package/dist/web-server/_libs/micromark-util-normalize-identifier+[...].mjs +0 -6
  143. package/dist/web-server/_libs/micromark-util-resolve-all.mjs +0 -15
  144. package/dist/web-server/_libs/micromark-util-sanitize-uri.mjs +0 -41
  145. package/dist/web-server/_libs/micromark-util-subtokenize.mjs +0 -346
  146. package/dist/web-server/_libs/micromark.mjs +0 -906
  147. package/dist/web-server/_libs/ocache.mjs +0 -1
  148. package/dist/web-server/_libs/ohash.mjs +0 -1
  149. package/dist/web-server/_libs/parse-entities.mjs +0 -245
  150. package/dist/web-server/_libs/property-information.mjs +0 -1210
  151. package/dist/web-server/_libs/react-dom.mjs +0 -10779
  152. package/dist/web-server/_libs/react-markdown.mjs +0 -147
  153. package/dist/web-server/_libs/react-syntax-highlighter.mjs +0 -941
  154. package/dist/web-server/_libs/react.mjs +0 -513
  155. package/dist/web-server/_libs/refractor.mjs +0 -2425
  156. package/dist/web-server/_libs/remark-gfm.mjs +0 -20
  157. package/dist/web-server/_libs/remark-parse.mjs +0 -19
  158. package/dist/web-server/_libs/remark-rehype.mjs +0 -21
  159. package/dist/web-server/_libs/reselect.mjs +0 -1
  160. package/dist/web-server/_libs/rou3.mjs +0 -8
  161. package/dist/web-server/_libs/seroval-plugins.mjs +0 -58
  162. package/dist/web-server/_libs/seroval.mjs +0 -1775
  163. package/dist/web-server/_libs/space-separated-tokens.mjs +0 -11
  164. package/dist/web-server/_libs/srvx.mjs +0 -781
  165. package/dist/web-server/_libs/style-to-js.mjs +0 -72
  166. package/dist/web-server/_libs/style-to-object.mjs +0 -38
  167. package/dist/web-server/_libs/tabler__icons-react.mjs +0 -233
  168. package/dist/web-server/_libs/tanstack__history.mjs +0 -204
  169. package/dist/web-server/_libs/tanstack__query-core.mjs +0 -2552
  170. package/dist/web-server/_libs/tanstack__react-query.mjs +0 -190
  171. package/dist/web-server/_libs/tanstack__react-router.mjs +0 -1120
  172. package/dist/web-server/_libs/tanstack__react-store.mjs +0 -2
  173. package/dist/web-server/_libs/tanstack__router-core.mjs +0 -4288
  174. package/dist/web-server/_libs/tanstack__store.mjs +0 -1
  175. package/dist/web-server/_libs/trim-lines.mjs +0 -41
  176. package/dist/web-server/_libs/trough.mjs +0 -85
  177. package/dist/web-server/_libs/ufo.mjs +0 -54
  178. package/dist/web-server/_libs/unctx.mjs +0 -1
  179. package/dist/web-server/_libs/ungap__structured-clone.mjs +0 -224
  180. package/dist/web-server/_libs/unified.mjs +0 -661
  181. package/dist/web-server/_libs/unist-util-is.mjs +0 -100
  182. package/dist/web-server/_libs/unist-util-position.mjs +0 -27
  183. package/dist/web-server/_libs/unist-util-stringify-position.mjs +0 -27
  184. package/dist/web-server/_libs/unist-util-visit-parents.mjs +0 -83
  185. package/dist/web-server/_libs/unist-util-visit.mjs +0 -24
  186. package/dist/web-server/_libs/unstorage.mjs +0 -1
  187. package/dist/web-server/_libs/use-sync-external-store.mjs +0 -139
  188. package/dist/web-server/_libs/vfile-message.mjs +0 -138
  189. package/dist/web-server/_libs/vfile.mjs +0 -467
  190. package/dist/web-server/_libs/zod.mjs +0 -3915
  191. package/dist/web-server/_libs/zustand.mjs +0 -343
  192. package/dist/web-server/_libs/zwitch.mjs +0 -1
  193. package/dist/web-server/_ssr/index--Bo2_ipW.mjs +0 -277
  194. package/dist/web-server/_ssr/index-BEvygh5x.mjs +0 -612
  195. package/dist/web-server/_ssr/index-BFaKxYfN.mjs +0 -40
  196. package/dist/web-server/_ssr/index-BdrMzRTd.mjs +0 -513
  197. package/dist/web-server/_ssr/index-CoDfv1vI.mjs +0 -66
  198. package/dist/web-server/_ssr/index-Cwp8Gyl1.mjs +0 -1812
  199. package/dist/web-server/_ssr/index-DQsfKYjV.mjs +0 -449
  200. package/dist/web-server/_ssr/index-Dbs9k8Ea.mjs +0 -251
  201. package/dist/web-server/_ssr/index-Dk93oyZD.mjs +0 -213
  202. package/dist/web-server/_ssr/index-KNJ7huw_.mjs +0 -369
  203. package/dist/web-server/_ssr/index.mjs +0 -1558
  204. package/dist/web-server/_ssr/input-BV1DMASc.mjs +0 -20
  205. package/dist/web-server/_ssr/models-MzrvbL2i.mjs +0 -43
  206. package/dist/web-server/_ssr/router-CS6Zq3md.mjs +0 -2134
  207. package/dist/web-server/_ssr/start-HYkvq4Ni.mjs +0 -4
  208. package/dist/web-server/_ssr/switch-Bd-Sg0HG.mjs +0 -33
  209. package/dist/web-server/_ssr/syntax-highlighter-5vezNTce.mjs +0 -62
  210. package/dist/web-server/_ssr/textarea-CB4kQp9w.mjs +0 -18
  211. package/dist/web-server/_tanstack-start-manifest_v-m5lY48LR.mjs +0 -4
  212. package/dist/web-server/index.mjs +0 -611
@@ -1,2425 +0,0 @@
1
- import { h } from "./hastscript.mjs";
2
- import { p as parseEntities } from "./parse-entities.mjs";
3
- var uniqueId = 0;
4
- var plainTextGrammar = {};
5
- var _ = {
6
- /**
7
- * A namespace for utility methods.
8
- *
9
- * All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
10
- * change or disappear at any time.
11
- *
12
- * @namespace
13
- * @memberof Prism
14
- */
15
- util: {
16
- /**
17
- * Returns the name of the type of the given value.
18
- *
19
- * @param {any} o
20
- * @returns {string}
21
- * @example
22
- * type(null) === 'Null'
23
- * type(undefined) === 'Undefined'
24
- * type(123) === 'Number'
25
- * type('foo') === 'String'
26
- * type(true) === 'Boolean'
27
- * type([1, 2]) === 'Array'
28
- * type({}) === 'Object'
29
- * type(String) === 'Function'
30
- * type(/abc+/) === 'RegExp'
31
- */
32
- type: function(o) {
33
- return Object.prototype.toString.call(o).slice(8, -1);
34
- },
35
- /**
36
- * Returns a unique number for the given object. Later calls will still return the same number.
37
- *
38
- * @param {Object} obj
39
- * @returns {number}
40
- */
41
- objId: function(obj) {
42
- if (!obj["__id"]) {
43
- Object.defineProperty(obj, "__id", { value: ++uniqueId });
44
- }
45
- return obj["__id"];
46
- },
47
- /**
48
- * Creates a deep clone of the given object.
49
- *
50
- * The main intended use of this function is to clone language definitions.
51
- *
52
- * @param {T} o
53
- * @param {Record<number, any>} [visited]
54
- * @returns {T}
55
- * @template T
56
- */
57
- clone: function deepClone(o, visited) {
58
- visited = visited || {};
59
- var clone;
60
- var id;
61
- switch (_.util.type(o)) {
62
- case "Object":
63
- id = _.util.objId(o);
64
- if (visited[id]) {
65
- return visited[id];
66
- }
67
- clone = /** @type {Record<string, any>} */
68
- {};
69
- visited[id] = clone;
70
- for (var key in o) {
71
- if (o.hasOwnProperty(key)) {
72
- clone[key] = deepClone(o[key], visited);
73
- }
74
- }
75
- return (
76
- /** @type {any} */
77
- clone
78
- );
79
- case "Array":
80
- id = _.util.objId(o);
81
- if (visited[id]) {
82
- return visited[id];
83
- }
84
- clone = [];
85
- visited[id] = clone;
86
- /** @type {any} */
87
- o.forEach(
88
- function(v, i) {
89
- clone[i] = deepClone(v, visited);
90
- }
91
- );
92
- return (
93
- /** @type {any} */
94
- clone
95
- );
96
- default:
97
- return o;
98
- }
99
- }
100
- },
101
- /**
102
- * This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
103
- *
104
- * @namespace
105
- * @memberof Prism
106
- * @public
107
- */
108
- languages: {
109
- /**
110
- * The grammar for plain, unformatted text.
111
- */
112
- plain: plainTextGrammar,
113
- plaintext: plainTextGrammar,
114
- text: plainTextGrammar,
115
- txt: plainTextGrammar,
116
- /**
117
- * Creates a deep copy of the language with the given id and appends the given tokens.
118
- *
119
- * If a token in `redef` also appears in the copied language, then the existing token in the copied language
120
- * will be overwritten at its original position.
121
- *
122
- * ## Best practices
123
- *
124
- * Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)
125
- * doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to
126
- * understand the language definition because, normally, the order of tokens matters in Prism grammars.
127
- *
128
- * Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.
129
- * Furthermore, all non-overwriting tokens should be placed after the overwriting ones.
130
- *
131
- * @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.
132
- * @param {Grammar} redef The new tokens to append.
133
- * @returns {Grammar} The new language created.
134
- * @public
135
- * @example
136
- * Prism.languages['css-with-colors'] = Prism.languages.extend('css', {
137
- * // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
138
- * // at its original position
139
- * 'comment': { ... },
140
- * // CSS doesn't have a 'color' token, so this token will be appended
141
- * 'color': /\b(?:red|green|blue)\b/
142
- * });
143
- */
144
- extend: function(id, redef) {
145
- var lang = _.util.clone(_.languages[id]);
146
- for (var key in redef) {
147
- lang[key] = redef[key];
148
- }
149
- return lang;
150
- },
151
- /**
152
- * Inserts tokens _before_ another token in a language definition or any other grammar.
153
- *
154
- * ## Usage
155
- *
156
- * This helper method makes it easy to modify existing languages. For example, the CSS language definition
157
- * not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded
158
- * in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the
159
- * appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do
160
- * this:
161
- *
162
- * ```js
163
- * Prism.languages.markup.style = {
164
- * // token
165
- * };
166
- * ```
167
- *
168
- * then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens
169
- * before existing tokens. For the CSS example above, you would use it like this:
170
- *
171
- * ```js
172
- * Prism.languages.insertBefore('markup', 'cdata', {
173
- * 'style': {
174
- * // token
175
- * }
176
- * });
177
- * ```
178
- *
179
- * ## Special cases
180
- *
181
- * If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar
182
- * will be ignored.
183
- *
184
- * This behavior can be used to insert tokens after `before`:
185
- *
186
- * ```js
187
- * Prism.languages.insertBefore('markup', 'comment', {
188
- * 'comment': Prism.languages.markup.comment,
189
- * // tokens after 'comment'
190
- * });
191
- * ```
192
- *
193
- * ## Limitations
194
- *
195
- * The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object
196
- * properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave
197
- * differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily
198
- * deleting properties which is necessary to insert at arbitrary positions.
199
- *
200
- * To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object.
201
- * Instead, it will create a new object and replace all references to the target object with the new one. This
202
- * can be done without temporarily deleting properties, so the iteration order is well-defined.
203
- *
204
- * However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if
205
- * you hold the target object in a variable, then the value of the variable will not change.
206
- *
207
- * ```js
208
- * var oldMarkup = Prism.languages.markup;
209
- * var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... });
210
- *
211
- * assert(oldMarkup !== Prism.languages.markup);
212
- * assert(newMarkup === Prism.languages.markup);
213
- * ```
214
- *
215
- * @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the
216
- * object to be modified.
217
- * @param {string} before The key to insert before.
218
- * @param {Grammar} insert An object containing the key-value pairs to be inserted.
219
- * @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the
220
- * object to be modified.
221
- *
222
- * Defaults to `Prism.languages`.
223
- * @returns {Grammar} The new grammar object.
224
- * @public
225
- */
226
- insertBefore: function(inside, before, insert, root) {
227
- root = root || /** @type {any} */
228
- _.languages;
229
- var grammar = root[inside];
230
- var ret = {};
231
- for (var token in grammar) {
232
- if (grammar.hasOwnProperty(token)) {
233
- if (token == before) {
234
- for (var newToken in insert) {
235
- if (insert.hasOwnProperty(newToken)) {
236
- ret[newToken] = insert[newToken];
237
- }
238
- }
239
- }
240
- if (!insert.hasOwnProperty(token)) {
241
- ret[token] = grammar[token];
242
- }
243
- }
244
- }
245
- var old = root[inside];
246
- root[inside] = ret;
247
- _.languages.DFS(_.languages, function(key, value) {
248
- if (value === old && key != inside) {
249
- this[key] = ret;
250
- }
251
- });
252
- return ret;
253
- },
254
- // Traverse a language definition with Depth First Search
255
- DFS: function DFS(o, callback, type, visited) {
256
- visited = visited || {};
257
- var objId = _.util.objId;
258
- for (var i in o) {
259
- if (o.hasOwnProperty(i)) {
260
- callback.call(o, i, o[i], type || i);
261
- var property = o[i];
262
- var propertyType = _.util.type(property);
263
- if (propertyType === "Object" && !visited[objId(property)]) {
264
- visited[objId(property)] = true;
265
- DFS(property, callback, null, visited);
266
- } else if (propertyType === "Array" && !visited[objId(property)]) {
267
- visited[objId(property)] = true;
268
- DFS(property, callback, i, visited);
269
- }
270
- }
271
- }
272
- }
273
- },
274
- plugins: {},
275
- /**
276
- * Low-level function, only use if you know what you’re doing. It accepts a string of text as input
277
- * and the language definitions to use, and returns a string with the HTML produced.
278
- *
279
- * The following hooks will be run:
280
- * 1. `before-tokenize`
281
- * 2. `after-tokenize`
282
- * 3. `wrap`: On each {@link Token}.
283
- *
284
- * @param {string} text A string with the code to be highlighted.
285
- * @param {Grammar} grammar An object containing the tokens to use.
286
- *
287
- * Usually a language definition like `Prism.languages.markup`.
288
- * @param {string} language The name of the language definition passed to `grammar`.
289
- * @returns {string} The highlighted HTML.
290
- * @memberof Prism
291
- * @public
292
- * @example
293
- * Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
294
- */
295
- highlight: function(text, grammar, language) {
296
- var env = {
297
- code: text,
298
- grammar,
299
- language
300
- };
301
- _.hooks.run("before-tokenize", env);
302
- if (!env.grammar) {
303
- throw new Error('The language "' + env.language + '" has no grammar.');
304
- }
305
- env.tokens = _.tokenize(env.code, env.grammar);
306
- _.hooks.run("after-tokenize", env);
307
- return Token.stringify(_.util.encode(env.tokens), env.language);
308
- },
309
- /**
310
- * This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
311
- * and the language definitions to use, and returns an array with the tokenized code.
312
- *
313
- * When the language definition includes nested tokens, the function is called recursively on each of these tokens.
314
- *
315
- * This method could be useful in other contexts as well, as a very crude parser.
316
- *
317
- * @param {string} text A string with the code to be highlighted.
318
- * @param {Grammar} grammar An object containing the tokens to use.
319
- *
320
- * Usually a language definition like `Prism.languages.markup`.
321
- * @returns {TokenStream} An array of strings and tokens, a token stream.
322
- * @memberof Prism
323
- * @public
324
- * @example
325
- * let code = `var foo = 0;`;
326
- * let tokens = Prism.tokenize(code, Prism.languages.javascript);
327
- * tokens.forEach(token => {
328
- * if (token instanceof Prism.Token && token.type === 'number') {
329
- * console.log(`Found numeric literal: ${token.content}`);
330
- * }
331
- * });
332
- */
333
- tokenize: function(text, grammar) {
334
- var rest = grammar.rest;
335
- if (rest) {
336
- for (var token in rest) {
337
- grammar[token] = rest[token];
338
- }
339
- delete grammar.rest;
340
- }
341
- var tokenList = new LinkedList();
342
- addAfter(tokenList, tokenList.head, text);
343
- matchGrammar(text, tokenList, grammar, tokenList.head, 0);
344
- return toArray(tokenList);
345
- },
346
- /**
347
- * @namespace
348
- * @memberof Prism
349
- * @public
350
- */
351
- hooks: {
352
- all: {},
353
- /**
354
- * Adds the given callback to the list of callbacks for the given hook.
355
- *
356
- * The callback will be invoked when the hook it is registered for is run.
357
- * Hooks are usually directly run by a highlight function but you can also run hooks yourself.
358
- *
359
- * One callback function can be registered to multiple hooks and the same hook multiple times.
360
- *
361
- * @param {string} name The name of the hook.
362
- * @param {HookCallback} callback The callback function which is given environment variables.
363
- * @public
364
- */
365
- add: function(name, callback) {
366
- var hooks = _.hooks.all;
367
- hooks[name] = hooks[name] || [];
368
- hooks[name].push(callback);
369
- },
370
- /**
371
- * Runs a hook invoking all registered callbacks with the given environment variables.
372
- *
373
- * Callbacks will be invoked synchronously and in the order in which they were registered.
374
- *
375
- * @param {string} name The name of the hook.
376
- * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
377
- * @public
378
- */
379
- run: function(name, env) {
380
- var callbacks = _.hooks.all[name];
381
- if (!callbacks || !callbacks.length) {
382
- return;
383
- }
384
- for (var i = 0, callback; callback = callbacks[i++]; ) {
385
- callback(env);
386
- }
387
- }
388
- },
389
- Token
390
- };
391
- function Token(type, content, alias2, matchedStr) {
392
- this.type = type;
393
- this.content = content;
394
- this.alias = alias2;
395
- this.length = (matchedStr || "").length | 0;
396
- }
397
- function matchPattern(pattern, pos, text, lookbehind) {
398
- pattern.lastIndex = pos;
399
- var match = pattern.exec(text);
400
- if (match && lookbehind && match[1]) {
401
- var lookbehindLength = match[1].length;
402
- match.index += lookbehindLength;
403
- match[0] = match[0].slice(lookbehindLength);
404
- }
405
- return match;
406
- }
407
- function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) {
408
- for (var token in grammar) {
409
- if (!grammar.hasOwnProperty(token) || !grammar[token]) {
410
- continue;
411
- }
412
- var patterns = grammar[token];
413
- patterns = Array.isArray(patterns) ? patterns : [patterns];
414
- for (var j = 0; j < patterns.length; ++j) {
415
- if (rematch && rematch.cause == token + "," + j) {
416
- return;
417
- }
418
- var patternObj = patterns[j];
419
- var inside = patternObj.inside;
420
- var lookbehind = !!patternObj.lookbehind;
421
- var greedy = !!patternObj.greedy;
422
- var alias2 = patternObj.alias;
423
- if (greedy && !patternObj.pattern.global) {
424
- var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0];
425
- patternObj.pattern = RegExp(patternObj.pattern.source, flags + "g");
426
- }
427
- var pattern = patternObj.pattern || patternObj;
428
- for (var currentNode = startNode.next, pos = startPos; currentNode !== tokenList.tail; pos += currentNode.value.length, currentNode = currentNode.next) {
429
- if (rematch && pos >= rematch.reach) {
430
- break;
431
- }
432
- var str = currentNode.value;
433
- if (tokenList.length > text.length) {
434
- return;
435
- }
436
- if (str instanceof Token) {
437
- continue;
438
- }
439
- var removeCount = 1;
440
- var match;
441
- if (greedy) {
442
- match = matchPattern(pattern, pos, text, lookbehind);
443
- if (!match || match.index >= text.length) {
444
- break;
445
- }
446
- var from = match.index;
447
- var to = match.index + match[0].length;
448
- var p = pos;
449
- p += currentNode.value.length;
450
- while (from >= p) {
451
- currentNode = currentNode.next;
452
- p += currentNode.value.length;
453
- }
454
- p -= currentNode.value.length;
455
- pos = p;
456
- if (currentNode.value instanceof Token) {
457
- continue;
458
- }
459
- for (var k = currentNode; k !== tokenList.tail && (p < to || typeof k.value === "string"); k = k.next) {
460
- removeCount++;
461
- p += k.value.length;
462
- }
463
- removeCount--;
464
- str = text.slice(pos, p);
465
- match.index -= pos;
466
- } else {
467
- match = matchPattern(pattern, 0, str, lookbehind);
468
- if (!match) {
469
- continue;
470
- }
471
- }
472
- var from = match.index;
473
- var matchStr = match[0];
474
- var before = str.slice(0, from);
475
- var after = str.slice(from + matchStr.length);
476
- var reach = pos + str.length;
477
- if (rematch && reach > rematch.reach) {
478
- rematch.reach = reach;
479
- }
480
- var removeFrom = currentNode.prev;
481
- if (before) {
482
- removeFrom = addAfter(tokenList, removeFrom, before);
483
- pos += before.length;
484
- }
485
- removeRange(tokenList, removeFrom, removeCount);
486
- var wrapped = new Token(
487
- token,
488
- inside ? _.tokenize(matchStr, inside) : matchStr,
489
- alias2,
490
- matchStr
491
- );
492
- currentNode = addAfter(tokenList, removeFrom, wrapped);
493
- if (after) {
494
- addAfter(tokenList, currentNode, after);
495
- }
496
- if (removeCount > 1) {
497
- var nestedRematch = {
498
- cause: token + "," + j,
499
- reach
500
- };
501
- matchGrammar(
502
- text,
503
- tokenList,
504
- grammar,
505
- currentNode.prev,
506
- pos,
507
- nestedRematch
508
- );
509
- if (rematch && nestedRematch.reach > rematch.reach) {
510
- rematch.reach = nestedRematch.reach;
511
- }
512
- }
513
- }
514
- }
515
- }
516
- }
517
- function LinkedList() {
518
- var head = { value: null, prev: null, next: null };
519
- var tail = { value: null, prev: head, next: null };
520
- head.next = tail;
521
- this.head = head;
522
- this.tail = tail;
523
- this.length = 0;
524
- }
525
- function addAfter(list, node, value) {
526
- var next = node.next;
527
- var newNode = { value, prev: node, next };
528
- node.next = newNode;
529
- next.prev = newNode;
530
- list.length++;
531
- return newNode;
532
- }
533
- function removeRange(list, node, count) {
534
- var next = node.next;
535
- for (var i = 0; i < count && next !== list.tail; i++) {
536
- next = next.next;
537
- }
538
- node.next = next;
539
- next.prev = node;
540
- list.length -= i;
541
- }
542
- function toArray(list) {
543
- var array = [];
544
- var node = list.head.next;
545
- while (node !== list.tail) {
546
- array.push(node.value);
547
- node = node.next;
548
- }
549
- return array;
550
- }
551
- const Prism = _;
552
- function Refractor() {
553
- }
554
- Refractor.prototype = Prism;
555
- const refractor = new Refractor();
556
- refractor.highlight = highlight;
557
- refractor.register = register;
558
- refractor.alias = alias;
559
- refractor.registered = registered;
560
- refractor.listLanguages = listLanguages;
561
- refractor.util.encode = encode;
562
- refractor.Token.stringify = stringify;
563
- function highlight(value, language) {
564
- if (typeof value !== "string") {
565
- throw new TypeError("Expected `string` for `value`, got `" + value + "`");
566
- }
567
- let grammar;
568
- let name;
569
- if (language && typeof language === "object") {
570
- grammar = language;
571
- } else {
572
- name = language;
573
- if (typeof name !== "string") {
574
- throw new TypeError("Expected `string` for `name`, got `" + name + "`");
575
- }
576
- if (Object.hasOwn(refractor.languages, name)) {
577
- grammar = refractor.languages[name];
578
- } else {
579
- throw new Error("Unknown language: `" + name + "` is not registered");
580
- }
581
- }
582
- return {
583
- type: "root",
584
- // @ts-expect-error: we hacked Prism to accept and return the things we want.
585
- children: Prism.highlight.call(refractor, value, grammar, name)
586
- };
587
- }
588
- function register(syntax) {
589
- if (typeof syntax !== "function" || !syntax.displayName) {
590
- throw new Error("Expected `function` for `syntax`, got `" + syntax + "`");
591
- }
592
- if (!Object.hasOwn(refractor.languages, syntax.displayName)) {
593
- syntax(refractor);
594
- }
595
- }
596
- function alias(language, alias2) {
597
- const languages = refractor.languages;
598
- let map = {};
599
- if (typeof language === "string") {
600
- if (alias2) {
601
- map[language] = alias2;
602
- }
603
- } else {
604
- map = language;
605
- }
606
- let key;
607
- for (key in map) {
608
- if (Object.hasOwn(map, key)) {
609
- const value = map[key];
610
- const list = typeof value === "string" ? [value] : value;
611
- let index = -1;
612
- while (++index < list.length) {
613
- languages[list[index]] = languages[key];
614
- }
615
- }
616
- }
617
- }
618
- function registered(aliasOrLanguage) {
619
- if (typeof aliasOrLanguage !== "string") {
620
- throw new TypeError(
621
- "Expected `string` for `aliasOrLanguage`, got `" + aliasOrLanguage + "`"
622
- );
623
- }
624
- return Object.hasOwn(refractor.languages, aliasOrLanguage);
625
- }
626
- function listLanguages() {
627
- const languages = refractor.languages;
628
- const list = [];
629
- let language;
630
- for (language in languages) {
631
- if (Object.hasOwn(languages, language) && typeof languages[language] === "object") {
632
- list.push(language);
633
- }
634
- }
635
- return list;
636
- }
637
- function stringify(value, language) {
638
- if (typeof value === "string") {
639
- return { type: "text", value };
640
- }
641
- if (Array.isArray(value)) {
642
- const result = [];
643
- let index = -1;
644
- while (++index < value.length) {
645
- if (value[index] !== null && value[index] !== void 0 && value[index] !== "") {
646
- result.push(
647
- /** @type {Element | Text} */
648
- stringify(value[index], language)
649
- );
650
- }
651
- }
652
- return result;
653
- }
654
- const env = {
655
- attributes: {},
656
- classes: ["token", value.type],
657
- content: stringify(value.content, language),
658
- language,
659
- tag: "span",
660
- type: value.type
661
- };
662
- if (value.alias) {
663
- env.classes.push(
664
- ...typeof value.alias === "string" ? [value.alias] : value.alias
665
- );
666
- }
667
- refractor.hooks.run("wrap", env);
668
- return h(
669
- env.tag + "." + env.classes.join("."),
670
- attributes(env.attributes),
671
- env.content
672
- );
673
- }
674
- function encode(tokens) {
675
- return tokens;
676
- }
677
- function attributes(record) {
678
- let key;
679
- for (key in record) {
680
- if (Object.hasOwn(record, key)) {
681
- record[key] = parseEntities(record[key]);
682
- }
683
- }
684
- return record;
685
- }
686
- markup.displayName = "markup";
687
- markup.aliases = ["atom", "html", "mathml", "rss", "ssml", "svg", "xml"];
688
- function markup(Prism2) {
689
- Prism2.languages.markup = {
690
- comment: {
691
- pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
692
- greedy: true
693
- },
694
- prolog: {
695
- pattern: /<\?[\s\S]+?\?>/,
696
- greedy: true
697
- },
698
- doctype: {
699
- // https://www.w3.org/TR/xml/#NT-doctypedecl
700
- pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
701
- greedy: true,
702
- inside: {
703
- "internal-subset": {
704
- pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
705
- lookbehind: true,
706
- greedy: true,
707
- inside: null
708
- // see below
709
- },
710
- string: {
711
- pattern: /"[^"]*"|'[^']*'/,
712
- greedy: true
713
- },
714
- punctuation: /^<!|>$|[[\]]/,
715
- "doctype-tag": /^DOCTYPE/i,
716
- name: /[^\s<>'"]+/
717
- }
718
- },
719
- cdata: {
720
- pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
721
- greedy: true
722
- },
723
- tag: {
724
- pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
725
- greedy: true,
726
- inside: {
727
- tag: {
728
- pattern: /^<\/?[^\s>\/]+/,
729
- inside: {
730
- punctuation: /^<\/?/,
731
- namespace: /^[^\s>\/:]+:/
732
- }
733
- },
734
- "special-attr": [],
735
- "attr-value": {
736
- pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
737
- inside: {
738
- punctuation: [
739
- {
740
- pattern: /^=/,
741
- alias: "attr-equals"
742
- },
743
- {
744
- pattern: /^(\s*)["']|["']$/,
745
- lookbehind: true
746
- }
747
- ]
748
- }
749
- },
750
- punctuation: /\/?>/,
751
- "attr-name": {
752
- pattern: /[^\s>\/]+/,
753
- inside: {
754
- namespace: /^[^\s>\/:]+:/
755
- }
756
- }
757
- }
758
- },
759
- entity: [
760
- {
761
- pattern: /&[\da-z]{1,8};/i,
762
- alias: "named-entity"
763
- },
764
- /&#x?[\da-f]{1,8};/i
765
- ]
766
- };
767
- Prism2.languages.markup["tag"].inside["attr-value"].inside["entity"] = Prism2.languages.markup["entity"];
768
- Prism2.languages.markup["doctype"].inside["internal-subset"].inside = Prism2.languages.markup;
769
- Prism2.hooks.add("wrap", function(env) {
770
- if (env.type === "entity") {
771
- env.attributes["title"] = env.content.value.replace(/&amp;/, "&");
772
- }
773
- });
774
- Object.defineProperty(Prism2.languages.markup.tag, "addInlined", {
775
- /**
776
- * Adds an inlined language to markup.
777
- *
778
- * An example of an inlined language is CSS with `<style>` tags.
779
- *
780
- * @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
781
- * case insensitive.
782
- * @param {string} lang The language key.
783
- * @example
784
- * addInlined('style', 'css');
785
- */
786
- value: function addInlined(tagName, lang) {
787
- var includedCdataInside = {};
788
- includedCdataInside["language-" + lang] = {
789
- pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
790
- lookbehind: true,
791
- inside: Prism2.languages[lang]
792
- };
793
- includedCdataInside["cdata"] = /^<!\[CDATA\[|\]\]>$/i;
794
- var inside = {
795
- "included-cdata": {
796
- pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
797
- inside: includedCdataInside
798
- }
799
- };
800
- inside["language-" + lang] = {
801
- pattern: /[\s\S]+/,
802
- inside: Prism2.languages[lang]
803
- };
804
- var def = {};
805
- def[tagName] = {
806
- pattern: RegExp(
807
- /(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(
808
- /__/g,
809
- function() {
810
- return tagName;
811
- }
812
- ),
813
- "i"
814
- ),
815
- lookbehind: true,
816
- greedy: true,
817
- inside
818
- };
819
- Prism2.languages.insertBefore("markup", "cdata", def);
820
- }
821
- });
822
- Object.defineProperty(Prism2.languages.markup.tag, "addAttribute", {
823
- /**
824
- * Adds an pattern to highlight languages embedded in HTML attributes.
825
- *
826
- * An example of an inlined language is CSS with `style` attributes.
827
- *
828
- * @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as
829
- * case insensitive.
830
- * @param {string} lang The language key.
831
- * @example
832
- * addAttribute('style', 'css');
833
- */
834
- value: function(attrName, lang) {
835
- Prism2.languages.markup.tag.inside["special-attr"].push({
836
- pattern: RegExp(
837
- /(^|["'\s])/.source + "(?:" + attrName + ")" + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
838
- "i"
839
- ),
840
- lookbehind: true,
841
- inside: {
842
- "attr-name": /^[^\s=]+/,
843
- "attr-value": {
844
- pattern: /=[\s\S]+/,
845
- inside: {
846
- value: {
847
- pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
848
- lookbehind: true,
849
- alias: [lang, "language-" + lang],
850
- inside: Prism2.languages[lang]
851
- },
852
- punctuation: [
853
- {
854
- pattern: /^=/,
855
- alias: "attr-equals"
856
- },
857
- /"|'/
858
- ]
859
- }
860
- }
861
- }
862
- });
863
- }
864
- });
865
- Prism2.languages.html = Prism2.languages.markup;
866
- Prism2.languages.mathml = Prism2.languages.markup;
867
- Prism2.languages.svg = Prism2.languages.markup;
868
- Prism2.languages.xml = Prism2.languages.extend("markup", {});
869
- Prism2.languages.ssml = Prism2.languages.xml;
870
- Prism2.languages.atom = Prism2.languages.xml;
871
- Prism2.languages.rss = Prism2.languages.xml;
872
- }
873
- css.displayName = "css";
874
- css.aliases = [];
875
- function css(Prism2) {
876
- (function(Prism3) {
877
- var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
878
- Prism3.languages.css = {
879
- comment: /\/\*[\s\S]*?\*\//,
880
- atrule: {
881
- pattern: RegExp(
882
- "@[\\w-](?:" + /[^;{\s"']|\s+(?!\s)/.source + "|" + string.source + ")*?" + /(?:;|(?=\s*\{))/.source
883
- ),
884
- inside: {
885
- rule: /^@[\w-]+/,
886
- "selector-function-argument": {
887
- pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
888
- lookbehind: true,
889
- alias: "selector"
890
- },
891
- keyword: {
892
- pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
893
- lookbehind: true
894
- }
895
- // See rest below
896
- }
897
- },
898
- url: {
899
- // https://drafts.csswg.org/css-values-3/#urls
900
- pattern: RegExp(
901
- "\\burl\\((?:" + string.source + "|" + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ")\\)",
902
- "i"
903
- ),
904
- greedy: true,
905
- inside: {
906
- function: /^url/i,
907
- punctuation: /^\(|\)$/,
908
- string: {
909
- pattern: RegExp("^" + string.source + "$"),
910
- alias: "url"
911
- }
912
- }
913
- },
914
- selector: {
915
- pattern: RegExp(
916
- `(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|` + string.source + ")*(?=\\s*\\{)"
917
- ),
918
- lookbehind: true
919
- },
920
- string: {
921
- pattern: string,
922
- greedy: true
923
- },
924
- property: {
925
- pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
926
- lookbehind: true
927
- },
928
- important: /!important\b/i,
929
- function: {
930
- pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
931
- lookbehind: true
932
- },
933
- punctuation: /[(){};:,]/
934
- };
935
- Prism3.languages.css["atrule"].inside.rest = Prism3.languages.css;
936
- var markup2 = Prism3.languages.markup;
937
- if (markup2) {
938
- markup2.tag.addInlined("style", "css");
939
- markup2.tag.addAttribute("style", "css");
940
- }
941
- })(Prism2);
942
- }
943
- clike.displayName = "clike";
944
- clike.aliases = [];
945
- function clike(Prism2) {
946
- Prism2.languages.clike = {
947
- comment: [
948
- {
949
- pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
950
- lookbehind: true,
951
- greedy: true
952
- },
953
- {
954
- pattern: /(^|[^\\:])\/\/.*/,
955
- lookbehind: true,
956
- greedy: true
957
- }
958
- ],
959
- string: {
960
- pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
961
- greedy: true
962
- },
963
- "class-name": {
964
- pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
965
- lookbehind: true,
966
- inside: {
967
- punctuation: /[.\\]/
968
- }
969
- },
970
- keyword: /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
971
- boolean: /\b(?:false|true)\b/,
972
- function: /\b\w+(?=\()/,
973
- number: /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
974
- operator: /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
975
- punctuation: /[{}[\];(),.:]/
976
- };
977
- }
978
- javascript.displayName = "javascript";
979
- javascript.aliases = ["js"];
980
- function javascript(Prism2) {
981
- Prism2.register(clike);
982
- Prism2.languages.javascript = Prism2.languages.extend("clike", {
983
- "class-name": [
984
- Prism2.languages.clike["class-name"],
985
- {
986
- pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
987
- lookbehind: true
988
- }
989
- ],
990
- keyword: [
991
- {
992
- pattern: /((?:^|\})\s*)catch\b/,
993
- lookbehind: true
994
- },
995
- {
996
- 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/,
997
- lookbehind: true
998
- }
999
- ],
1000
- // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
1001
- function: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
1002
- number: {
1003
- pattern: RegExp(
1004
- /(^|[^\w$])/.source + "(?:" + // constant
1005
- (/NaN|Infinity/.source + "|" + // binary integer
1006
- /0[bB][01]+(?:_[01]+)*n?/.source + "|" + // octal integer
1007
- /0[oO][0-7]+(?:_[0-7]+)*n?/.source + "|" + // hexadecimal integer
1008
- /0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source + "|" + // decimal bigint
1009
- /\d+(?:_\d+)*n/.source + "|" + // decimal number (integer or float) but no bigint
1010
- /(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source) + ")" + /(?![\w$])/.source
1011
- ),
1012
- lookbehind: true
1013
- },
1014
- operator: /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
1015
- });
1016
- Prism2.languages.javascript["class-name"][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
1017
- Prism2.languages.insertBefore("javascript", "keyword", {
1018
- regex: {
1019
- pattern: RegExp(
1020
- // lookbehind
1021
- // eslint-disable-next-line regexp/no-dupe-characters-character-class
1022
- /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source + // Regex pattern:
1023
- // There are 2 regex patterns here. The RegExp set notation proposal added support for nested character
1024
- // classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible
1025
- // with the only syntax, so we have to define 2 different regex patterns.
1026
- /\//.source + "(?:" + /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source + "|" + // `v` flag syntax. This supports 3 levels of nested character classes.
1027
- /(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source + ")" + // lookahead
1028
- /(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
1029
- ),
1030
- lookbehind: true,
1031
- greedy: true,
1032
- inside: {
1033
- "regex-source": {
1034
- pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
1035
- lookbehind: true,
1036
- alias: "language-regex",
1037
- inside: Prism2.languages.regex
1038
- },
1039
- "regex-delimiter": /^\/|\/$/,
1040
- "regex-flags": /^[a-z]+$/
1041
- }
1042
- },
1043
- // This must be declared before keyword because we use "function" inside the look-forward
1044
- "function-variable": {
1045
- 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*=>))/,
1046
- alias: "function"
1047
- },
1048
- parameter: [
1049
- {
1050
- pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
1051
- lookbehind: true,
1052
- inside: Prism2.languages.javascript
1053
- },
1054
- {
1055
- pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
1056
- lookbehind: true,
1057
- inside: Prism2.languages.javascript
1058
- },
1059
- {
1060
- pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
1061
- lookbehind: true,
1062
- inside: Prism2.languages.javascript
1063
- },
1064
- {
1065
- 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*\{)/,
1066
- lookbehind: true,
1067
- inside: Prism2.languages.javascript
1068
- }
1069
- ],
1070
- constant: /\b[A-Z](?:[A-Z_]|\dx?)*\b/
1071
- });
1072
- Prism2.languages.insertBefore("javascript", "string", {
1073
- hashbang: {
1074
- pattern: /^#!.*/,
1075
- greedy: true,
1076
- alias: "comment"
1077
- },
1078
- "template-string": {
1079
- pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
1080
- greedy: true,
1081
- inside: {
1082
- "template-punctuation": {
1083
- pattern: /^`|`$/,
1084
- alias: "string"
1085
- },
1086
- interpolation: {
1087
- pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
1088
- lookbehind: true,
1089
- inside: {
1090
- "interpolation-punctuation": {
1091
- pattern: /^\$\{|\}$/,
1092
- alias: "punctuation"
1093
- },
1094
- rest: Prism2.languages.javascript
1095
- }
1096
- },
1097
- string: /[\s\S]+/
1098
- }
1099
- },
1100
- "string-property": {
1101
- pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
1102
- lookbehind: true,
1103
- greedy: true,
1104
- alias: "property"
1105
- }
1106
- });
1107
- Prism2.languages.insertBefore("javascript", "operator", {
1108
- "literal-property": {
1109
- pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
1110
- lookbehind: true,
1111
- alias: "property"
1112
- }
1113
- });
1114
- if (Prism2.languages.markup) {
1115
- Prism2.languages.markup.tag.addInlined("script", "javascript");
1116
- Prism2.languages.markup.tag.addAttribute(
1117
- /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,
1118
- "javascript"
1119
- );
1120
- }
1121
- Prism2.languages.js = Prism2.languages.javascript;
1122
- }
1123
- sql.displayName = "sql";
1124
- sql.aliases = [];
1125
- function sql(Prism2) {
1126
- Prism2.languages.sql = {
1127
- comment: {
1128
- pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,
1129
- lookbehind: true
1130
- },
1131
- variable: [
1132
- {
1133
- pattern: /@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,
1134
- greedy: true
1135
- },
1136
- /@[\w.$]+/
1137
- ],
1138
- string: {
1139
- pattern: /(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,
1140
- greedy: true,
1141
- lookbehind: true
1142
- },
1143
- identifier: {
1144
- pattern: /(^|[^@\\])`(?:\\[\s\S]|[^`\\]|``)*`/,
1145
- greedy: true,
1146
- lookbehind: true,
1147
- inside: {
1148
- punctuation: /^`|`$/
1149
- }
1150
- },
1151
- function: /\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i,
1152
- // Should we highlight user defined functions too?
1153
- keyword: /\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:COL|_INSERT)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:ING|S)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i,
1154
- boolean: /\b(?:FALSE|NULL|TRUE)\b/i,
1155
- number: /\b0x[\da-f]+\b|\b\d+(?:\.\d*)?|\B\.\d+\b/i,
1156
- operator: /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
1157
- punctuation: /[;[\]()`,.]/
1158
- };
1159
- }
1160
- bash.displayName = "bash";
1161
- bash.aliases = ["sh", "shell"];
1162
- function bash(Prism2) {
1163
- (function(Prism3) {
1164
- var envVars = "\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b";
1165
- var commandAfterHeredoc = {
1166
- pattern: /(^(["']?)\w+\2)[ \t]+\S.*/,
1167
- lookbehind: true,
1168
- alias: "punctuation",
1169
- // this looks reasonably well in all themes
1170
- inside: null
1171
- // see below
1172
- };
1173
- var insideString = {
1174
- bash: commandAfterHeredoc,
1175
- environment: {
1176
- pattern: RegExp("\\$" + envVars),
1177
- alias: "constant"
1178
- },
1179
- variable: [
1180
- // [0]: Arithmetic Environment
1181
- {
1182
- pattern: /\$?\(\([\s\S]+?\)\)/,
1183
- greedy: true,
1184
- inside: {
1185
- // If there is a $ sign at the beginning highlight $(( and )) as variable
1186
- variable: [
1187
- {
1188
- pattern: /(^\$\(\([\s\S]+)\)\)/,
1189
- lookbehind: true
1190
- },
1191
- /^\$\(\(/
1192
- ],
1193
- number: /\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,
1194
- // Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic
1195
- operator: /--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,
1196
- // If there is no $ sign at the beginning highlight (( and )) as punctuation
1197
- punctuation: /\(\(?|\)\)?|,|;/
1198
- }
1199
- },
1200
- // [1]: Command Substitution
1201
- {
1202
- pattern: /\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,
1203
- greedy: true,
1204
- inside: {
1205
- variable: /^\$\(|^`|\)$|`$/
1206
- }
1207
- },
1208
- // [2]: Brace expansion
1209
- {
1210
- pattern: /\$\{[^}]+\}/,
1211
- greedy: true,
1212
- inside: {
1213
- operator: /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,
1214
- punctuation: /[\[\]]/,
1215
- environment: {
1216
- pattern: RegExp("(\\{)" + envVars),
1217
- lookbehind: true,
1218
- alias: "constant"
1219
- }
1220
- }
1221
- },
1222
- /\$(?:\w+|[#?*!@$])/
1223
- ],
1224
- // Escape sequences from echo and printf's manuals, and escaped quotes.
1225
- entity: /\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/
1226
- };
1227
- Prism3.languages.bash = {
1228
- shebang: {
1229
- pattern: /^#!\s*\/.*/,
1230
- alias: "important"
1231
- },
1232
- comment: {
1233
- pattern: /(^|[^"{\\$])#.*/,
1234
- lookbehind: true
1235
- },
1236
- "function-name": [
1237
- // a) function foo {
1238
- // b) foo() {
1239
- // c) function foo() {
1240
- // but not “foo {”
1241
- {
1242
- // a) and c)
1243
- pattern: /(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,
1244
- lookbehind: true,
1245
- alias: "function"
1246
- },
1247
- {
1248
- // b)
1249
- pattern: /\b[\w-]+(?=\s*\(\s*\)\s*\{)/,
1250
- alias: "function"
1251
- }
1252
- ],
1253
- // Highlight variable names as variables in for and select beginnings.
1254
- "for-or-select": {
1255
- pattern: /(\b(?:for|select)\s+)\w+(?=\s+in\s)/,
1256
- alias: "variable",
1257
- lookbehind: true
1258
- },
1259
- // Highlight variable names as variables in the left-hand part
1260
- // of assignments (“=” and “+=”).
1261
- "assign-left": {
1262
- pattern: /(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,
1263
- inside: {
1264
- environment: {
1265
- pattern: RegExp("(^|[\\s;|&]|[<>]\\()" + envVars),
1266
- lookbehind: true,
1267
- alias: "constant"
1268
- }
1269
- },
1270
- alias: "variable",
1271
- lookbehind: true
1272
- },
1273
- // Highlight parameter names as variables
1274
- parameter: {
1275
- pattern: /(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,
1276
- alias: "variable",
1277
- lookbehind: true
1278
- },
1279
- string: [
1280
- // Support for Here-documents https://en.wikipedia.org/wiki/Here_document
1281
- {
1282
- pattern: /((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,
1283
- lookbehind: true,
1284
- greedy: true,
1285
- inside: insideString
1286
- },
1287
- // Here-document with quotes around the tag
1288
- // → No expansion (so no “inside”).
1289
- {
1290
- pattern: /((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,
1291
- lookbehind: true,
1292
- greedy: true,
1293
- inside: {
1294
- bash: commandAfterHeredoc
1295
- }
1296
- },
1297
- // “Normal” string
1298
- {
1299
- // https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html
1300
- pattern: /(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,
1301
- lookbehind: true,
1302
- greedy: true,
1303
- inside: insideString
1304
- },
1305
- {
1306
- // https://www.gnu.org/software/bash/manual/html_node/Single-Quotes.html
1307
- pattern: /(^|[^$\\])'[^']*'/,
1308
- lookbehind: true,
1309
- greedy: true
1310
- },
1311
- {
1312
- // https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html
1313
- pattern: /\$'(?:[^'\\]|\\[\s\S])*'/,
1314
- greedy: true,
1315
- inside: {
1316
- entity: insideString.entity
1317
- }
1318
- }
1319
- ],
1320
- environment: {
1321
- pattern: RegExp("\\$?" + envVars),
1322
- alias: "constant"
1323
- },
1324
- variable: insideString.variable,
1325
- function: {
1326
- pattern: /(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,
1327
- lookbehind: true
1328
- },
1329
- keyword: {
1330
- pattern: /(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,
1331
- lookbehind: true
1332
- },
1333
- // https://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html
1334
- builtin: {
1335
- pattern: /(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,
1336
- lookbehind: true,
1337
- // Alias added to make those easier to distinguish from strings.
1338
- alias: "class-name"
1339
- },
1340
- boolean: {
1341
- pattern: /(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,
1342
- lookbehind: true
1343
- },
1344
- "file-descriptor": {
1345
- pattern: /\B&\d\b/,
1346
- alias: "important"
1347
- },
1348
- operator: {
1349
- // Lots of redirections here, but not just that.
1350
- pattern: /\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,
1351
- inside: {
1352
- "file-descriptor": {
1353
- pattern: /^\d/,
1354
- alias: "important"
1355
- }
1356
- }
1357
- },
1358
- punctuation: /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,
1359
- number: {
1360
- pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,
1361
- lookbehind: true
1362
- }
1363
- };
1364
- commandAfterHeredoc.inside = Prism3.languages.bash;
1365
- var toBeCopied = [
1366
- "comment",
1367
- "function-name",
1368
- "for-or-select",
1369
- "assign-left",
1370
- "parameter",
1371
- "string",
1372
- "environment",
1373
- "function",
1374
- "keyword",
1375
- "builtin",
1376
- "boolean",
1377
- "file-descriptor",
1378
- "operator",
1379
- "punctuation",
1380
- "number"
1381
- ];
1382
- var inside = insideString.variable[1].inside;
1383
- for (var i = 0; i < toBeCopied.length; i++) {
1384
- inside[toBeCopied[i]] = Prism3.languages.bash[toBeCopied[i]];
1385
- }
1386
- Prism3.languages.sh = Prism3.languages.bash;
1387
- Prism3.languages.shell = Prism3.languages.bash;
1388
- })(Prism2);
1389
- }
1390
- yaml.displayName = "yaml";
1391
- yaml.aliases = ["yml"];
1392
- function yaml(Prism2) {
1393
- (function(Prism3) {
1394
- var anchorOrAlias = /[*&][^\s[\]{},]+/;
1395
- var tag = /!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/;
1396
- var properties = "(?:" + tag.source + "(?:[ ]+" + anchorOrAlias.source + ")?|" + anchorOrAlias.source + "(?:[ ]+" + tag.source + ")?)";
1397
- var plainKey = /(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-]<PLAIN>)(?:[ \t]*(?:(?![#:])<PLAIN>|:<PLAIN>))*/.source.replace(
1398
- /<PLAIN>/g,
1399
- function() {
1400
- return /[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source;
1401
- }
1402
- );
1403
- var string = /"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;
1404
- function createValuePattern(value, flags) {
1405
- flags = (flags || "").replace(/m/g, "") + "m";
1406
- var pattern = /([:\-,[{]\s*(?:\s<<prop>>[ \t]+)?)(?:<<value>>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<<prop>>/g, function() {
1407
- return properties;
1408
- }).replace(/<<value>>/g, function() {
1409
- return value;
1410
- });
1411
- return RegExp(pattern, flags);
1412
- }
1413
- Prism3.languages.yaml = {
1414
- scalar: {
1415
- pattern: RegExp(
1416
- /([\-:]\s*(?:\s<<prop>>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(
1417
- /<<prop>>/g,
1418
- function() {
1419
- return properties;
1420
- }
1421
- )
1422
- ),
1423
- lookbehind: true,
1424
- alias: "string"
1425
- },
1426
- comment: /#.*/,
1427
- key: {
1428
- pattern: RegExp(
1429
- /((?:^|[:\-,[{\r\n?])[ \t]*(?:<<prop>>[ \t]+)?)<<key>>(?=\s*:\s)/.source.replace(/<<prop>>/g, function() {
1430
- return properties;
1431
- }).replace(/<<key>>/g, function() {
1432
- return "(?:" + plainKey + "|" + string + ")";
1433
- })
1434
- ),
1435
- lookbehind: true,
1436
- greedy: true,
1437
- alias: "atrule"
1438
- },
1439
- directive: {
1440
- pattern: /(^[ \t]*)%.+/m,
1441
- lookbehind: true,
1442
- alias: "important"
1443
- },
1444
- datetime: {
1445
- pattern: createValuePattern(
1446
- /\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source
1447
- ),
1448
- lookbehind: true,
1449
- alias: "number"
1450
- },
1451
- boolean: {
1452
- pattern: createValuePattern(/false|true/.source, "i"),
1453
- lookbehind: true,
1454
- alias: "important"
1455
- },
1456
- null: {
1457
- pattern: createValuePattern(/null|~/.source, "i"),
1458
- lookbehind: true,
1459
- alias: "important"
1460
- },
1461
- string: {
1462
- pattern: createValuePattern(string),
1463
- lookbehind: true,
1464
- greedy: true
1465
- },
1466
- number: {
1467
- pattern: createValuePattern(
1468
- /[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,
1469
- "i"
1470
- ),
1471
- lookbehind: true
1472
- },
1473
- tag,
1474
- important: anchorOrAlias,
1475
- punctuation: /---|[:[\]{}\-,|>?]|\.\.\./
1476
- };
1477
- Prism3.languages.yml = Prism3.languages.yaml;
1478
- })(Prism2);
1479
- }
1480
- markdown.displayName = "markdown";
1481
- markdown.aliases = ["md"];
1482
- function markdown(Prism2) {
1483
- Prism2.register(markup);
1484
- (function(Prism3) {
1485
- var inner = /(?:\\.|[^\\\n\r]|(?:\n|\r\n?)(?![\r\n]))/.source;
1486
- function createInline(pattern) {
1487
- pattern = pattern.replace(/<inner>/g, function() {
1488
- return inner;
1489
- });
1490
- return RegExp(/((?:^|[^\\])(?:\\{2})*)/.source + "(?:" + pattern + ")");
1491
- }
1492
- var tableCell = /(?:\\.|``(?:[^`\r\n]|`(?!`))+``|`[^`\r\n]+`|[^\\|\r\n`])+/.source;
1493
- var tableRow = /\|?__(?:\|__)+\|?(?:(?:\n|\r\n?)|(?![\s\S]))/.source.replace(
1494
- /__/g,
1495
- function() {
1496
- return tableCell;
1497
- }
1498
- );
1499
- var tableLine = /\|?[ \t]*:?-{3,}:?[ \t]*(?:\|[ \t]*:?-{3,}:?[ \t]*)+\|?(?:\n|\r\n?)/.source;
1500
- Prism3.languages.markdown = Prism3.languages.extend("markup", {});
1501
- Prism3.languages.insertBefore("markdown", "prolog", {
1502
- "front-matter-block": {
1503
- pattern: /(^(?:\s*[\r\n])?)---(?!.)[\s\S]*?[\r\n]---(?!.)/,
1504
- lookbehind: true,
1505
- greedy: true,
1506
- inside: {
1507
- punctuation: /^---|---$/,
1508
- "front-matter": {
1509
- pattern: /\S+(?:\s+\S+)*/,
1510
- alias: ["yaml", "language-yaml"],
1511
- inside: Prism3.languages.yaml
1512
- }
1513
- }
1514
- },
1515
- blockquote: {
1516
- // > ...
1517
- pattern: /^>(?:[\t ]*>)*/m,
1518
- alias: "punctuation"
1519
- },
1520
- table: {
1521
- pattern: RegExp(
1522
- "^" + tableRow + tableLine + "(?:" + tableRow + ")*",
1523
- "m"
1524
- ),
1525
- inside: {
1526
- "table-data-rows": {
1527
- pattern: RegExp(
1528
- "^(" + tableRow + tableLine + ")(?:" + tableRow + ")*$"
1529
- ),
1530
- lookbehind: true,
1531
- inside: {
1532
- "table-data": {
1533
- pattern: RegExp(tableCell),
1534
- inside: Prism3.languages.markdown
1535
- },
1536
- punctuation: /\|/
1537
- }
1538
- },
1539
- "table-line": {
1540
- pattern: RegExp("^(" + tableRow + ")" + tableLine + "$"),
1541
- lookbehind: true,
1542
- inside: {
1543
- punctuation: /\||:?-{3,}:?/
1544
- }
1545
- },
1546
- "table-header-row": {
1547
- pattern: RegExp("^" + tableRow + "$"),
1548
- inside: {
1549
- "table-header": {
1550
- pattern: RegExp(tableCell),
1551
- alias: "important",
1552
- inside: Prism3.languages.markdown
1553
- },
1554
- punctuation: /\|/
1555
- }
1556
- }
1557
- }
1558
- },
1559
- code: [
1560
- {
1561
- // Prefixed by 4 spaces or 1 tab and preceded by an empty line
1562
- pattern: /((?:^|\n)[ \t]*\n|(?:^|\r\n?)[ \t]*\r\n?)(?: {4}|\t).+(?:(?:\n|\r\n?)(?: {4}|\t).+)*/,
1563
- lookbehind: true,
1564
- alias: "keyword"
1565
- },
1566
- {
1567
- // ```optional language
1568
- // code block
1569
- // ```
1570
- pattern: /^```[\s\S]*?^```$/m,
1571
- greedy: true,
1572
- inside: {
1573
- "code-block": {
1574
- pattern: /^(```.*(?:\n|\r\n?))[\s\S]+?(?=(?:\n|\r\n?)^```$)/m,
1575
- lookbehind: true
1576
- },
1577
- "code-language": {
1578
- pattern: /^(```).+/,
1579
- lookbehind: true
1580
- },
1581
- punctuation: /```/
1582
- }
1583
- }
1584
- ],
1585
- title: [
1586
- {
1587
- // title 1
1588
- // =======
1589
- // title 2
1590
- // -------
1591
- pattern: /\S.*(?:\n|\r\n?)(?:==+|--+)(?=[ \t]*$)/m,
1592
- alias: "important",
1593
- inside: {
1594
- punctuation: /==+$|--+$/
1595
- }
1596
- },
1597
- {
1598
- // # title 1
1599
- // ###### title 6
1600
- pattern: /(^\s*)#.+/m,
1601
- lookbehind: true,
1602
- alias: "important",
1603
- inside: {
1604
- punctuation: /^#+|#+$/
1605
- }
1606
- }
1607
- ],
1608
- hr: {
1609
- // ***
1610
- // ---
1611
- // * * *
1612
- // -----------
1613
- pattern: /(^\s*)([*-])(?:[\t ]*\2){2,}(?=\s*$)/m,
1614
- lookbehind: true,
1615
- alias: "punctuation"
1616
- },
1617
- list: {
1618
- // * item
1619
- // + item
1620
- // - item
1621
- // 1. item
1622
- pattern: /(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m,
1623
- lookbehind: true,
1624
- alias: "punctuation"
1625
- },
1626
- "url-reference": {
1627
- // [id]: http://example.com "Optional title"
1628
- // [id]: http://example.com 'Optional title'
1629
- // [id]: http://example.com (Optional title)
1630
- // [id]: <http://example.com> "Optional title"
1631
- pattern: /!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/,
1632
- inside: {
1633
- variable: {
1634
- pattern: /^(!?\[)[^\]]+/,
1635
- lookbehind: true
1636
- },
1637
- string: /(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/,
1638
- punctuation: /^[\[\]!:]|[<>]/
1639
- },
1640
- alias: "url"
1641
- },
1642
- bold: {
1643
- // **strong**
1644
- // __strong__
1645
- // allow one nested instance of italic text using the same delimiter
1646
- pattern: createInline(
1647
- /\b__(?:(?!_)<inner>|_(?:(?!_)<inner>)+_)+__\b|\*\*(?:(?!\*)<inner>|\*(?:(?!\*)<inner>)+\*)+\*\*/.source
1648
- ),
1649
- lookbehind: true,
1650
- greedy: true,
1651
- inside: {
1652
- content: {
1653
- pattern: /(^..)[\s\S]+(?=..$)/,
1654
- lookbehind: true,
1655
- inside: {}
1656
- // see below
1657
- },
1658
- punctuation: /\*\*|__/
1659
- }
1660
- },
1661
- italic: {
1662
- // *em*
1663
- // _em_
1664
- // allow one nested instance of bold text using the same delimiter
1665
- pattern: createInline(
1666
- /\b_(?:(?!_)<inner>|__(?:(?!_)<inner>)+__)+_\b|\*(?:(?!\*)<inner>|\*\*(?:(?!\*)<inner>)+\*\*)+\*/.source
1667
- ),
1668
- lookbehind: true,
1669
- greedy: true,
1670
- inside: {
1671
- content: {
1672
- pattern: /(^.)[\s\S]+(?=.$)/,
1673
- lookbehind: true,
1674
- inside: {}
1675
- // see below
1676
- },
1677
- punctuation: /[*_]/
1678
- }
1679
- },
1680
- strike: {
1681
- // ~~strike through~~
1682
- // ~strike~
1683
- // eslint-disable-next-line regexp/strict
1684
- pattern: createInline(/(~~?)(?:(?!~)<inner>)+\2/.source),
1685
- lookbehind: true,
1686
- greedy: true,
1687
- inside: {
1688
- content: {
1689
- pattern: /(^~~?)[\s\S]+(?=\1$)/,
1690
- lookbehind: true,
1691
- inside: {}
1692
- // see below
1693
- },
1694
- punctuation: /~~?/
1695
- }
1696
- },
1697
- "code-snippet": {
1698
- // `code`
1699
- // ``code``
1700
- pattern: /(^|[^\\`])(?:``[^`\r\n]+(?:`[^`\r\n]+)*``(?!`)|`[^`\r\n]+`(?!`))/,
1701
- lookbehind: true,
1702
- greedy: true,
1703
- alias: ["code", "keyword"]
1704
- },
1705
- url: {
1706
- // [example](http://example.com "Optional title")
1707
- // [example][id]
1708
- // [example] [id]
1709
- pattern: createInline(
1710
- /!?\[(?:(?!\])<inner>)+\](?:\([^\s)]+(?:[\t ]+"(?:\\.|[^"\\])*")?\)|[ \t]?\[(?:(?!\])<inner>)+\])/.source
1711
- ),
1712
- lookbehind: true,
1713
- greedy: true,
1714
- inside: {
1715
- operator: /^!/,
1716
- content: {
1717
- pattern: /(^\[)[^\]]+(?=\])/,
1718
- lookbehind: true,
1719
- inside: {}
1720
- // see below
1721
- },
1722
- variable: {
1723
- pattern: /(^\][ \t]?\[)[^\]]+(?=\]$)/,
1724
- lookbehind: true
1725
- },
1726
- url: {
1727
- pattern: /(^\]\()[^\s)]+/,
1728
- lookbehind: true
1729
- },
1730
- string: {
1731
- pattern: /(^[ \t]+)"(?:\\.|[^"\\])*"(?=\)$)/,
1732
- lookbehind: true
1733
- }
1734
- }
1735
- }
1736
- });
1737
- ["url", "bold", "italic", "strike"].forEach(function(token) {
1738
- ["url", "bold", "italic", "strike", "code-snippet"].forEach(
1739
- function(inside) {
1740
- if (token !== inside) {
1741
- Prism3.languages.markdown[token].inside.content.inside[inside] = Prism3.languages.markdown[inside];
1742
- }
1743
- }
1744
- );
1745
- });
1746
- Prism3.hooks.add("after-tokenize", function(env) {
1747
- if (env.language !== "markdown" && env.language !== "md") {
1748
- return;
1749
- }
1750
- function walkTokens(tokens) {
1751
- if (!tokens || typeof tokens === "string") {
1752
- return;
1753
- }
1754
- for (var i = 0, l = tokens.length; i < l; i++) {
1755
- var token = tokens[i];
1756
- if (token.type !== "code") {
1757
- walkTokens(token.content);
1758
- continue;
1759
- }
1760
- var codeLang = token.content[1];
1761
- var codeBlock = token.content[3];
1762
- if (codeLang && codeBlock && codeLang.type === "code-language" && codeBlock.type === "code-block" && typeof codeLang.content === "string") {
1763
- var lang = codeLang.content.replace(/\b#/g, "sharp").replace(/\b\+\+/g, "pp");
1764
- lang = (/[a-z][\w-]*/i.exec(lang) || [""])[0].toLowerCase();
1765
- var alias2 = "language-" + lang;
1766
- if (!codeBlock.alias) {
1767
- codeBlock.alias = [alias2];
1768
- } else if (typeof codeBlock.alias === "string") {
1769
- codeBlock.alias = [codeBlock.alias, alias2];
1770
- } else {
1771
- codeBlock.alias.push(alias2);
1772
- }
1773
- }
1774
- }
1775
- }
1776
- walkTokens(env.tokens);
1777
- });
1778
- Prism3.hooks.add("wrap", function(env) {
1779
- if (env.type !== "code-block") {
1780
- return;
1781
- }
1782
- var codeLang = "";
1783
- for (var i = 0, l = env.classes.length; i < l; i++) {
1784
- var cls = env.classes[i];
1785
- var match = /language-(.+)/.exec(cls);
1786
- if (match) {
1787
- codeLang = match[1];
1788
- break;
1789
- }
1790
- }
1791
- var grammar = Prism3.languages[codeLang];
1792
- if (!grammar) {
1793
- if (codeLang && codeLang !== "none" && Prism3.plugins.autoloader) {
1794
- var id = "md-" + (/* @__PURE__ */ new Date()).valueOf() + "-" + Math.floor(Math.random() * 1e16);
1795
- env.attributes["id"] = id;
1796
- Prism3.plugins.autoloader.loadLanguages(codeLang, function() {
1797
- var ele = document.getElementById(id);
1798
- if (ele) {
1799
- ele.innerHTML = Prism3.highlight(
1800
- ele.textContent,
1801
- Prism3.languages[codeLang],
1802
- codeLang
1803
- );
1804
- }
1805
- });
1806
- }
1807
- } else {
1808
- env.content = Prism3.highlight(env.content.value, grammar, codeLang);
1809
- }
1810
- });
1811
- RegExp(Prism3.languages.markup.tag.pattern.source, "gi");
1812
- Prism3.languages.md = Prism3.languages.markdown;
1813
- })(Prism2);
1814
- }
1815
- go.displayName = "go";
1816
- go.aliases = [];
1817
- function go(Prism2) {
1818
- Prism2.register(clike);
1819
- Prism2.languages.go = Prism2.languages.extend("clike", {
1820
- string: {
1821
- pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,
1822
- lookbehind: true,
1823
- greedy: true
1824
- },
1825
- keyword: /\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,
1826
- boolean: /\b(?:_|false|iota|nil|true)\b/,
1827
- number: [
1828
- // binary and octal integers
1829
- /\b0(?:b[01_]+|o[0-7_]+)i?\b/i,
1830
- // hexadecimal integers and floats
1831
- /\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,
1832
- // decimal integers and floats
1833
- /(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i
1834
- ],
1835
- operator: /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
1836
- builtin: /\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/
1837
- });
1838
- Prism2.languages.insertBefore("go", "string", {
1839
- char: {
1840
- pattern: /'(?:\\.|[^'\\\r\n]){0,10}'/,
1841
- greedy: true
1842
- }
1843
- });
1844
- delete Prism2.languages.go["class-name"];
1845
- }
1846
- json.displayName = "json";
1847
- json.aliases = ["webmanifest"];
1848
- function json(Prism2) {
1849
- Prism2.languages.json = {
1850
- property: {
1851
- pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,
1852
- lookbehind: true,
1853
- greedy: true
1854
- },
1855
- string: {
1856
- pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,
1857
- lookbehind: true,
1858
- greedy: true
1859
- },
1860
- comment: {
1861
- pattern: /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,
1862
- greedy: true
1863
- },
1864
- number: /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,
1865
- punctuation: /[{}[\],]/,
1866
- operator: /:/,
1867
- boolean: /\b(?:false|true)\b/,
1868
- null: {
1869
- pattern: /\bnull\b/,
1870
- alias: "keyword"
1871
- }
1872
- };
1873
- Prism2.languages.webmanifest = Prism2.languages.json;
1874
- }
1875
- java.displayName = "java";
1876
- java.aliases = [];
1877
- function java(Prism2) {
1878
- Prism2.register(clike);
1879
- (function(Prism3) {
1880
- 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/;
1881
- var classNamePrefix = /(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source;
1882
- var className = {
1883
- pattern: RegExp(
1884
- /(^|[^\w.])/.source + classNamePrefix + /[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source
1885
- ),
1886
- lookbehind: true,
1887
- inside: {
1888
- namespace: {
1889
- pattern: /^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,
1890
- inside: {
1891
- punctuation: /\./
1892
- }
1893
- },
1894
- punctuation: /\./
1895
- }
1896
- };
1897
- Prism3.languages.java = Prism3.languages.extend("clike", {
1898
- string: {
1899
- pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,
1900
- lookbehind: true,
1901
- greedy: true
1902
- },
1903
- "class-name": [
1904
- className,
1905
- {
1906
- // variables, parameters, and constructor references
1907
- // this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
1908
- pattern: RegExp(
1909
- /(^|[^\w.])/.source + classNamePrefix + /[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source
1910
- ),
1911
- lookbehind: true,
1912
- inside: className.inside
1913
- },
1914
- {
1915
- // class names based on keyword
1916
- // this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
1917
- pattern: RegExp(
1918
- /(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source + classNamePrefix + /[A-Z]\w*\b/.source
1919
- ),
1920
- lookbehind: true,
1921
- inside: className.inside
1922
- }
1923
- ],
1924
- keyword: keywords,
1925
- function: [
1926
- Prism3.languages.clike.function,
1927
- {
1928
- pattern: /(::\s*)[a-z_]\w*/,
1929
- lookbehind: true
1930
- }
1931
- ],
1932
- 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,
1933
- operator: {
1934
- pattern: /(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,
1935
- lookbehind: true
1936
- },
1937
- constant: /\b[A-Z][A-Z_\d]+\b/
1938
- });
1939
- Prism3.languages.insertBefore("java", "string", {
1940
- "triple-quoted-string": {
1941
- // http://openjdk.java.net/jeps/355#Description
1942
- pattern: /"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,
1943
- greedy: true,
1944
- alias: "string"
1945
- },
1946
- char: {
1947
- pattern: /'(?:\\.|[^'\\\r\n]){1,6}'/,
1948
- greedy: true
1949
- }
1950
- });
1951
- Prism3.languages.insertBefore("java", "class-name", {
1952
- annotation: {
1953
- pattern: /(^|[^.])@\w+(?:\s*\.\s*\w+)*/,
1954
- lookbehind: true,
1955
- alias: "punctuation"
1956
- },
1957
- generics: {
1958
- pattern: /<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,
1959
- inside: {
1960
- "class-name": className,
1961
- keyword: keywords,
1962
- punctuation: /[<>(),.:]/,
1963
- operator: /[?&|]/
1964
- }
1965
- },
1966
- import: [
1967
- {
1968
- pattern: RegExp(
1969
- /(\bimport\s+)/.source + classNamePrefix + /(?:[A-Z]\w*|\*)(?=\s*;)/.source
1970
- ),
1971
- lookbehind: true,
1972
- inside: {
1973
- namespace: className.inside.namespace,
1974
- punctuation: /\./,
1975
- operator: /\*/,
1976
- "class-name": /\w+/
1977
- }
1978
- },
1979
- {
1980
- pattern: RegExp(
1981
- /(\bimport\s+static\s+)/.source + classNamePrefix + /(?:\w+|\*)(?=\s*;)/.source
1982
- ),
1983
- lookbehind: true,
1984
- alias: "static",
1985
- inside: {
1986
- namespace: className.inside.namespace,
1987
- static: /\b\w+$/,
1988
- punctuation: /\./,
1989
- operator: /\*/,
1990
- "class-name": /\w+/
1991
- }
1992
- }
1993
- ],
1994
- namespace: {
1995
- pattern: RegExp(
1996
- /(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!<keyword>)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(
1997
- /<keyword>/g,
1998
- function() {
1999
- return keywords.source;
2000
- }
2001
- )
2002
- ),
2003
- lookbehind: true,
2004
- inside: {
2005
- punctuation: /\./
2006
- }
2007
- }
2008
- });
2009
- })(Prism2);
2010
- }
2011
- typescript.displayName = "typescript";
2012
- typescript.aliases = ["ts"];
2013
- function typescript(Prism2) {
2014
- Prism2.register(javascript);
2015
- (function(Prism3) {
2016
- Prism3.languages.typescript = Prism3.languages.extend("javascript", {
2017
- "class-name": {
2018
- pattern: /(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,
2019
- lookbehind: true,
2020
- greedy: true,
2021
- inside: null
2022
- // see below
2023
- },
2024
- builtin: /\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/
2025
- });
2026
- Prism3.languages.typescript.keyword.push(
2027
- /\b(?:abstract|declare|is|keyof|readonly|require)\b/,
2028
- // keywords that have to be followed by an identifier
2029
- /\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,
2030
- // This is for `import type *, {}`
2031
- /\btype\b(?=\s*(?:[\{*]|$))/
2032
- );
2033
- delete Prism3.languages.typescript["parameter"];
2034
- delete Prism3.languages.typescript["literal-property"];
2035
- var typeInside = Prism3.languages.extend("typescript", {});
2036
- delete typeInside["class-name"];
2037
- Prism3.languages.typescript["class-name"].inside = typeInside;
2038
- Prism3.languages.insertBefore("typescript", "function", {
2039
- decorator: {
2040
- pattern: /@[$\w\xA0-\uFFFF]+/,
2041
- inside: {
2042
- at: {
2043
- pattern: /^@/,
2044
- alias: "operator"
2045
- },
2046
- function: /^[\s\S]+/
2047
- }
2048
- },
2049
- "generic-function": {
2050
- // e.g. foo<T extends "bar" | "baz">( ...
2051
- pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,
2052
- greedy: true,
2053
- inside: {
2054
- function: /^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,
2055
- generic: {
2056
- pattern: /<[\s\S]+/,
2057
- // everything after the first <
2058
- alias: "class-name",
2059
- inside: typeInside
2060
- }
2061
- }
2062
- }
2063
- });
2064
- Prism3.languages.ts = Prism3.languages.typescript;
2065
- })(Prism2);
2066
- }
2067
- python.displayName = "python";
2068
- python.aliases = ["py"];
2069
- function python(Prism2) {
2070
- Prism2.languages.python = {
2071
- comment: {
2072
- pattern: /(^|[^\\])#.*/,
2073
- lookbehind: true,
2074
- greedy: true
2075
- },
2076
- "string-interpolation": {
2077
- pattern: /(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
2078
- greedy: true,
2079
- inside: {
2080
- interpolation: {
2081
- // "{" <expression> <optional "!s", "!r", or "!a"> <optional ":" format specifier> "}"
2082
- pattern: /((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,
2083
- lookbehind: true,
2084
- inside: {
2085
- "format-spec": {
2086
- pattern: /(:)[^:(){}]+(?=\}$)/,
2087
- lookbehind: true
2088
- },
2089
- "conversion-option": {
2090
- pattern: /![sra](?=[:}]$)/,
2091
- alias: "punctuation"
2092
- },
2093
- rest: null
2094
- }
2095
- },
2096
- string: /[\s\S]+/
2097
- }
2098
- },
2099
- "triple-quoted-string": {
2100
- pattern: /(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,
2101
- greedy: true,
2102
- alias: "string"
2103
- },
2104
- string: {
2105
- pattern: /(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,
2106
- greedy: true
2107
- },
2108
- function: {
2109
- pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,
2110
- lookbehind: true
2111
- },
2112
- "class-name": {
2113
- pattern: /(\bclass\s+)\w+/i,
2114
- lookbehind: true
2115
- },
2116
- decorator: {
2117
- pattern: /(^[\t ]*)@\w+(?:\.\w+)*/m,
2118
- lookbehind: true,
2119
- alias: ["annotation", "punctuation"],
2120
- inside: {
2121
- punctuation: /\./
2122
- }
2123
- },
2124
- 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/,
2125
- 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/,
2126
- boolean: /\b(?:False|None|True)\b/,
2127
- 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,
2128
- operator: /[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
2129
- punctuation: /[{}[\];(),.:]/
2130
- };
2131
- Prism2.languages.python["string-interpolation"].inside["interpolation"].inside.rest = Prism2.languages.python;
2132
- Prism2.languages.py = Prism2.languages.python;
2133
- }
2134
- jsx.displayName = "jsx";
2135
- jsx.aliases = [];
2136
- function jsx(Prism2) {
2137
- Prism2.register(javascript);
2138
- Prism2.register(markup);
2139
- (function(Prism3) {
2140
- var javascript2 = Prism3.util.clone(Prism3.languages.javascript);
2141
- var space = /(?:\s|\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))\*\/)/.source;
2142
- var braces = /(?:\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])*\})/.source;
2143
- var spread = /(?:\{<S>*\.{3}(?:[^{}]|<BRACES>)*\})/.source;
2144
- function re(source, flags) {
2145
- source = source.replace(/<S>/g, function() {
2146
- return space;
2147
- }).replace(/<BRACES>/g, function() {
2148
- return braces;
2149
- }).replace(/<SPREAD>/g, function() {
2150
- return spread;
2151
- });
2152
- return RegExp(source, flags);
2153
- }
2154
- spread = re(spread).source;
2155
- Prism3.languages.jsx = Prism3.languages.extend("markup", javascript2);
2156
- Prism3.languages.jsx.tag.pattern = re(
2157
- /<\/?(?:[\w.:-]+(?:<S>+(?:[\w.:$-]+(?:=(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s{'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*\/?)?>/.source
2158
- );
2159
- Prism3.languages.jsx.tag.inside["tag"].pattern = /^<\/?[^\s>\/]*/;
2160
- Prism3.languages.jsx.tag.inside["attr-value"].pattern = /=(?!\{)(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s'">]+)/;
2161
- Prism3.languages.jsx.tag.inside["tag"].inside["class-name"] = /^[A-Z]\w*(?:\.[A-Z]\w*)*$/;
2162
- Prism3.languages.jsx.tag.inside["comment"] = javascript2["comment"];
2163
- Prism3.languages.insertBefore(
2164
- "inside",
2165
- "attr-name",
2166
- {
2167
- spread: {
2168
- pattern: re(/<SPREAD>/.source),
2169
- inside: Prism3.languages.jsx
2170
- }
2171
- },
2172
- Prism3.languages.jsx.tag
2173
- );
2174
- Prism3.languages.insertBefore(
2175
- "inside",
2176
- "special-attr",
2177
- {
2178
- script: {
2179
- // Allow for two levels of nesting
2180
- pattern: re(/=<BRACES>/.source),
2181
- alias: "language-javascript",
2182
- inside: {
2183
- "script-punctuation": {
2184
- pattern: /^=(?=\{)/,
2185
- alias: "punctuation"
2186
- },
2187
- rest: Prism3.languages.jsx
2188
- }
2189
- }
2190
- },
2191
- Prism3.languages.jsx.tag
2192
- );
2193
- var stringifyToken = function(token) {
2194
- if (!token) {
2195
- return "";
2196
- }
2197
- if (typeof token === "string") {
2198
- return token;
2199
- }
2200
- if (typeof token.content === "string") {
2201
- return token.content;
2202
- }
2203
- return token.content.map(stringifyToken).join("");
2204
- };
2205
- var walkTokens = function(tokens) {
2206
- var openedTags = [];
2207
- for (var i = 0; i < tokens.length; i++) {
2208
- var token = tokens[i];
2209
- var notTagNorBrace = false;
2210
- if (typeof token !== "string") {
2211
- if (token.type === "tag" && token.content[0] && token.content[0].type === "tag") {
2212
- if (token.content[0].content[0].content === "</") {
2213
- if (openedTags.length > 0 && openedTags[openedTags.length - 1].tagName === stringifyToken(token.content[0].content[1])) {
2214
- openedTags.pop();
2215
- }
2216
- } else {
2217
- if (token.content[token.content.length - 1].content === "/>") ;
2218
- else {
2219
- openedTags.push({
2220
- tagName: stringifyToken(token.content[0].content[1]),
2221
- openedBraces: 0
2222
- });
2223
- }
2224
- }
2225
- } else if (openedTags.length > 0 && token.type === "punctuation" && token.content === "{") {
2226
- openedTags[openedTags.length - 1].openedBraces++;
2227
- } else if (openedTags.length > 0 && openedTags[openedTags.length - 1].openedBraces > 0 && token.type === "punctuation" && token.content === "}") {
2228
- openedTags[openedTags.length - 1].openedBraces--;
2229
- } else {
2230
- notTagNorBrace = true;
2231
- }
2232
- }
2233
- if (notTagNorBrace || typeof token === "string") {
2234
- if (openedTags.length > 0 && openedTags[openedTags.length - 1].openedBraces === 0) {
2235
- var plainText = stringifyToken(token);
2236
- if (i < tokens.length - 1 && (typeof tokens[i + 1] === "string" || tokens[i + 1].type === "plain-text")) {
2237
- plainText += stringifyToken(tokens[i + 1]);
2238
- tokens.splice(i + 1, 1);
2239
- }
2240
- if (i > 0 && (typeof tokens[i - 1] === "string" || tokens[i - 1].type === "plain-text")) {
2241
- plainText = stringifyToken(tokens[i - 1]) + plainText;
2242
- tokens.splice(i - 1, 1);
2243
- i--;
2244
- }
2245
- tokens[i] = new Prism3.Token(
2246
- "plain-text",
2247
- plainText,
2248
- null,
2249
- plainText
2250
- );
2251
- }
2252
- }
2253
- if (token.content && typeof token.content !== "string") {
2254
- walkTokens(token.content);
2255
- }
2256
- }
2257
- };
2258
- Prism3.hooks.add("after-tokenize", function(env) {
2259
- if (env.language !== "jsx" && env.language !== "tsx") {
2260
- return;
2261
- }
2262
- walkTokens(env.tokens);
2263
- });
2264
- })(Prism2);
2265
- }
2266
- tsx.displayName = "tsx";
2267
- tsx.aliases = [];
2268
- function tsx(Prism2) {
2269
- Prism2.register(jsx);
2270
- Prism2.register(typescript);
2271
- (function(Prism3) {
2272
- var typescript2 = Prism3.util.clone(Prism3.languages.typescript);
2273
- Prism3.languages.tsx = Prism3.languages.extend("jsx", typescript2);
2274
- delete Prism3.languages.tsx["parameter"];
2275
- delete Prism3.languages.tsx["literal-property"];
2276
- var tag = Prism3.languages.tsx.tag;
2277
- tag.pattern = RegExp(
2278
- /(^|[^\w$]|(?=<\/))/.source + "(?:" + tag.pattern.source + ")",
2279
- tag.pattern.flags
2280
- );
2281
- tag.lookbehind = true;
2282
- })(Prism2);
2283
- }
2284
- rust.displayName = "rust";
2285
- rust.aliases = [];
2286
- function rust(Prism2) {
2287
- (function(Prism3) {
2288
- var multilineComment = /\/\*(?:[^*/]|\*(?!\/)|\/(?!\*)|<self>)*\*\//.source;
2289
- for (var i = 0; i < 2; i++) {
2290
- multilineComment = multilineComment.replace(/<self>/g, function() {
2291
- return multilineComment;
2292
- });
2293
- }
2294
- multilineComment = multilineComment.replace(/<self>/g, function() {
2295
- return /[^\s\S]/.source;
2296
- });
2297
- Prism3.languages.rust = {
2298
- comment: [
2299
- {
2300
- pattern: RegExp(/(^|[^\\])/.source + multilineComment),
2301
- lookbehind: true,
2302
- greedy: true
2303
- },
2304
- {
2305
- pattern: /(^|[^\\:])\/\/.*/,
2306
- lookbehind: true,
2307
- greedy: true
2308
- }
2309
- ],
2310
- string: {
2311
- pattern: /b?"(?:\\[\s\S]|[^\\"])*"|b?r(#*)"(?:[^"]|"(?!\1))*"\1/,
2312
- greedy: true
2313
- },
2314
- char: {
2315
- pattern: /b?'(?:\\(?:x[0-7][\da-fA-F]|u\{(?:[\da-fA-F]_*){1,6}\}|.)|[^\\\r\n\t'])'/,
2316
- greedy: true
2317
- },
2318
- attribute: {
2319
- pattern: /#!?\[(?:[^\[\]"]|"(?:\\[\s\S]|[^\\"])*")*\]/,
2320
- greedy: true,
2321
- alias: "attr-name",
2322
- inside: {
2323
- string: null
2324
- // see below
2325
- }
2326
- },
2327
- // Closure params should not be confused with bitwise OR |
2328
- "closure-params": {
2329
- pattern: /([=(,:]\s*|\bmove\s*)\|[^|]*\||\|[^|]*\|(?=\s*(?:\{|->))/,
2330
- lookbehind: true,
2331
- greedy: true,
2332
- inside: {
2333
- "closure-punctuation": {
2334
- pattern: /^\||\|$/,
2335
- alias: "punctuation"
2336
- },
2337
- rest: null
2338
- // see below
2339
- }
2340
- },
2341
- "lifetime-annotation": {
2342
- pattern: /'\w+/,
2343
- alias: "symbol"
2344
- },
2345
- "fragment-specifier": {
2346
- pattern: /(\$\w+:)[a-z]+/,
2347
- lookbehind: true,
2348
- alias: "punctuation"
2349
- },
2350
- variable: /\$\w+/,
2351
- "function-definition": {
2352
- pattern: /(\bfn\s+)\w+/,
2353
- lookbehind: true,
2354
- alias: "function"
2355
- },
2356
- "type-definition": {
2357
- pattern: /(\b(?:enum|struct|trait|type|union)\s+)\w+/,
2358
- lookbehind: true,
2359
- alias: "class-name"
2360
- },
2361
- "module-declaration": [
2362
- {
2363
- pattern: /(\b(?:crate|mod)\s+)[a-z][a-z_\d]*/,
2364
- lookbehind: true,
2365
- alias: "namespace"
2366
- },
2367
- {
2368
- pattern: /(\b(?:crate|self|super)\s*)::\s*[a-z][a-z_\d]*\b(?:\s*::(?:\s*[a-z][a-z_\d]*\s*::)*)?/,
2369
- lookbehind: true,
2370
- alias: "namespace",
2371
- inside: {
2372
- punctuation: /::/
2373
- }
2374
- }
2375
- ],
2376
- keyword: [
2377
- // https://github.com/rust-lang/reference/blob/master/src/keywords.md
2378
- /\b(?:Self|abstract|as|async|await|become|box|break|const|continue|crate|do|dyn|else|enum|extern|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|override|priv|pub|ref|return|self|static|struct|super|trait|try|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/,
2379
- // primitives and str
2380
- // https://doc.rust-lang.org/stable/rust-by-example/primitives.html
2381
- /\b(?:bool|char|f(?:32|64)|[ui](?:8|16|32|64|128|size)|str)\b/
2382
- ],
2383
- // functions can technically start with an upper-case letter, but this will introduce a lot of false positives
2384
- // and Rust's naming conventions recommend snake_case anyway.
2385
- // https://doc.rust-lang.org/1.0.0/style/style/naming/README.html
2386
- function: /\b[a-z_]\w*(?=\s*(?:::\s*<|\())/,
2387
- macro: {
2388
- pattern: /\b\w+!/,
2389
- alias: "property"
2390
- },
2391
- constant: /\b[A-Z_][A-Z_\d]+\b/,
2392
- "class-name": /\b[A-Z]\w*\b/,
2393
- namespace: {
2394
- pattern: /(?:\b[a-z][a-z_\d]*\s*::\s*)*\b[a-z][a-z_\d]*\s*::(?!\s*<)/,
2395
- inside: {
2396
- punctuation: /::/
2397
- }
2398
- },
2399
- // Hex, oct, bin, dec numbers with visual separators and type suffix
2400
- number: /\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(?:(?:\d(?:_?\d)*)?\.)?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:f32|f64|[iu](?:8|16|32|64|size)?))?\b/,
2401
- boolean: /\b(?:false|true)\b/,
2402
- punctuation: /->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,
2403
- operator: /[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/
2404
- };
2405
- Prism3.languages.rust["closure-params"].inside.rest = Prism3.languages.rust;
2406
- Prism3.languages.rust["attribute"].inside["string"] = Prism3.languages.rust["string"];
2407
- })(Prism2);
2408
- }
2409
- export {
2410
- jsx as a,
2411
- tsx as b,
2412
- bash as c,
2413
- json as d,
2414
- css as e,
2415
- rust as f,
2416
- go as g,
2417
- java as h,
2418
- javascript as j,
2419
- markdown as m,
2420
- python as p,
2421
- refractor as r,
2422
- sql as s,
2423
- typescript as t,
2424
- yaml as y
2425
- };