@kg-ui/kg-ui-plus 0.0.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.
- package/README.md +39 -0
- package/dist/es/KgCopilot/CopiContent/AnswerHead.vue.mjs +16 -0
- package/dist/es/KgCopilot/CopiContent/AnswerHead.vue2.mjs +4 -0
- package/dist/es/KgCopilot/CopiContent/UserHead.vue.mjs +26 -0
- package/dist/es/KgCopilot/CopiContent/UserHead.vue2.mjs +4 -0
- package/dist/es/KgCopilot/CopiFooter/components/NewTheme.vue.mjs +7 -0
- package/dist/es/KgCopilot/CopiFooter/components/NewTheme.vue2.mjs +49 -0
- package/dist/es/KgCopilot/CopiFooter/components/NewTheme.vue3.mjs +4 -0
- package/dist/es/KgCopilot/CopiFooter/components/SearchInput/SelectPlugin.vue.mjs +7 -0
- package/dist/es/KgCopilot/CopiFooter/components/SearchInput/SelectPlugin.vue2.mjs +94 -0
- package/dist/es/KgCopilot/CopiFooter/components/SearchInput/SelectPlugin.vue3.mjs +4 -0
- package/dist/es/KgCopilot/CopiFooter/components/SearchInput/SpeechControl.vue.mjs +7 -0
- package/dist/es/KgCopilot/CopiFooter/components/SearchInput/SpeechControl.vue2.mjs +33 -0
- package/dist/es/KgCopilot/CopiFooter/components/SearchInput/SpeechControl.vue3.mjs +4 -0
- package/dist/es/KgCopilot/CopiFooter/components/SearchInput/Upload.vue.mjs +7 -0
- package/dist/es/KgCopilot/CopiFooter/components/SearchInput/Upload.vue2.mjs +140 -0
- package/dist/es/KgCopilot/CopiFooter/components/SearchInput/Upload.vue3.mjs +4 -0
- package/dist/es/KgCopilot/CopiFooter/components/SearchInput/index.vue.mjs +7 -0
- package/dist/es/KgCopilot/CopiFooter/components/SearchInput/index.vue2.mjs +131 -0
- package/dist/es/KgCopilot/CopiFooter/components/SearchInput/index.vue3.mjs +4 -0
- package/dist/es/KgCopilot/CopiFooter/index.vue.mjs +7 -0
- package/dist/es/KgCopilot/CopiFooter/index.vue2.mjs +21 -0
- package/dist/es/KgCopilot/CopiFooter/index.vue3.mjs +4 -0
- package/dist/es/KgCopilot/dialogue.vue.mjs +7 -0
- package/dist/es/KgCopilot/dialogue.vue2.mjs +131 -0
- package/dist/es/KgCopilot/dialogue.vue3.mjs +4 -0
- package/dist/es/KgCopilot/index.vue.mjs +7 -0
- package/dist/es/KgCopilot/index.vue2.mjs +49 -0
- package/dist/es/KgCopilot/index.vue3.mjs +4 -0
- package/dist/es/KgCopilot/mdInCode.mjs +56 -0
- package/dist/es/KgCopilot/readMd.vue.mjs +7 -0
- package/dist/es/KgCopilot/readMd.vue2.mjs +87 -0
- package/dist/es/KgCopilot/readMd.vue3.mjs +4 -0
- package/dist/es/ReIcon/index.mjs +11 -0
- package/dist/es/ReIcon/src/iconfont.mjs +46 -0
- package/dist/es/ReIcon/src/iconifyIconOffline.mjs +30 -0
- package/dist/es/ReIcon/src/iconifyIconOnline.mjs +29 -0
- package/dist/es/_virtual/___vite-browser-external.mjs +6 -0
- package/dist/es/_virtual/__vite-browser-external.mjs +4 -0
- package/dist/es/_virtual/_commonjsHelpers.mjs +34 -0
- package/dist/es/_virtual/_plugin-vue_export-helper.mjs +10 -0
- package/dist/es/_virtual/index.mjs +13 -0
- package/dist/es/api/project.mjs +51 -0
- package/dist/es/directives/heighlight/index.mjs +69 -0
- package/dist/es/directives/index.mjs +4 -0
- package/dist/es/home/LFilter/FilterArea.vue.mjs +7 -0
- package/dist/es/home/LFilter/FilterArea.vue2.mjs +507 -0
- package/dist/es/home/LFilter/FilterArea.vue3.mjs +4 -0
- package/dist/es/home/LFilter/FilterHead.vue.mjs +129 -0
- package/dist/es/home/LFilter/FilterHead.vue2.mjs +4 -0
- package/dist/es/home/LFilter/FilterItem.vue.mjs +7 -0
- package/dist/es/home/LFilter/FilterItem.vue2.mjs +114 -0
- package/dist/es/home/LFilter/FilterItem.vue3.mjs +4 -0
- package/dist/es/home/LFilter/FilterItemIcon.vue.mjs +7 -0
- package/dist/es/home/LFilter/FilterItemIcon.vue2.mjs +171 -0
- package/dist/es/home/LFilter/FilterItemIcon.vue3.mjs +4 -0
- package/dist/es/home/LFilter/index.vue.mjs +17 -0
- package/dist/es/home/LFilter/index.vue2.mjs +4 -0
- package/dist/es/home/LProject/index.vue.mjs +7 -0
- package/dist/es/home/LProject/index.vue2.mjs +70 -0
- package/dist/es/home/LProject/index.vue3.mjs +4 -0
- package/dist/es/home/index.vue.mjs +7 -0
- package/dist/es/home/index.vue2.mjs +80 -0
- package/dist/es/home/index.vue3.mjs +4 -0
- package/dist/es/index.mjs +36 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/check.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/circle-plus.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/close.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/microphone.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/paperclip.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/promotion.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/upload.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ph@1.2.5/node_modules/@iconify-icons/ph/copy-simple.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ph@1.2.5/node_modules/@iconify-icons/ph/speaker-high-light.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ph@1.2.5/node_modules/@iconify-icons/ph/thumbs-down-thin.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ph@1.2.5/node_modules/@iconify-icons/ph/thumbs-up-thin.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ph@1.2.5/node_modules/@iconify-icons/ph/warning-bold.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ri@1.2.3/node_modules/@iconify-icons/ri/add-line.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ri@1.2.3/node_modules/@iconify-icons/ri/arrow-down-s-line.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ri@1.2.3/node_modules/@iconify-icons/ri/arrow-up-s-line.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ri@1.2.3/node_modules/@iconify-icons/ri/check-fill.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ri@1.2.3/node_modules/@iconify-icons/ri/download-line.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ri@1.2.3/node_modules/@iconify-icons/ri/more-2-fill.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify_vue@4.0.0_vue@3.2.45/node_modules/@iconify/vue/dist/iconify.mjs +1702 -0
- package/dist/es/node_modules/.pnpm/@iconify_vue@4.0.0_vue@3.2.45/node_modules/@iconify/vue/dist/offline.mjs +436 -0
- package/dist/es/node_modules/.pnpm/@pureadmin_utils@1.8.5_vue@3.2.45/node_modules/@pureadmin/utils/dist/index.mjs +70 -0
- package/dist/es/node_modules/.pnpm/call-bind@1.0.7/node_modules/call-bind/callBound.mjs +16 -0
- package/dist/es/node_modules/.pnpm/call-bind@1.0.7/node_modules/call-bind/index.mjs +36 -0
- package/dist/es/node_modules/.pnpm/define-data-property@1.1.4/node_modules/define-data-property/index.mjs +48 -0
- package/dist/es/node_modules/.pnpm/dompurify@3.0.10/node_modules/dompurify/dist/purify.es.mjs +949 -0
- package/dist/es/node_modules/.pnpm/es-define-property@1.0.0/node_modules/es-define-property/index.mjs +22 -0
- package/dist/es/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/eval.mjs +4 -0
- package/dist/es/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/index.mjs +4 -0
- package/dist/es/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/range.mjs +4 -0
- package/dist/es/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/ref.mjs +4 -0
- package/dist/es/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/syntax.mjs +4 -0
- package/dist/es/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/type.mjs +4 -0
- package/dist/es/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/uri.mjs +4 -0
- package/dist/es/node_modules/.pnpm/function-bind@1.1.2/node_modules/function-bind/implementation.mjs +72 -0
- package/dist/es/node_modules/.pnpm/function-bind@1.1.2/node_modules/function-bind/index.mjs +6 -0
- package/dist/es/node_modules/.pnpm/get-intrinsic@1.2.4/node_modules/get-intrinsic/index.mjs +320 -0
- package/dist/es/node_modules/.pnpm/gopd@1.0.1/node_modules/gopd/index.mjs +14 -0
- package/dist/es/node_modules/.pnpm/has-property-descriptors@1.0.2/node_modules/has-property-descriptors/index.mjs +19 -0
- package/dist/es/node_modules/.pnpm/has-proto@1.0.3/node_modules/has-proto/index.mjs +11 -0
- package/dist/es/node_modules/.pnpm/has-symbols@1.0.3/node_modules/has-symbols/index.mjs +21 -0
- package/dist/es/node_modules/.pnpm/has-symbols@1.0.3/node_modules/has-symbols/shams.mjs +48 -0
- package/dist/es/node_modules/.pnpm/hasown@2.0.2/node_modules/hasown/index.mjs +8 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/core.mjs +5 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/apache.mjs +91 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/bash.mjs +377 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/basic.mjs +221 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/c.mjs +280 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/css.mjs +732 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/dart.mjs +247 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/django.mjs +47 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/dns.mjs +71 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/dos.mjs +160 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/dust.mjs +38 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/erlang.mjs +176 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/go.mjs +135 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/http.mjs +89 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/java.mjs +254 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/javascript.mjs +698 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/json.mjs +40 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/markdown.mjs +227 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/nginx.mjs +144 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/php.mjs +589 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/python.mjs +414 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/ruby.mjs +414 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/stylus.mjs +766 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/swift.mjs +832 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/typescript.mjs +788 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/xml.mjs +227 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/lib/core.mjs +1580 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/styles/paraiso-light.css.mjs +4 -0
- package/dist/es/node_modules/.pnpm/marked@12.0.1/node_modules/marked/lib/marked.esm.mjs +2045 -0
- package/dist/es/node_modules/.pnpm/object-inspect@1.13.1/node_modules/object-inspect/index.mjs +514 -0
- package/dist/es/node_modules/.pnpm/pinyin-match@1.2.4/node_modules/pinyin-match/es/main.mjs +124 -0
- package/dist/es/node_modules/.pnpm/qs@6.11.0/node_modules/qs/lib/formats.mjs +22 -0
- package/dist/es/node_modules/.pnpm/qs@6.11.0/node_modules/qs/lib/index.mjs +14 -0
- package/dist/es/node_modules/.pnpm/qs@6.11.0/node_modules/qs/lib/parse.mjs +199 -0
- package/dist/es/node_modules/.pnpm/qs@6.11.0/node_modules/qs/lib/stringify.mjs +262 -0
- package/dist/es/node_modules/.pnpm/qs@6.11.0/node_modules/qs/lib/utils.mjs +196 -0
- package/dist/es/node_modules/.pnpm/set-function-length@1.2.2/node_modules/set-function-length/index.mjs +54 -0
- package/dist/es/node_modules/.pnpm/side-channel@1.0.6/node_modules/side-channel/index.mjs +115 -0
- package/dist/es/store/index.mjs +8 -0
- package/dist/es/store/modules/copilot.mjs +108 -0
- package/dist/es/store/modules/filters.mjs +346 -0
- package/dist/es/store/modules/types.mjs +19 -0
- package/dist/es/style/index.scss.mjs +4 -0
- package/dist/es/style/tailwind.css.mjs +4 -0
- package/dist/es/style.css +1 -0
- package/dist/es/utils/home.mjs +129 -0
- package/dist/es/utils/http/index.mjs +90 -0
- package/dist/es/utils/message.mjs +42 -0
- package/package.json +124 -0
@@ -0,0 +1,414 @@
|
|
1
|
+
function python(hljs) {
|
2
|
+
const regex = hljs.regex;
|
3
|
+
const IDENT_RE = /[\p{XID_Start}_]\p{XID_Continue}*/u;
|
4
|
+
const RESERVED_WORDS = [
|
5
|
+
"and",
|
6
|
+
"as",
|
7
|
+
"assert",
|
8
|
+
"async",
|
9
|
+
"await",
|
10
|
+
"break",
|
11
|
+
"case",
|
12
|
+
"class",
|
13
|
+
"continue",
|
14
|
+
"def",
|
15
|
+
"del",
|
16
|
+
"elif",
|
17
|
+
"else",
|
18
|
+
"except",
|
19
|
+
"finally",
|
20
|
+
"for",
|
21
|
+
"from",
|
22
|
+
"global",
|
23
|
+
"if",
|
24
|
+
"import",
|
25
|
+
"in",
|
26
|
+
"is",
|
27
|
+
"lambda",
|
28
|
+
"match",
|
29
|
+
"nonlocal|10",
|
30
|
+
"not",
|
31
|
+
"or",
|
32
|
+
"pass",
|
33
|
+
"raise",
|
34
|
+
"return",
|
35
|
+
"try",
|
36
|
+
"while",
|
37
|
+
"with",
|
38
|
+
"yield"
|
39
|
+
];
|
40
|
+
const BUILT_INS = [
|
41
|
+
"__import__",
|
42
|
+
"abs",
|
43
|
+
"all",
|
44
|
+
"any",
|
45
|
+
"ascii",
|
46
|
+
"bin",
|
47
|
+
"bool",
|
48
|
+
"breakpoint",
|
49
|
+
"bytearray",
|
50
|
+
"bytes",
|
51
|
+
"callable",
|
52
|
+
"chr",
|
53
|
+
"classmethod",
|
54
|
+
"compile",
|
55
|
+
"complex",
|
56
|
+
"delattr",
|
57
|
+
"dict",
|
58
|
+
"dir",
|
59
|
+
"divmod",
|
60
|
+
"enumerate",
|
61
|
+
"eval",
|
62
|
+
"exec",
|
63
|
+
"filter",
|
64
|
+
"float",
|
65
|
+
"format",
|
66
|
+
"frozenset",
|
67
|
+
"getattr",
|
68
|
+
"globals",
|
69
|
+
"hasattr",
|
70
|
+
"hash",
|
71
|
+
"help",
|
72
|
+
"hex",
|
73
|
+
"id",
|
74
|
+
"input",
|
75
|
+
"int",
|
76
|
+
"isinstance",
|
77
|
+
"issubclass",
|
78
|
+
"iter",
|
79
|
+
"len",
|
80
|
+
"list",
|
81
|
+
"locals",
|
82
|
+
"map",
|
83
|
+
"max",
|
84
|
+
"memoryview",
|
85
|
+
"min",
|
86
|
+
"next",
|
87
|
+
"object",
|
88
|
+
"oct",
|
89
|
+
"open",
|
90
|
+
"ord",
|
91
|
+
"pow",
|
92
|
+
"print",
|
93
|
+
"property",
|
94
|
+
"range",
|
95
|
+
"repr",
|
96
|
+
"reversed",
|
97
|
+
"round",
|
98
|
+
"set",
|
99
|
+
"setattr",
|
100
|
+
"slice",
|
101
|
+
"sorted",
|
102
|
+
"staticmethod",
|
103
|
+
"str",
|
104
|
+
"sum",
|
105
|
+
"super",
|
106
|
+
"tuple",
|
107
|
+
"type",
|
108
|
+
"vars",
|
109
|
+
"zip"
|
110
|
+
];
|
111
|
+
const LITERALS = [
|
112
|
+
"__debug__",
|
113
|
+
"Ellipsis",
|
114
|
+
"False",
|
115
|
+
"None",
|
116
|
+
"NotImplemented",
|
117
|
+
"True"
|
118
|
+
];
|
119
|
+
const TYPES = [
|
120
|
+
"Any",
|
121
|
+
"Callable",
|
122
|
+
"Coroutine",
|
123
|
+
"Dict",
|
124
|
+
"List",
|
125
|
+
"Literal",
|
126
|
+
"Generic",
|
127
|
+
"Optional",
|
128
|
+
"Sequence",
|
129
|
+
"Set",
|
130
|
+
"Tuple",
|
131
|
+
"Type",
|
132
|
+
"Union"
|
133
|
+
];
|
134
|
+
const KEYWORDS = {
|
135
|
+
$pattern: /[A-Za-z]\w+|__\w+__/,
|
136
|
+
keyword: RESERVED_WORDS,
|
137
|
+
built_in: BUILT_INS,
|
138
|
+
literal: LITERALS,
|
139
|
+
type: TYPES
|
140
|
+
};
|
141
|
+
const PROMPT = {
|
142
|
+
className: "meta",
|
143
|
+
begin: /^(>>>|\.\.\.) /
|
144
|
+
};
|
145
|
+
const SUBST = {
|
146
|
+
className: "subst",
|
147
|
+
begin: /\{/,
|
148
|
+
end: /\}/,
|
149
|
+
keywords: KEYWORDS,
|
150
|
+
illegal: /#/
|
151
|
+
};
|
152
|
+
const LITERAL_BRACKET = {
|
153
|
+
begin: /\{\{/,
|
154
|
+
relevance: 0
|
155
|
+
};
|
156
|
+
const STRING = {
|
157
|
+
className: "string",
|
158
|
+
contains: [hljs.BACKSLASH_ESCAPE],
|
159
|
+
variants: [
|
160
|
+
{
|
161
|
+
begin: /([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,
|
162
|
+
end: /'''/,
|
163
|
+
contains: [
|
164
|
+
hljs.BACKSLASH_ESCAPE,
|
165
|
+
PROMPT
|
166
|
+
],
|
167
|
+
relevance: 10
|
168
|
+
},
|
169
|
+
{
|
170
|
+
begin: /([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,
|
171
|
+
end: /"""/,
|
172
|
+
contains: [
|
173
|
+
hljs.BACKSLASH_ESCAPE,
|
174
|
+
PROMPT
|
175
|
+
],
|
176
|
+
relevance: 10
|
177
|
+
},
|
178
|
+
{
|
179
|
+
begin: /([fF][rR]|[rR][fF]|[fF])'''/,
|
180
|
+
end: /'''/,
|
181
|
+
contains: [
|
182
|
+
hljs.BACKSLASH_ESCAPE,
|
183
|
+
PROMPT,
|
184
|
+
LITERAL_BRACKET,
|
185
|
+
SUBST
|
186
|
+
]
|
187
|
+
},
|
188
|
+
{
|
189
|
+
begin: /([fF][rR]|[rR][fF]|[fF])"""/,
|
190
|
+
end: /"""/,
|
191
|
+
contains: [
|
192
|
+
hljs.BACKSLASH_ESCAPE,
|
193
|
+
PROMPT,
|
194
|
+
LITERAL_BRACKET,
|
195
|
+
SUBST
|
196
|
+
]
|
197
|
+
},
|
198
|
+
{
|
199
|
+
begin: /([uU]|[rR])'/,
|
200
|
+
end: /'/,
|
201
|
+
relevance: 10
|
202
|
+
},
|
203
|
+
{
|
204
|
+
begin: /([uU]|[rR])"/,
|
205
|
+
end: /"/,
|
206
|
+
relevance: 10
|
207
|
+
},
|
208
|
+
{
|
209
|
+
begin: /([bB]|[bB][rR]|[rR][bB])'/,
|
210
|
+
end: /'/
|
211
|
+
},
|
212
|
+
{
|
213
|
+
begin: /([bB]|[bB][rR]|[rR][bB])"/,
|
214
|
+
end: /"/
|
215
|
+
},
|
216
|
+
{
|
217
|
+
begin: /([fF][rR]|[rR][fF]|[fF])'/,
|
218
|
+
end: /'/,
|
219
|
+
contains: [
|
220
|
+
hljs.BACKSLASH_ESCAPE,
|
221
|
+
LITERAL_BRACKET,
|
222
|
+
SUBST
|
223
|
+
]
|
224
|
+
},
|
225
|
+
{
|
226
|
+
begin: /([fF][rR]|[rR][fF]|[fF])"/,
|
227
|
+
end: /"/,
|
228
|
+
contains: [
|
229
|
+
hljs.BACKSLASH_ESCAPE,
|
230
|
+
LITERAL_BRACKET,
|
231
|
+
SUBST
|
232
|
+
]
|
233
|
+
},
|
234
|
+
hljs.APOS_STRING_MODE,
|
235
|
+
hljs.QUOTE_STRING_MODE
|
236
|
+
]
|
237
|
+
};
|
238
|
+
const digitpart = "[0-9](_?[0-9])*";
|
239
|
+
const pointfloat = `(\\b(${digitpart}))?\\.(${digitpart})|\\b(${digitpart})\\.`;
|
240
|
+
const lookahead = `\\b|${RESERVED_WORDS.join("|")}`;
|
241
|
+
const NUMBER = {
|
242
|
+
className: "number",
|
243
|
+
relevance: 0,
|
244
|
+
variants: [
|
245
|
+
// exponentfloat, pointfloat
|
246
|
+
// https://docs.python.org/3.9/reference/lexical_analysis.html#floating-point-literals
|
247
|
+
// optionally imaginary
|
248
|
+
// https://docs.python.org/3.9/reference/lexical_analysis.html#imaginary-literals
|
249
|
+
// Note: no leading \b because floats can start with a decimal point
|
250
|
+
// and we don't want to mishandle e.g. `fn(.5)`,
|
251
|
+
// no trailing \b for pointfloat because it can end with a decimal point
|
252
|
+
// and we don't want to mishandle e.g. `0..hex()`; this should be safe
|
253
|
+
// because both MUST contain a decimal point and so cannot be confused with
|
254
|
+
// the interior part of an identifier
|
255
|
+
{
|
256
|
+
begin: `(\\b(${digitpart})|(${pointfloat}))[eE][+-]?(${digitpart})[jJ]?(?=${lookahead})`
|
257
|
+
},
|
258
|
+
{
|
259
|
+
begin: `(${pointfloat})[jJ]?`
|
260
|
+
},
|
261
|
+
// decinteger, bininteger, octinteger, hexinteger
|
262
|
+
// https://docs.python.org/3.9/reference/lexical_analysis.html#integer-literals
|
263
|
+
// optionally "long" in Python 2
|
264
|
+
// https://docs.python.org/2.7/reference/lexical_analysis.html#integer-and-long-integer-literals
|
265
|
+
// decinteger is optionally imaginary
|
266
|
+
// https://docs.python.org/3.9/reference/lexical_analysis.html#imaginary-literals
|
267
|
+
{
|
268
|
+
begin: `\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${lookahead})`
|
269
|
+
},
|
270
|
+
{
|
271
|
+
begin: `\\b0[bB](_?[01])+[lL]?(?=${lookahead})`
|
272
|
+
},
|
273
|
+
{
|
274
|
+
begin: `\\b0[oO](_?[0-7])+[lL]?(?=${lookahead})`
|
275
|
+
},
|
276
|
+
{
|
277
|
+
begin: `\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${lookahead})`
|
278
|
+
},
|
279
|
+
// imagnumber (digitpart-based)
|
280
|
+
// https://docs.python.org/3.9/reference/lexical_analysis.html#imaginary-literals
|
281
|
+
{
|
282
|
+
begin: `\\b(${digitpart})[jJ](?=${lookahead})`
|
283
|
+
}
|
284
|
+
]
|
285
|
+
};
|
286
|
+
const COMMENT_TYPE = {
|
287
|
+
className: "comment",
|
288
|
+
begin: regex.lookahead(/# type:/),
|
289
|
+
end: /$/,
|
290
|
+
keywords: KEYWORDS,
|
291
|
+
contains: [
|
292
|
+
{
|
293
|
+
// prevent keywords from coloring `type`
|
294
|
+
begin: /# type:/
|
295
|
+
},
|
296
|
+
// comment within a datatype comment includes no keywords
|
297
|
+
{
|
298
|
+
begin: /#/,
|
299
|
+
end: /\b\B/,
|
300
|
+
endsWithParent: true
|
301
|
+
}
|
302
|
+
]
|
303
|
+
};
|
304
|
+
const PARAMS = {
|
305
|
+
className: "params",
|
306
|
+
variants: [
|
307
|
+
// Exclude params in functions without params
|
308
|
+
{
|
309
|
+
className: "",
|
310
|
+
begin: /\(\s*\)/,
|
311
|
+
skip: true
|
312
|
+
},
|
313
|
+
{
|
314
|
+
begin: /\(/,
|
315
|
+
end: /\)/,
|
316
|
+
excludeBegin: true,
|
317
|
+
excludeEnd: true,
|
318
|
+
keywords: KEYWORDS,
|
319
|
+
contains: [
|
320
|
+
"self",
|
321
|
+
PROMPT,
|
322
|
+
NUMBER,
|
323
|
+
STRING,
|
324
|
+
hljs.HASH_COMMENT_MODE
|
325
|
+
]
|
326
|
+
}
|
327
|
+
]
|
328
|
+
};
|
329
|
+
SUBST.contains = [
|
330
|
+
STRING,
|
331
|
+
NUMBER,
|
332
|
+
PROMPT
|
333
|
+
];
|
334
|
+
return {
|
335
|
+
name: "Python",
|
336
|
+
aliases: [
|
337
|
+
"py",
|
338
|
+
"gyp",
|
339
|
+
"ipython"
|
340
|
+
],
|
341
|
+
unicodeRegex: true,
|
342
|
+
keywords: KEYWORDS,
|
343
|
+
illegal: /(<\/|\?)|=>/,
|
344
|
+
contains: [
|
345
|
+
PROMPT,
|
346
|
+
NUMBER,
|
347
|
+
{
|
348
|
+
// very common convention
|
349
|
+
begin: /\bself\b/
|
350
|
+
},
|
351
|
+
{
|
352
|
+
// eat "if" prior to string so that it won't accidentally be
|
353
|
+
// labeled as an f-string
|
354
|
+
beginKeywords: "if",
|
355
|
+
relevance: 0
|
356
|
+
},
|
357
|
+
STRING,
|
358
|
+
COMMENT_TYPE,
|
359
|
+
hljs.HASH_COMMENT_MODE,
|
360
|
+
{
|
361
|
+
match: [
|
362
|
+
/\bdef/,
|
363
|
+
/\s+/,
|
364
|
+
IDENT_RE
|
365
|
+
],
|
366
|
+
scope: {
|
367
|
+
1: "keyword",
|
368
|
+
3: "title.function"
|
369
|
+
},
|
370
|
+
contains: [PARAMS]
|
371
|
+
},
|
372
|
+
{
|
373
|
+
variants: [
|
374
|
+
{
|
375
|
+
match: [
|
376
|
+
/\bclass/,
|
377
|
+
/\s+/,
|
378
|
+
IDENT_RE,
|
379
|
+
/\s*/,
|
380
|
+
/\(\s*/,
|
381
|
+
IDENT_RE,
|
382
|
+
/\s*\)/
|
383
|
+
]
|
384
|
+
},
|
385
|
+
{
|
386
|
+
match: [
|
387
|
+
/\bclass/,
|
388
|
+
/\s+/,
|
389
|
+
IDENT_RE
|
390
|
+
]
|
391
|
+
}
|
392
|
+
],
|
393
|
+
scope: {
|
394
|
+
1: "keyword",
|
395
|
+
3: "title.class",
|
396
|
+
6: "title.class.inherited"
|
397
|
+
}
|
398
|
+
},
|
399
|
+
{
|
400
|
+
className: "meta",
|
401
|
+
begin: /^[\t ]*@/,
|
402
|
+
end: /(?=#)|$/,
|
403
|
+
contains: [
|
404
|
+
NUMBER,
|
405
|
+
PARAMS,
|
406
|
+
STRING
|
407
|
+
]
|
408
|
+
}
|
409
|
+
]
|
410
|
+
};
|
411
|
+
}
|
412
|
+
export {
|
413
|
+
python as default
|
414
|
+
};
|