spec-up-t 1.1.55 → 1.2.1
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/assets/compiled/body.js +59 -8
- package/assets/compiled/head.css +13 -12
- package/assets/css/adjust-font-size.css +11 -0
- package/assets/css/collapse-meta-info.css +27 -8
- package/assets/css/create-term-filter.css +11 -0
- package/assets/css/index.css +15 -0
- package/assets/css/prism.css +176 -153
- package/assets/css/prism.dark.css +157 -0
- package/assets/css/prism.default.css +180 -0
- package/assets/css/terms-and-definitions.1.css +223 -0
- package/assets/css/terms-and-definitions.css +214 -100
- package/assets/js/addAnchorsToTerms.js +1 -1
- package/assets/js/collapse-definitions.js +2 -1
- package/assets/js/collapse-meta-info.js +25 -11
- package/assets/js/create-term-filter.js +61 -0
- package/assets/js/horizontal-scroll-hint.js +159 -0
- package/assets/js/index.1.js +137 -0
- package/assets/js/index.js +2 -1
- package/assets/js/insert-trefs.js +122 -116
- package/assets/js/insert-xrefs.1.js +372 -0
- package/assets/js/{show-commit-hashes.js → insert-xrefs.js} +67 -7
- package/assets/js/prism.dark.js +24 -0
- package/assets/js/prism.default.js +23 -0
- package/assets/js/prism.js +4 -5
- package/assets/js/search.js +1 -1
- package/assets/js/toggle-dense-info.js +40 -0
- package/branches.md +4 -24
- package/index.js +429 -190
- package/index.new.js +662 -0
- package/package.json +1 -2
- package/src/asset-map.json +9 -5
- package/src/collect-external-references.js +16 -9
- package/src/collectExternalReferences/fetchTermsFromIndex.js +328 -0
- package/src/collectExternalReferences/processXTrefsData.js +73 -18
- package/src/create-pdf.js +385 -89
- package/src/health-check/term-references-checker.js +3 -2
- package/src/health-check/tref-term-checker.js +18 -17
- package/src/markdown-it-extensions.js +134 -103
- package/src/prepare-tref.js +61 -24
- package/src/utils/fetch.js +100 -0
- package/templates/template.html +12 -7
- package/assets/js/css-helper.js +0 -30
- package/src/collectExternalReferences/fetchTermsFromGitHubRepository.js +0 -232
- package/src/collectExternalReferences/fetchTermsFromGitHubRepository.test.js +0 -385
- package/src/collectExternalReferences/octokitClient.js +0 -96
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file This file fetches and displays commit hashes by matching elements with `x-term-reference` class against the `allXTrefs` global object.
|
|
3
|
+
* Example:
|
|
4
|
+
* const allXTrefs = {
|
|
5
|
+
"xtrefs": [
|
|
6
|
+
{
|
|
7
|
+
"externalSpec": "test-1",
|
|
8
|
+
"term": "Aal",
|
|
9
|
+
"repoUrl": "https://github.com/blockchainbird/spec-up-xref-test-1",
|
|
10
|
+
"terms_dir": "spec/term-definitions",
|
|
11
|
+
"owner": "blockchainbird",
|
|
12
|
+
"repo": "spec-up-xref-test-1",
|
|
13
|
+
"site": "https://blockchainbird.github.io/spec-up-xref-test-1/",
|
|
14
|
+
"commitHash": [
|
|
15
|
+
"f66951f1d378490289caab9c51141b44a0438365",
|
|
16
|
+
"content": "[[def: AAL]]:\n\n~ See: [[ref: authenticator assurance level]].\n\n~ This is an addition, for testing purposes.\n"
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
{…}
|
|
20
|
+
]
|
|
21
|
+
};
|
|
22
|
+
* @author Kor Dwarshuis
|
|
23
|
+
* @version 0.0.1
|
|
24
|
+
* @license MIT
|
|
25
|
+
* @since 2024-06-09
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
function fetchCommitHashes() {
|
|
31
|
+
|
|
32
|
+
let tipMap = new WeakMap();
|
|
33
|
+
|
|
34
|
+
async function insertGitHubTermRealTime(match, element) {
|
|
35
|
+
const div = document.createElement('div');
|
|
36
|
+
div.classList.add('fetched-xref-term');
|
|
37
|
+
div.classList.add('transcluded-xref-term');
|
|
38
|
+
div.innerHTML = "<p class='loadertext'>Loading external reference</p><div class='loader'></div>";
|
|
39
|
+
element.parentNode.insertBefore(div, element.nextSibling);
|
|
40
|
+
|
|
41
|
+
// Promise.all waits for both termPromise and delayPromise to complete if termPromise finishes within 2000 ms.If termPromise takes longer than 2000 ms, the delay is effectively bypassed because Promise.all only cares about both promises finishing, regardless of the time taken by each.
|
|
42
|
+
|
|
43
|
+
// Start fetching the GitHub term asynchronously
|
|
44
|
+
const termPromise = fetchGitHubTerm(savedToken, match);
|
|
45
|
+
|
|
46
|
+
// Create a delay of 2000 ms
|
|
47
|
+
const delayPromise = new Promise(resolve => setTimeout(resolve, 2000));
|
|
48
|
+
|
|
49
|
+
// Wait for whichever completes last between termPromise and delayPromise. The square brackets are used for array destructuring. In this context, the code is awaiting the resolution of multiple promises (termPromise and delayPromise) using Promise.all. The result of Promise.all is an array, and the square brackets are used to extract the first element of that array into the variable term.
|
|
50
|
+
const [term] = await Promise.all([termPromise, delayPromise]);
|
|
51
|
+
|
|
52
|
+
const timestamp = Date.now();
|
|
53
|
+
const date = new Date(timestamp);
|
|
54
|
+
const options = {
|
|
55
|
+
year: 'numeric',
|
|
56
|
+
month: 'long',
|
|
57
|
+
day: 'numeric',
|
|
58
|
+
hour: '2-digit',
|
|
59
|
+
minute: '2-digit',
|
|
60
|
+
second: '2-digit'
|
|
61
|
+
};
|
|
62
|
+
const humanReadableDate = date.toLocaleDateString('en-US', options);
|
|
63
|
+
|
|
64
|
+
// Now that either both are complete or the term has taken longer than 2000 ms, continue with your code
|
|
65
|
+
div.innerHTML = "<p class='transclusion-heading'>Current definition</p><small>" + humanReadableDate + "</small>" + term;
|
|
66
|
+
}
|
|
67
|
+
// Check if allXTrefs is undefined or does not exist
|
|
68
|
+
if (typeof allXTrefs === 'undefined' || allXTrefs === null) {
|
|
69
|
+
console.log('allXTrefs is not defined or does not exist. We will continue without it.');
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Load GitHub API token from local storage if it exists
|
|
74
|
+
const savedToken = localStorage.getItem('githubToken');
|
|
75
|
+
|
|
76
|
+
// Markdown parser, assuming markdown-it and markdown-it-deflist are globally available
|
|
77
|
+
const md = window.markdownit().use(window.markdownitDeflist);
|
|
78
|
+
|
|
79
|
+
// A: Debounce function to delay execution, so the error message is not displayed too often, since we do not know of often and how many times the error will be triggered.
|
|
80
|
+
function debounce(func, wait) {
|
|
81
|
+
let timeout;
|
|
82
|
+
return function (...args) {
|
|
83
|
+
clearTimeout(timeout);
|
|
84
|
+
timeout = setTimeout(() => func.apply(this, args), wait);
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// B: Debounced “GitHub API rate limit exceeded” error message
|
|
89
|
+
const debouncedError = debounce(() => {
|
|
90
|
+
notyf.error('GitHub API rate limit exceeded. See <a target="_blank" rel="noopener" href="https://blockchainbird.github.io/spec-up-t-website/docs/getting-started/github-token">documentation</a> for more info.');
|
|
91
|
+
}, 3000); // Delay in milliseconds
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Fetches the content of a term file from GitHub using the GitHub API.
|
|
95
|
+
* Compares the fetched content with the locally stored version and displays the diff in a modal.
|
|
96
|
+
*
|
|
97
|
+
* @param {string} savedToken - GitHub API token for authentication
|
|
98
|
+
* @param {Object} match - The matched term object containing repository and term information
|
|
99
|
+
*/
|
|
100
|
+
function fetchGitHubContent(savedToken, match) {
|
|
101
|
+
// Create a headers object with the Authorization header if a GitHub API token is set
|
|
102
|
+
const headers = {};
|
|
103
|
+
if (savedToken && savedToken.length > 0) {
|
|
104
|
+
headers['Authorization'] = `token ${savedToken}`;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
fetch('https://api.github.com/repos/' + match.owner + '/' + match.repo + '/contents/' + match.terms_dir + '/' + match.term.replace(/ /g, '-').toLowerCase() + '.md', { headers: headers })
|
|
108
|
+
.then(response => {
|
|
109
|
+
if (response.status === 403 && response.headers.get('X-RateLimit-Remaining') === '0') {
|
|
110
|
+
const resetTime = new Date(response.headers.get('X-RateLimit-Reset') * 1000);
|
|
111
|
+
console.error(`❌ Github API rate limit exceeded. Try again after ${resetTime}. See https://blockchainbird.github.io/spec-up-t-website/docs/getting-started/github-token for more info.`);
|
|
112
|
+
|
|
113
|
+
// Call the debounced error function
|
|
114
|
+
debouncedError();
|
|
115
|
+
return true;
|
|
116
|
+
} else {
|
|
117
|
+
console.log(`ℹ️ Github API rate limit: ${response.headers.get('X-RateLimit-Remaining')} requests remaining. See https://blockchainbird.github.io/spec-up-t-website/docs/getting-started/github-token for more info.`);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return response.json();
|
|
121
|
+
})
|
|
122
|
+
.then(data => {
|
|
123
|
+
// Decode base64 encoded content
|
|
124
|
+
const decodedContent = atob(data.content);
|
|
125
|
+
|
|
126
|
+
// Diff the content of the current term-file with the content of stored version
|
|
127
|
+
// See https://www.npmjs.com/package/diff , examples
|
|
128
|
+
const diff = Diff.diffChars(match.content, decodedContent),
|
|
129
|
+
fragment = document.createDocumentFragment();
|
|
130
|
+
|
|
131
|
+
diff.forEach((part) => {
|
|
132
|
+
// green for additions, red for deletions
|
|
133
|
+
// grey for common parts
|
|
134
|
+
const color = part.added ? 'green' :
|
|
135
|
+
part.removed ? 'red' : 'grey';
|
|
136
|
+
|
|
137
|
+
const backgroundColor = part.added ? '#ddd' :
|
|
138
|
+
part.removed ? '#ddd' : 'white';
|
|
139
|
+
|
|
140
|
+
span = document.createElement('span');
|
|
141
|
+
span.style.color = color;
|
|
142
|
+
span.style.backgroundColor = backgroundColor;
|
|
143
|
+
|
|
144
|
+
span.appendChild(document
|
|
145
|
+
.createTextNode(part.value));
|
|
146
|
+
fragment.appendChild(span);
|
|
147
|
+
});
|
|
148
|
+
// Create a temporary container to hold the fragment
|
|
149
|
+
const tempContainer = document.createElement('div');
|
|
150
|
+
tempContainer.innerHTML = '<h1>Diff xref (local snapshot) and latest version</h1>';
|
|
151
|
+
tempContainer.appendChild(fragment);
|
|
152
|
+
// Replace newlines with <br> tags
|
|
153
|
+
tempContainer.innerHTML = tempContainer.innerHTML.replace(/\n/g, '<br>');
|
|
154
|
+
showModal(tempContainer.innerHTML);
|
|
155
|
+
})
|
|
156
|
+
.catch(error => {
|
|
157
|
+
console.error('Error fetching content:', error);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
async function fetchGitHubTerm(savedToken, match) {
|
|
162
|
+
function processSpecUpMarkdown(markdown) {
|
|
163
|
+
|
|
164
|
+
// Replace all occurrences of [[def: ]] with ''
|
|
165
|
+
const defRegex = /\[\[def: ([^\]]+)\]\]/g;
|
|
166
|
+
markdown = markdown.replace(defRegex, '');
|
|
167
|
+
|
|
168
|
+
// // Replace all occurrences of [[ref: ]] with <a href="#"></a>
|
|
169
|
+
// const refRegex = /\[\[ref: ([^\]]+)\]\]/g;
|
|
170
|
+
// markdown = markdown.replace(refRegex, '<a class="x-term-reference" data-local-href="ref:$1">$1</a>');
|
|
171
|
+
|
|
172
|
+
return md.render(markdown);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const headers = {};
|
|
176
|
+
if (savedToken && savedToken.length > 0) {
|
|
177
|
+
headers['Authorization'] = `token ${savedToken}`;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
try {
|
|
181
|
+
const response = await fetch('https://api.github.com/repos/' + match.owner + '/' + match.repo + '/contents/' + match.terms_dir + '/' + match.term.replace(/ /g, '-').toLowerCase() + '.md', { headers: headers });
|
|
182
|
+
|
|
183
|
+
if (response.status === 403 && response.headers.get('X-RateLimit-Remaining') === '0') {
|
|
184
|
+
const resetTime = new Date(response.headers.get('X-RateLimit-Reset') * 1000);
|
|
185
|
+
console.error(`❌ Github API rate limit exceeded. Try again after ${resetTime}. See https://blockchainbird.github.io/spec-up-t-website/docs/getting-started/github-token for more info.`);
|
|
186
|
+
|
|
187
|
+
debouncedError();
|
|
188
|
+
return true;
|
|
189
|
+
} else {
|
|
190
|
+
console.log(`ℹ️ Github API rate limit: ${response.headers.get('X-RateLimit-Remaining')} requests remaining. See https://blockchainbird.github.io/spec-up-t-website/docs/getting-started/github-token for more info.`);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const data = await response.json();
|
|
194
|
+
const decodedContent = atob(data.content);
|
|
195
|
+
const processedContent = processSpecUpMarkdown(decodedContent);
|
|
196
|
+
return processedContent;
|
|
197
|
+
} catch (error) {
|
|
198
|
+
console.error('Error fetching content:', error);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// get all elements with class “x-term-reference”
|
|
203
|
+
const elements = document.querySelectorAll('.x-term-reference');
|
|
204
|
+
|
|
205
|
+
elements.forEach((element) => {
|
|
206
|
+
// Get the value of the data-local-href attribute
|
|
207
|
+
const href = element.getAttribute('data-local-href');
|
|
208
|
+
|
|
209
|
+
// split href on “:” and create array
|
|
210
|
+
const splitHref = href.split(':');
|
|
211
|
+
|
|
212
|
+
// allXTrefs is an object that is available in the global scope
|
|
213
|
+
allXTrefs.xtrefs.forEach((match) => {
|
|
214
|
+
|
|
215
|
+
//TODO: remove toLowerCase() or not?
|
|
216
|
+
if (match.externalSpec === splitHref[1] && match.term.toLowerCase() === splitHref[2].toLowerCase()) {
|
|
217
|
+
|
|
218
|
+
// If no commit hash is found, display a message and return
|
|
219
|
+
if (!match.commitHash) {
|
|
220
|
+
/**
|
|
221
|
+
* Error message element shown when no cross-reference is found
|
|
222
|
+
* Displayed directly after the term reference element
|
|
223
|
+
*/
|
|
224
|
+
const noXTrefFoundMessage = document.createElement('span');
|
|
225
|
+
noXTrefFoundMessage.classList.add('no-xref-found-message');
|
|
226
|
+
noXTrefFoundMessage.innerHTML = 'No xref found.';
|
|
227
|
+
element.parentNode.insertBefore(noXTrefFoundMessage, element.nextSibling);
|
|
228
|
+
|
|
229
|
+
return
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
// To be used in the future
|
|
233
|
+
const commitHashShort = match.commitHash && match.commitHash ? match.commitHash.substring(0, 7) : 'No hash';
|
|
234
|
+
|
|
235
|
+
// Comment out all UI elements except tooltip
|
|
236
|
+
|
|
237
|
+
// Diff of the latest commit hash of a term file and the referenced commit hash
|
|
238
|
+
|
|
239
|
+
// Button that links to GitHub comparison between referenced commit and current main branch
|
|
240
|
+
// Shows the difference between the referenced version and latest version on GitHub
|
|
241
|
+
|
|
242
|
+
const diff = document.createElement('a');
|
|
243
|
+
diff.href = 'https://github.com/' + match.owner + '/' + match.repo + '/compare/' + match.commitHash + '../main';
|
|
244
|
+
diff.target = '_blank';
|
|
245
|
+
diff.rel = 'noopener noreferrer';
|
|
246
|
+
diff.classList.add('diff', 'xref-info-links', 'btn');
|
|
247
|
+
diff.innerHTML = '<svg icon><use xlink:href="#svg-github"></use></svg> Xref < > <svg icon><use xlink:href="#svg-github"></use></svg> Now';
|
|
248
|
+
diff.title = 'A Diff between the current commit hash of the definition and the commit hash referenced when the link was created.';
|
|
249
|
+
element.parentNode.insertBefore(diff, element.nextSibling);
|
|
250
|
+
|
|
251
|
+
// Latest version of a term-file
|
|
252
|
+
|
|
253
|
+
// Button that links to the latest version of the term file on GitHub
|
|
254
|
+
// Takes the user to the most current version in the repository
|
|
255
|
+
|
|
256
|
+
const latestVersion = document.createElement('a');
|
|
257
|
+
latestVersion.href = 'https://github.com/' + match.owner + '/' + match.repo + '/blob/main/' + match.terms_dir + '/' + match.term.replace(/ /g, '-').toLowerCase() + '.md';
|
|
258
|
+
latestVersion.target = '_blank';
|
|
259
|
+
latestVersion.rel = 'noopener noreferrer';
|
|
260
|
+
latestVersion.classList.add('latest-version', 'xref-info-links', 'btn');
|
|
261
|
+
latestVersion.innerHTML = '<svg icon><use xlink:href="#svg-github"></use></svg> Now';
|
|
262
|
+
latestVersion.title = 'Go to the repo page of the definition‘s latest version.';
|
|
263
|
+
diff.parentNode.insertBefore(latestVersion, element.nextSibling);
|
|
264
|
+
|
|
265
|
+
// Exact commit hash at the time of referencing the file
|
|
266
|
+
|
|
267
|
+
// Button that links to the exact commit version of the term file referenced in the document
|
|
268
|
+
// Shows the historical version that was used when creating the reference
|
|
269
|
+
|
|
270
|
+
const exactCommitHash = document.createElement('a');
|
|
271
|
+
exactCommitHash.href = 'https://github.com/' + match.owner + '/' + match.repo + '/blob/' + match.commitHash + '/' + match.terms_dir + '/' + match.term.replace(/ /g, '-').toLowerCase() + '.md';
|
|
272
|
+
exactCommitHash.target = '_blank';
|
|
273
|
+
exactCommitHash.rel = 'noopener noreferrer';
|
|
274
|
+
exactCommitHash.classList.add('exact-commit-hash', 'xref-info-links', 'btn');
|
|
275
|
+
exactCommitHash.innerHTML = '<svg icon><use xlink:href="#svg-github"></use></svg> Xref';
|
|
276
|
+
exactCommitHash.title = 'Go to the repo page of the definition‘s version referenced when the link was created.';
|
|
277
|
+
latestVersion.parentNode.insertBefore(exactCommitHash, element.nextSibling);
|
|
278
|
+
|
|
279
|
+
// Diff of the latest version and the referenced version in a modal
|
|
280
|
+
|
|
281
|
+
// Button that opens a modal showing the diff between referenced version and latest version
|
|
282
|
+
// Displays changes inline within the current page context
|
|
283
|
+
|
|
284
|
+
const showDiffModal = document.createElement('button');
|
|
285
|
+
showDiffModal.classList.add('show-diff-modal', 'xref-info-links', 'btn');
|
|
286
|
+
showDiffModal.innerHTML = 'Xref < > <svg icon><use xlink:href="#svg-github"></use></svg> Now';
|
|
287
|
+
showDiffModal.title = 'Show diff between the latest version and the referenced version';
|
|
288
|
+
latestVersion.parentNode.insertBefore(showDiffModal, element.nextSibling);
|
|
289
|
+
showDiffModal.addEventListener('click', function (event) {
|
|
290
|
+
event.preventDefault();
|
|
291
|
+
fetchGitHubContent(savedToken, match);
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
// The stored version of the term-file
|
|
295
|
+
// Button that opens a modal showing only the locally stored version of the term
|
|
296
|
+
// Displays the exact content that was stored when the reference was created
|
|
297
|
+
|
|
298
|
+
const localStoredTerm = document.createElement('button');
|
|
299
|
+
localStoredTerm.classList.add('show-diff-modal', 'xref-info-links', 'btn');
|
|
300
|
+
localStoredTerm.innerHTML = 'Xref';
|
|
301
|
+
localStoredTerm.title = 'Show the stored version of the term-file';
|
|
302
|
+
showDiffModal.parentNode.insertBefore(localStoredTerm, element.nextSibling);
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
// Replace all occurrences of [[def: ]] with ''
|
|
307
|
+
const defRegex = /\[\[def: ([^\]]+)\]\]/g;
|
|
308
|
+
match.content = match.content.replace(defRegex, '');
|
|
309
|
+
|
|
310
|
+
// const content = md.render(match.content);
|
|
311
|
+
const content = match.content;
|
|
312
|
+
localStoredTerm.addEventListener('click', function (event) {
|
|
313
|
+
event.preventDefault();
|
|
314
|
+
showModal(`
|
|
315
|
+
<h1>Term definition (local snapshot)</h1>
|
|
316
|
+
<table>
|
|
317
|
+
<tr>
|
|
318
|
+
<th>Commit hash</th>
|
|
319
|
+
<td>${match.commitHash}</td>
|
|
320
|
+
</tr>
|
|
321
|
+
<tr>
|
|
322
|
+
<th>Content</th>
|
|
323
|
+
<td>${content}</td>
|
|
324
|
+
</tr>
|
|
325
|
+
</table>
|
|
326
|
+
`);
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
const div = document.createElement('div');
|
|
330
|
+
div.classList.add('local-snapshot-xref-term');
|
|
331
|
+
div.classList.add('transcluded-xref-term');
|
|
332
|
+
div.innerHTML = `<p class='transclusion-heading'>Snapshot</p><p>Commit Hash: ${match.commitHash}</p> ${content}`;
|
|
333
|
+
element.parentNode.insertBefore(div, element.nextSibling);
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
// Tooltip functionality
|
|
337
|
+
delegateEvent('pointerover', '.x-term-reference', (e, anchor) => {
|
|
338
|
+
// Get the matching term from your data
|
|
339
|
+
const href = anchor.getAttribute('data-local-href');
|
|
340
|
+
const splitHref = href.split(':');
|
|
341
|
+
|
|
342
|
+
// Find matching term in allXTrefs
|
|
343
|
+
const match = allXTrefs.xtrefs.find(m =>
|
|
344
|
+
m.externalSpec === splitHref[1] &&
|
|
345
|
+
m.term.toLowerCase() === splitHref[2].toLowerCase());
|
|
346
|
+
|
|
347
|
+
if (!match || tipMap.has(anchor)) return;
|
|
348
|
+
|
|
349
|
+
// Create tooltip with content
|
|
350
|
+
let tip = {
|
|
351
|
+
// content: md.render(match.content.replace(/\[\[def: ([^\]]+)\]\]/g, '')),
|
|
352
|
+
// content: `<dl>` + md.render(match.content.replace(/\[\[def: ([^\]]+)\]\]/g, '')) + `</dl>`,
|
|
353
|
+
content: match.content.replace(/\[\[def: ([^\]]+)\]\]/g, ''),
|
|
354
|
+
allowHTML: true,
|
|
355
|
+
inlinePositioning: true
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
if (tip.content) tipMap.set(anchor, tippy(anchor, tip));
|
|
359
|
+
}, { passive: true });
|
|
360
|
+
|
|
361
|
+
// Keep tooltip functionality active, but comment out real-time content fetch
|
|
362
|
+
|
|
363
|
+
insertGitHubTermRealTime(match, element);
|
|
364
|
+
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
document.addEventListener("DOMContentLoaded", function () {
|
|
371
|
+
fetchCommitHashes();
|
|
372
|
+
});
|
|
@@ -25,10 +25,12 @@
|
|
|
25
25
|
* @since 2024-06-09
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
|
|
30
30
|
function fetchCommitHashes() {
|
|
31
31
|
|
|
32
|
+
let tipMap = new WeakMap();
|
|
33
|
+
|
|
32
34
|
async function insertGitHubTermRealTime(match, element) {
|
|
33
35
|
const div = document.createElement('div');
|
|
34
36
|
div.classList.add('fetched-xref-term');
|
|
@@ -88,7 +90,13 @@ function fetchCommitHashes() {
|
|
|
88
90
|
notyf.error('GitHub API rate limit exceeded. See <a target="_blank" rel="noopener" href="https://blockchainbird.github.io/spec-up-t-website/docs/getting-started/github-token">documentation</a> for more info.');
|
|
89
91
|
}, 3000); // Delay in milliseconds
|
|
90
92
|
|
|
91
|
-
|
|
93
|
+
/**
|
|
94
|
+
* Fetches the content of a term file from GitHub using the GitHub API.
|
|
95
|
+
* Compares the fetched content with the locally stored version and displays the diff in a modal.
|
|
96
|
+
*
|
|
97
|
+
* @param {string} savedToken - GitHub API token for authentication
|
|
98
|
+
* @param {Object} match - The matched term object containing repository and term information
|
|
99
|
+
*/
|
|
92
100
|
function fetchGitHubContent(savedToken, match) {
|
|
93
101
|
// Create a headers object with the Authorization header if a GitHub API token is set
|
|
94
102
|
const headers = {};
|
|
@@ -209,6 +217,10 @@ function fetchCommitHashes() {
|
|
|
209
217
|
|
|
210
218
|
// If no commit hash is found, display a message and return
|
|
211
219
|
if (!match.commitHash) {
|
|
220
|
+
/**
|
|
221
|
+
* Error message element shown when no cross-reference is found
|
|
222
|
+
* Displayed directly after the term reference element
|
|
223
|
+
*/
|
|
212
224
|
const noXTrefFoundMessage = document.createElement('span');
|
|
213
225
|
noXTrefFoundMessage.classList.add('no-xref-found-message');
|
|
214
226
|
noXTrefFoundMessage.innerHTML = 'No xref found.';
|
|
@@ -220,7 +232,13 @@ function fetchCommitHashes() {
|
|
|
220
232
|
// To be used in the future
|
|
221
233
|
const commitHashShort = match.commitHash && match.commitHash ? match.commitHash.substring(0, 7) : 'No hash';
|
|
222
234
|
|
|
235
|
+
// Comment out all UI elements except tooltip
|
|
236
|
+
|
|
223
237
|
// Diff of the latest commit hash of a term file and the referenced commit hash
|
|
238
|
+
|
|
239
|
+
// Button that links to GitHub comparison between referenced commit and current main branch
|
|
240
|
+
// Shows the difference between the referenced version and latest version on GitHub
|
|
241
|
+
|
|
224
242
|
const diff = document.createElement('a');
|
|
225
243
|
diff.href = 'https://github.com/' + match.owner + '/' + match.repo + '/compare/' + match.commitHash + '../main';
|
|
226
244
|
diff.target = '_blank';
|
|
@@ -231,6 +249,10 @@ function fetchCommitHashes() {
|
|
|
231
249
|
element.parentNode.insertBefore(diff, element.nextSibling);
|
|
232
250
|
|
|
233
251
|
// Latest version of a term-file
|
|
252
|
+
|
|
253
|
+
// Button that links to the latest version of the term file on GitHub
|
|
254
|
+
// Takes the user to the most current version in the repository
|
|
255
|
+
|
|
234
256
|
const latestVersion = document.createElement('a');
|
|
235
257
|
latestVersion.href = 'https://github.com/' + match.owner + '/' + match.repo + '/blob/main/' + match.terms_dir + '/' + match.term.replace(/ /g, '-').toLowerCase() + '.md';
|
|
236
258
|
latestVersion.target = '_blank';
|
|
@@ -241,6 +263,10 @@ function fetchCommitHashes() {
|
|
|
241
263
|
diff.parentNode.insertBefore(latestVersion, element.nextSibling);
|
|
242
264
|
|
|
243
265
|
// Exact commit hash at the time of referencing the file
|
|
266
|
+
|
|
267
|
+
// Button that links to the exact commit version of the term file referenced in the document
|
|
268
|
+
// Shows the historical version that was used when creating the reference
|
|
269
|
+
|
|
244
270
|
const exactCommitHash = document.createElement('a');
|
|
245
271
|
exactCommitHash.href = 'https://github.com/' + match.owner + '/' + match.repo + '/blob/' + match.commitHash + '/' + match.terms_dir + '/' + match.term.replace(/ /g, '-').toLowerCase() + '.md';
|
|
246
272
|
exactCommitHash.target = '_blank';
|
|
@@ -251,6 +277,10 @@ function fetchCommitHashes() {
|
|
|
251
277
|
latestVersion.parentNode.insertBefore(exactCommitHash, element.nextSibling);
|
|
252
278
|
|
|
253
279
|
// Diff of the latest version and the referenced version in a modal
|
|
280
|
+
|
|
281
|
+
// Button that opens a modal showing the diff between referenced version and latest version
|
|
282
|
+
// Displays changes inline within the current page context
|
|
283
|
+
|
|
254
284
|
const showDiffModal = document.createElement('button');
|
|
255
285
|
showDiffModal.classList.add('show-diff-modal', 'xref-info-links', 'btn');
|
|
256
286
|
showDiffModal.innerHTML = 'Xref < > <svg icon><use xlink:href="#svg-github"></use></svg> Now';
|
|
@@ -262,19 +292,23 @@ function fetchCommitHashes() {
|
|
|
262
292
|
});
|
|
263
293
|
|
|
264
294
|
// The stored version of the term-file
|
|
295
|
+
// Button that opens a modal showing only the locally stored version of the term
|
|
296
|
+
// Displays the exact content that was stored when the reference was created
|
|
297
|
+
|
|
265
298
|
const localStoredTerm = document.createElement('button');
|
|
266
299
|
localStoredTerm.classList.add('show-diff-modal', 'xref-info-links', 'btn');
|
|
267
300
|
localStoredTerm.innerHTML = 'Xref';
|
|
268
301
|
localStoredTerm.title = 'Show the stored version of the term-file';
|
|
269
302
|
showDiffModal.parentNode.insertBefore(localStoredTerm, element.nextSibling);
|
|
270
|
-
|
|
271
|
-
|
|
303
|
+
|
|
304
|
+
|
|
272
305
|
|
|
273
306
|
// Replace all occurrences of [[def: ]] with ''
|
|
274
307
|
const defRegex = /\[\[def: ([^\]]+)\]\]/g;
|
|
275
308
|
match.content = match.content.replace(defRegex, '');
|
|
276
309
|
|
|
277
|
-
const content = md.render(match.content);
|
|
310
|
+
// const content = md.render(match.content);
|
|
311
|
+
const content = match.content;
|
|
278
312
|
localStoredTerm.addEventListener('click', function (event) {
|
|
279
313
|
event.preventDefault();
|
|
280
314
|
showModal(`
|
|
@@ -297,9 +331,35 @@ function fetchCommitHashes() {
|
|
|
297
331
|
div.classList.add('transcluded-xref-term');
|
|
298
332
|
div.innerHTML = `<p class='transclusion-heading'>Snapshot</p><p>Commit Hash: ${match.commitHash}</p> ${content}`;
|
|
299
333
|
element.parentNode.insertBefore(div, element.nextSibling);
|
|
300
|
-
|
|
301
|
-
|
|
334
|
+
|
|
302
335
|
insertGitHubTermRealTime(match, element);
|
|
336
|
+
|
|
337
|
+
// Tooltip functionality
|
|
338
|
+
delegateEvent('pointerover', '.x-term-reference', (e, anchor) => {
|
|
339
|
+
// Get the matching term from your data
|
|
340
|
+
const href = anchor.getAttribute('data-local-href');
|
|
341
|
+
const splitHref = href.split(':');
|
|
342
|
+
|
|
343
|
+
// Find matching term in allXTrefs
|
|
344
|
+
const match = allXTrefs.xtrefs.find(m =>
|
|
345
|
+
m.externalSpec === splitHref[1] &&
|
|
346
|
+
m.term.toLowerCase() === splitHref[2].toLowerCase());
|
|
347
|
+
|
|
348
|
+
if (!match || tipMap.has(anchor)) return;
|
|
349
|
+
|
|
350
|
+
// Create tooltip with content
|
|
351
|
+
let tip = {
|
|
352
|
+
// content: md.render(match.content.replace(/\[\[def: ([^\]]+)\]\]/g, '')),
|
|
353
|
+
// content: `<dl>` + md.render(match.content.replace(/\[\[def: ([^\]]+)\]\]/g, '')) + `</dl>`,
|
|
354
|
+
content: match.content.replace(/\[\[def: ([^\]]+)\]\]/g, ''),
|
|
355
|
+
allowHTML: true,
|
|
356
|
+
inlinePositioning: true
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
if (tip.content) tipMap.set(anchor, tippy(anchor, tip));
|
|
360
|
+
}, { passive: true });
|
|
361
|
+
|
|
362
|
+
|
|
303
363
|
}
|
|
304
364
|
});
|
|
305
365
|
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/* PrismJS 1.29.0
|
|
2
|
+
To update this file, download PrismJS from https://prismjs.com/download.html and use this url, that includes only the languages and plugins you need:
|
|
3
|
+
|
|
4
|
+
https://prismjs.com/download.html#themes=prism-tomorrow&languages=markup+css+clike+javascript+abnf+diff+git+http+js-extras+json+json5+js-templates+regex+yaml&plugins=line-numbers+highlight-keywords
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
var _self = "undefined" != typeof window ? window : "undefined" != typeof WorkerGlobalScope && self instanceof WorkerGlobalScope ? self : {}, Prism = function (e) { var n = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i, t = 0, r = {}, a = { manual: e.Prism && e.Prism.manual, disableWorkerMessageHandler: e.Prism && e.Prism.disableWorkerMessageHandler, util: { encode: function e(n) { return n instanceof i ? new i(n.type, e(n.content), n.alias) : Array.isArray(n) ? n.map(e) : n.replace(/&/g, "&").replace(/</g, "<").replace(/\u00a0/g, " ") }, type: function (e) { return Object.prototype.toString.call(e).slice(8, -1) }, objId: function (e) { return e.__id || Object.defineProperty(e, "__id", { value: ++t }), e.__id }, clone: function e(n, t) { var r, i; switch (t = t || {}, a.util.type(n)) { case "Object": if (i = a.util.objId(n), t[i]) return t[i]; for (var l in r = {}, t[i] = r, n) n.hasOwnProperty(l) && (r[l] = e(n[l], t)); return r; case "Array": return i = a.util.objId(n), t[i] ? t[i] : (r = [], t[i] = r, n.forEach((function (n, a) { r[a] = e(n, t) })), r); default: return n } }, getLanguage: function (e) { for (; e;) { var t = n.exec(e.className); if (t) return t[1].toLowerCase(); e = e.parentElement } return "none" }, setLanguage: function (e, t) { e.className = e.className.replace(RegExp(n, "gi"), ""), e.classList.add("language-" + t) }, currentScript: function () { if ("undefined" == typeof document) return null; if ("currentScript" in document) return document.currentScript; try { throw new Error } catch (r) { var e = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(r.stack) || [])[1]; if (e) { var n = document.getElementsByTagName("script"); for (var t in n) if (n[t].src == e) return n[t] } return null } }, isActive: function (e, n, t) { for (var r = "no-" + n; e;) { var a = e.classList; if (a.contains(n)) return !0; if (a.contains(r)) return !1; e = e.parentElement } return !!t } }, languages: { plain: r, plaintext: r, text: r, txt: r, extend: function (e, n) { var t = a.util.clone(a.languages[e]); for (var r in n) t[r] = n[r]; return t }, insertBefore: function (e, n, t, r) { var i = (r = r || a.languages)[e], l = {}; for (var o in i) if (i.hasOwnProperty(o)) { if (o == n) for (var s in t) t.hasOwnProperty(s) && (l[s] = t[s]); t.hasOwnProperty(o) || (l[o] = i[o]) } var u = r[e]; return r[e] = l, a.languages.DFS(a.languages, (function (n, t) { t === u && n != e && (this[n] = l) })), l }, DFS: function e(n, t, r, i) { i = i || {}; var l = a.util.objId; for (var o in n) if (n.hasOwnProperty(o)) { t.call(n, o, n[o], r || o); var s = n[o], u = a.util.type(s); "Object" !== u || i[l(s)] ? "Array" !== u || i[l(s)] || (i[l(s)] = !0, e(s, t, o, i)) : (i[l(s)] = !0, e(s, t, null, i)) } } }, plugins: {}, highlightAll: function (e, n) { a.highlightAllUnder(document, e, n) }, highlightAllUnder: function (e, n, t) { var r = { callback: t, container: e, selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code' }; a.hooks.run("before-highlightall", r), r.elements = Array.prototype.slice.apply(r.container.querySelectorAll(r.selector)), a.hooks.run("before-all-elements-highlight", r); for (var i, l = 0; i = r.elements[l++];)a.highlightElement(i, !0 === n, r.callback) }, highlightElement: function (n, t, r) { var i = a.util.getLanguage(n), l = a.languages[i]; a.util.setLanguage(n, i); var o = n.parentElement; o && "pre" === o.nodeName.toLowerCase() && a.util.setLanguage(o, i); var s = { element: n, language: i, grammar: l, code: n.textContent }; function u(e) { s.highlightedCode = e, a.hooks.run("before-insert", s), s.element.innerHTML = s.highlightedCode, a.hooks.run("after-highlight", s), a.hooks.run("complete", s), r && r.call(s.element) } if (a.hooks.run("before-sanity-check", s), (o = s.element.parentElement) && "pre" === o.nodeName.toLowerCase() && !o.hasAttribute("tabindex") && o.setAttribute("tabindex", "0"), !s.code) return a.hooks.run("complete", s), void (r && r.call(s.element)); if (a.hooks.run("before-highlight", s), s.grammar) if (t && e.Worker) { var c = new Worker(a.filename); c.onmessage = function (e) { u(e.data) }, c.postMessage(JSON.stringify({ language: s.language, code: s.code, immediateClose: !0 })) } else u(a.highlight(s.code, s.grammar, s.language)); else u(a.util.encode(s.code)) }, highlight: function (e, n, t) { var r = { code: e, grammar: n, language: t }; if (a.hooks.run("before-tokenize", r), !r.grammar) throw new Error('The language "' + r.language + '" has no grammar.'); return r.tokens = a.tokenize(r.code, r.grammar), a.hooks.run("after-tokenize", r), i.stringify(a.util.encode(r.tokens), r.language) }, tokenize: function (e, n) { var t = n.rest; if (t) { for (var r in t) n[r] = t[r]; delete n.rest } var a = new s; return u(a, a.head, e), o(e, a, n, a.head, 0), function (e) { for (var n = [], t = e.head.next; t !== e.tail;)n.push(t.value), t = t.next; return n }(a) }, hooks: { all: {}, add: function (e, n) { var t = a.hooks.all; t[e] = t[e] || [], t[e].push(n) }, run: function (e, n) { var t = a.hooks.all[e]; if (t && t.length) for (var r, i = 0; r = t[i++];)r(n) } }, Token: i }; function i(e, n, t, r) { this.type = e, this.content = n, this.alias = t, this.length = 0 | (r || "").length } function l(e, n, t, r) { e.lastIndex = n; var a = e.exec(t); if (a && r && a[1]) { var i = a[1].length; a.index += i, a[0] = a[0].slice(i) } return a } function o(e, n, t, r, s, g) { for (var f in t) if (t.hasOwnProperty(f) && t[f]) { var h = t[f]; h = Array.isArray(h) ? h : [h]; for (var d = 0; d < h.length; ++d) { if (g && g.cause == f + "," + d) return; var v = h[d], p = v.inside, m = !!v.lookbehind, y = !!v.greedy, k = v.alias; if (y && !v.pattern.global) { var x = v.pattern.toString().match(/[imsuy]*$/)[0]; v.pattern = RegExp(v.pattern.source, x + "g") } for (var b = v.pattern || v, w = r.next, A = s; w !== n.tail && !(g && A >= g.reach); A += w.value.length, w = w.next) { var E = w.value; if (n.length > e.length) return; if (!(E instanceof i)) { var P, L = 1; if (y) { if (!(P = l(b, A, e, m)) || P.index >= e.length) break; var S = P.index, O = P.index + P[0].length, j = A; for (j += w.value.length; S >= j;)j += (w = w.next).value.length; if (A = j -= w.value.length, w.value instanceof i) continue; for (var C = w; C !== n.tail && (j < O || "string" == typeof C.value); C = C.next)L++, j += C.value.length; L--, E = e.slice(A, j), P.index -= A } else if (!(P = l(b, 0, E, m))) continue; S = P.index; var N = P[0], _ = E.slice(0, S), M = E.slice(S + N.length), W = A + E.length; g && W > g.reach && (g.reach = W); var z = w.prev; if (_ && (z = u(n, z, _), A += _.length), c(n, z, L), w = u(n, z, new i(f, p ? a.tokenize(N, p) : N, k, N)), M && u(n, w, M), L > 1) { var I = { cause: f + "," + d, reach: W }; o(e, n, t, w.prev, A, I), g && I.reach > g.reach && (g.reach = I.reach) } } } } } } function s() { var e = { value: null, prev: null, next: null }, n = { value: null, prev: e, next: null }; e.next = n, this.head = e, this.tail = n, this.length = 0 } function u(e, n, t) { var r = n.next, a = { value: t, prev: n, next: r }; return n.next = a, r.prev = a, e.length++, a } function c(e, n, t) { for (var r = n.next, a = 0; a < t && r !== e.tail; a++)r = r.next; n.next = r, r.prev = n, e.length -= a } if (e.Prism = a, i.stringify = function e(n, t) { if ("string" == typeof n) return n; if (Array.isArray(n)) { var r = ""; return n.forEach((function (n) { r += e(n, t) })), r } var i = { type: n.type, content: e(n.content, t), tag: "span", classes: ["token", n.type], attributes: {}, language: t }, l = n.alias; l && (Array.isArray(l) ? Array.prototype.push.apply(i.classes, l) : i.classes.push(l)), a.hooks.run("wrap", i); var o = ""; for (var s in i.attributes) o += " " + s + '="' + (i.attributes[s] || "").replace(/"/g, """) + '"'; return "<" + i.tag + ' class="' + i.classes.join(" ") + '"' + o + ">" + i.content + "</" + i.tag + ">" }, !e.document) return e.addEventListener ? (a.disableWorkerMessageHandler || e.addEventListener("message", (function (n) { var t = JSON.parse(n.data), r = t.language, i = t.code, l = t.immediateClose; e.postMessage(a.highlight(i, a.languages[r], r)), l && e.close() }), !1), a) : a; var g = a.util.currentScript(); function f() { a.manual || a.highlightAll() } if (g && (a.filename = g.src, g.hasAttribute("data-manual") && (a.manual = !0)), !a.manual) { var h = document.readyState; "loading" === h || "interactive" === h && g && g.defer ? document.addEventListener("DOMContentLoaded", f) : window.requestAnimationFrame ? window.requestAnimationFrame(f) : window.setTimeout(f, 16) } return a }(_self); "undefined" != typeof module && module.exports && (module.exports = Prism), "undefined" != typeof global && (global.Prism = Prism);
|
|
8
|
+
Prism.languages.markup = { comment: { pattern: /<!--(?:(?!<!--)[\s\S])*?-->/, greedy: !0 }, prolog: { pattern: /<\?[\s\S]+?\?>/, greedy: !0 }, doctype: { pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i, greedy: !0, inside: { "internal-subset": { pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/, lookbehind: !0, greedy: !0, inside: null }, string: { pattern: /"[^"]*"|'[^']*'/, greedy: !0 }, punctuation: /^<!|>$|[[\]]/, "doctype-tag": /^DOCTYPE/i, name: /[^\s<>'"]+/ } }, cdata: { pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i, greedy: !0 }, tag: { pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/, greedy: !0, inside: { tag: { pattern: /^<\/?[^\s>\/]+/, inside: { punctuation: /^<\/?/, namespace: /^[^\s>\/:]+:/ } }, "special-attr": [], "attr-value": { pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/, inside: { punctuation: [{ pattern: /^=/, alias: "attr-equals" }, { pattern: /^(\s*)["']|["']$/, lookbehind: !0 }] } }, punctuation: /\/?>/, "attr-name": { pattern: /[^\s>\/]+/, inside: { namespace: /^[^\s>\/:]+:/ } } } }, entity: [{ pattern: /&[\da-z]{1,8};/i, alias: "named-entity" }, /&#x?[\da-f]{1,8};/i] }, Prism.languages.markup.tag.inside["attr-value"].inside.entity = Prism.languages.markup.entity, Prism.languages.markup.doctype.inside["internal-subset"].inside = Prism.languages.markup, Prism.hooks.add("wrap", (function (a) { "entity" === a.type && (a.attributes.title = a.content.replace(/&/, "&")) })), Object.defineProperty(Prism.languages.markup.tag, "addInlined", { value: function (a, e) { var s = {}; s["language-" + e] = { pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i, lookbehind: !0, inside: Prism.languages[e] }, s.cdata = /^<!\[CDATA\[|\]\]>$/i; var t = { "included-cdata": { pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i, inside: s } }; t["language-" + e] = { pattern: /[\s\S]+/, inside: Prism.languages[e] }; var n = {}; n[a] = { pattern: RegExp("(<__[^>]*>)(?:<!\\[CDATA\\[(?:[^\\]]|\\](?!\\]>))*\\]\\]>|(?!<!\\[CDATA\\[)[^])*?(?=</__>)".replace(/__/g, (function () { return a })), "i"), lookbehind: !0, greedy: !0, inside: t }, Prism.languages.insertBefore("markup", "cdata", n) } }), Object.defineProperty(Prism.languages.markup.tag, "addAttribute", { value: function (a, e) { Prism.languages.markup.tag.inside["special-attr"].push({ pattern: RegExp("(^|[\"'\\s])(?:" + a + ")\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^\\s'\">=]+(?=[\\s>]))", "i"), lookbehind: !0, inside: { "attr-name": /^[^\s=]+/, "attr-value": { pattern: /=[\s\S]+/, inside: { value: { pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/, lookbehind: !0, alias: [e, "language-" + e], inside: Prism.languages[e] }, punctuation: [{ pattern: /^=/, alias: "attr-equals" }, /"|'/] } } } }) } }), Prism.languages.html = Prism.languages.markup, Prism.languages.mathml = Prism.languages.markup, Prism.languages.svg = Prism.languages.markup, Prism.languages.xml = Prism.languages.extend("markup", {}), Prism.languages.ssml = Prism.languages.xml, Prism.languages.atom = Prism.languages.xml, Prism.languages.rss = Prism.languages.xml;
|
|
9
|
+
!function (s) { var e = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/; s.languages.css = { comment: /\/\*[\s\S]*?\*\//, atrule: { pattern: RegExp("@[\\w-](?:[^;{\\s\"']|\\s+(?!\\s)|" + e.source + ")*?(?:;|(?=\\s*\\{))"), inside: { rule: /^@[\w-]+/, "selector-function-argument": { pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/, lookbehind: !0, alias: "selector" }, keyword: { pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/, lookbehind: !0 } } }, url: { pattern: RegExp("\\burl\\((?:" + e.source + "|(?:[^\\\\\r\n()\"']|\\\\[^])*)\\)", "i"), greedy: !0, inside: { function: /^url/i, punctuation: /^\(|\)$/, string: { pattern: RegExp("^" + e.source + "$"), alias: "url" } } }, selector: { pattern: RegExp("(^|[{}\\s])[^{}\\s](?:[^{};\"'\\s]|\\s+(?![\\s{])|" + e.source + ")*(?=\\s*\\{)"), lookbehind: !0 }, string: { pattern: e, greedy: !0 }, property: { pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i, lookbehind: !0 }, important: /!important\b/i, function: { pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i, lookbehind: !0 }, punctuation: /[(){};:,]/ }, s.languages.css.atrule.inside.rest = s.languages.css; var t = s.languages.markup; t && (t.tag.addInlined("style", "css"), t.tag.addAttribute("style", "css")) }(Prism);
|
|
10
|
+
Prism.languages.clike = { comment: [{ pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/, lookbehind: !0, greedy: !0 }, { pattern: /(^|[^\\:])\/\/.*/, lookbehind: !0, greedy: !0 }], string: { pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, greedy: !0 }, "class-name": { pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i, lookbehind: !0, inside: { punctuation: /[.\\]/ } }, keyword: /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/, boolean: /\b(?:false|true)\b/, function: /\b\w+(?=\()/, number: /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i, operator: /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/, punctuation: /[{}[\];(),.:]/ };
|
|
11
|
+
Prism.languages.javascript = Prism.languages.extend("clike", { "class-name": [Prism.languages.clike["class-name"], { pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/, lookbehind: !0 }], keyword: [{ pattern: /((?:^|\})\s*)catch\b/, lookbehind: !0 }, { 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/, lookbehind: !0 }], function: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/, number: { pattern: RegExp("(^|[^\\w$])(?:NaN|Infinity|0[bB][01]+(?:_[01]+)*n?|0[oO][0-7]+(?:_[0-7]+)*n?|0[xX][\\dA-Fa-f]+(?:_[\\dA-Fa-f]+)*n?|\\d+(?:_\\d+)*n|(?:\\d+(?:_\\d+)*(?:\\.(?:\\d+(?:_\\d+)*)?)?|\\.\\d+(?:_\\d+)*)(?:[Ee][+-]?\\d+(?:_\\d+)*)?)(?![\\w$])"), lookbehind: !0 }, operator: /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/ }), Prism.languages.javascript["class-name"][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/, Prism.languages.insertBefore("javascript", "keyword", { regex: { pattern: RegExp("((?:^|[^$\\w\\xA0-\\uFFFF.\"'\\])\\s]|\\b(?:return|yield))\\s*)/(?:(?:\\[(?:[^\\]\\\\\r\n]|\\\\.)*\\]|\\\\.|[^/\\\\\\[\r\n])+/[dgimyus]{0,7}|(?:\\[(?:[^[\\]\\\\\r\n]|\\\\.|\\[(?:[^[\\]\\\\\r\n]|\\\\.|\\[(?:[^[\\]\\\\\r\n]|\\\\.)*\\])*\\])*\\]|\\\\.|[^/\\\\\\[\r\n])+/[dgimyus]{0,7}v[dgimyus]{0,7})(?=(?:\\s|/\\*(?:[^*]|\\*(?!/))*\\*/)*(?:$|[\r\n,.;:})\\]]|//))"), lookbehind: !0, greedy: !0, inside: { "regex-source": { pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/, lookbehind: !0, alias: "language-regex", inside: Prism.languages.regex }, "regex-delimiter": /^\/|\/$/, "regex-flags": /^[a-z]+$/ } }, "function-variable": { 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*=>))/, alias: "function" }, parameter: [{ pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/, lookbehind: !0, inside: Prism.languages.javascript }, { pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i, lookbehind: !0, inside: Prism.languages.javascript }, { pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/, lookbehind: !0, inside: Prism.languages.javascript }, { 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*\{)/, lookbehind: !0, inside: Prism.languages.javascript }], constant: /\b[A-Z](?:[A-Z_]|\dx?)*\b/ }), Prism.languages.insertBefore("javascript", "string", { hashbang: { pattern: /^#!.*/, greedy: !0, alias: "comment" }, "template-string": { pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/, greedy: !0, inside: { "template-punctuation": { pattern: /^`|`$/, alias: "string" }, interpolation: { pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/, lookbehind: !0, inside: { "interpolation-punctuation": { pattern: /^\$\{|\}$/, alias: "punctuation" }, rest: Prism.languages.javascript } }, string: /[\s\S]+/ } }, "string-property": { pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m, lookbehind: !0, greedy: !0, alias: "property" } }), Prism.languages.insertBefore("javascript", "operator", { "literal-property": { pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m, lookbehind: !0, alias: "property" } }), Prism.languages.markup && (Prism.languages.markup.tag.addInlined("script", "javascript"), Prism.languages.markup.tag.addAttribute("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)", "javascript")), Prism.languages.js = Prism.languages.javascript;
|
|
12
|
+
!function (n) { var i = "(?:ALPHA|BIT|CHAR|CR|CRLF|CTL|DIGIT|DQUOTE|HEXDIG|HTAB|LF|LWSP|OCTET|SP|VCHAR|WSP)"; n.languages.abnf = { comment: /;.*/, string: { pattern: /(?:%[is])?"[^"\n\r]*"/, greedy: !0, inside: { punctuation: /^%[is]/ } }, range: { pattern: /%(?:b[01]+-[01]+|d\d+-\d+|x[A-F\d]+-[A-F\d]+)/i, alias: "number" }, terminal: { pattern: /%(?:b[01]+(?:\.[01]+)*|d\d+(?:\.\d+)*|x[A-F\d]+(?:\.[A-F\d]+)*)/i, alias: "number" }, repetition: { pattern: /(^|[^\w-])(?:\d*\*\d*|\d+)/, lookbehind: !0, alias: "operator" }, definition: { pattern: /(^[ \t]*)(?:[a-z][\w-]*|<[^<>\r\n]*>)(?=\s*=)/m, lookbehind: !0, alias: "keyword", inside: { punctuation: /<|>/ } }, "core-rule": { pattern: RegExp("(?:(^|[^<\\w-])" + i + "|<" + i + ">)(?![\\w-])", "i"), lookbehind: !0, alias: ["rule", "constant"], inside: { punctuation: /<|>/ } }, rule: { pattern: /(^|[^<\w-])[a-z][\w-]*|<[^<>\r\n]*>/i, lookbehind: !0, inside: { punctuation: /<|>/ } }, operator: /=\/?|\//, punctuation: /[()\[\]]/ } }(Prism);
|
|
13
|
+
!function (e) { e.languages.diff = { coord: [/^(?:\*{3}|-{3}|\+{3}).*$/m, /^@@.*@@$/m, /^\d.*$/m] }; var n = { "deleted-sign": "-", "deleted-arrow": "<", "inserted-sign": "+", "inserted-arrow": ">", unchanged: " ", diff: "!" }; Object.keys(n).forEach((function (a) { var i = n[a], r = []; /^\w+$/.test(a) || r.push(/\w+/.exec(a)[0]), "diff" === a && r.push("bold"), e.languages.diff[a] = { pattern: RegExp("^(?:[" + i + "].*(?:\r\n?|\n|(?![\\s\\S])))+", "m"), alias: r, inside: { line: { pattern: /(.)(?=[\s\S]).*(?:\r\n?|\n)?/, lookbehind: !0 }, prefix: { pattern: /[\s\S]/, alias: /\w+/.exec(a)[0] } } } })), Object.defineProperty(e.languages.diff, "PREFIXES", { value: n }) }(Prism);
|
|
14
|
+
Prism.languages.git = { comment: /^#.*/m, deleted: /^[-–].*/m, inserted: /^\+.*/m, string: /("|')(?:\\.|(?!\1)[^\\\r\n])*\1/, command: { pattern: /^.*\$ git .*$/m, inside: { parameter: /\s--?\w+/ } }, coord: /^@@.*@@$/m, "commit-sha1": /^commit \w{40}$/m };
|
|
15
|
+
!function (t) { function a(t) { return RegExp("(^(?:" + t + "):[ \t]*(?![ \t]))[^]+", "i") } t.languages.http = { "request-line": { pattern: /^(?:CONNECT|DELETE|GET|HEAD|OPTIONS|PATCH|POST|PRI|PUT|SEARCH|TRACE)\s(?:https?:\/\/|\/)\S*\sHTTP\/[\d.]+/m, inside: { method: { pattern: /^[A-Z]+\b/, alias: "property" }, "request-target": { pattern: /^(\s)(?:https?:\/\/|\/)\S*(?=\s)/, lookbehind: !0, alias: "url", inside: t.languages.uri }, "http-version": { pattern: /^(\s)HTTP\/[\d.]+/, lookbehind: !0, alias: "property" } } }, "response-status": { pattern: /^HTTP\/[\d.]+ \d+ .+/m, inside: { "http-version": { pattern: /^HTTP\/[\d.]+/, alias: "property" }, "status-code": { pattern: /^(\s)\d+(?=\s)/, lookbehind: !0, alias: "number" }, "reason-phrase": { pattern: /^(\s).+/, lookbehind: !0, alias: "string" } } }, header: { pattern: /^[\w-]+:.+(?:(?:\r\n?|\n)[ \t].+)*/m, inside: { "header-value": [{ pattern: a("Content-Security-Policy"), lookbehind: !0, alias: ["csp", "languages-csp"], inside: t.languages.csp }, { pattern: a("Public-Key-Pins(?:-Report-Only)?"), lookbehind: !0, alias: ["hpkp", "languages-hpkp"], inside: t.languages.hpkp }, { pattern: a("Strict-Transport-Security"), lookbehind: !0, alias: ["hsts", "languages-hsts"], inside: t.languages.hsts }, { pattern: a("[^:]+"), lookbehind: !0 }], "header-name": { pattern: /^[^:]+/, alias: "keyword" }, punctuation: /^:/ } } }; var e, n = t.languages, s = { "application/javascript": n.javascript, "application/json": n.json || n.javascript, "application/xml": n.xml, "text/xml": n.xml, "text/html": n.html, "text/css": n.css, "text/plain": n.plain }, i = { "application/json": !0, "application/xml": !0 }; function r(t) { var a = t.replace(/^[a-z]+\//, ""); return "(?:" + t + "|\\w+/(?:[\\w.-]+\\+)+" + a + "(?![+\\w.-]))" } for (var p in s) if (s[p]) { e = e || {}; var l = i[p] ? r(p) : p; e[p.replace(/\//g, "-")] = { pattern: RegExp("(content-type:\\s*" + l + "(?:(?:\r\n?|\n)[\\w-].*)*(?:\r(?:\n|(?!\n))|\n))[^ \t\\w-][^]*", "i"), lookbehind: !0, inside: s[p] } } e && t.languages.insertBefore("http", "header", e) }(Prism);
|
|
16
|
+
!function (a) { function e(a, e) { return RegExp(a.replace(/<ID>/g, (function () { return "(?!\\s)[_$a-zA-Z\\xA0-\\uFFFF](?:(?!\\s)[$\\w\\xA0-\\uFFFF])*" })), e) } a.languages.insertBefore("javascript", "function-variable", { "method-variable": { pattern: RegExp("(\\.\\s*)" + a.languages.javascript["function-variable"].pattern.source), lookbehind: !0, alias: ["function-variable", "method", "function", "property-access"] } }), a.languages.insertBefore("javascript", "function", { method: { pattern: RegExp("(\\.\\s*)" + a.languages.javascript.function.source), lookbehind: !0, alias: ["function", "property-access"] } }), a.languages.insertBefore("javascript", "constant", { "known-class-name": [{ pattern: /\b(?:(?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)?Array|ArrayBuffer|BigInt|Boolean|DataView|Date|Error|Function|Intl|JSON|(?:Weak)?(?:Map|Set)|Math|Number|Object|Promise|Proxy|Reflect|RegExp|String|Symbol|WebAssembly)\b/, alias: "class-name" }, { pattern: /\b(?:[A-Z]\w*)Error\b/, alias: "class-name" }] }), a.languages.insertBefore("javascript", "keyword", { imports: { pattern: e("(\\bimport\\b\\s*)(?:<ID>(?:\\s*,\\s*(?:\\*\\s*as\\s+<ID>|\\{[^{}]*\\}))?|\\*\\s*as\\s+<ID>|\\{[^{}]*\\})(?=\\s*\\bfrom\\b)"), lookbehind: !0, inside: a.languages.javascript }, exports: { pattern: e("(\\bexport\\b\\s*)(?:\\*(?:\\s*as\\s+<ID>)?(?=\\s*\\bfrom\\b)|\\{[^{}]*\\})"), lookbehind: !0, inside: a.languages.javascript } }), a.languages.javascript.keyword.unshift({ pattern: /\b(?:as|default|export|from|import)\b/, alias: "module" }, { pattern: /\b(?:await|break|catch|continue|do|else|finally|for|if|return|switch|throw|try|while|yield)\b/, alias: "control-flow" }, { pattern: /\bnull\b/, alias: ["null", "nil"] }, { pattern: /\bundefined\b/, alias: "nil" }), a.languages.insertBefore("javascript", "operator", { spread: { pattern: /\.{3}/, alias: "operator" }, arrow: { pattern: /=>/, alias: "operator" } }), a.languages.insertBefore("javascript", "punctuation", { "property-access": { pattern: e("(\\.\\s*)#?<ID>"), lookbehind: !0 }, "maybe-class-name": { pattern: /(^|[^$\w\xA0-\uFFFF])[A-Z][$\w\xA0-\uFFFF]+/, lookbehind: !0 }, dom: { pattern: /\b(?:document|(?:local|session)Storage|location|navigator|performance|window)\b/, alias: "variable" }, console: { pattern: /\bconsole(?=\s*\.)/, alias: "class-name" } }); for (var t = ["function", "function-variable", "method", "method-variable", "property-access"], r = 0; r < t.length; r++) { var n = t[r], s = a.languages.javascript[n]; "RegExp" === a.util.type(s) && (s = a.languages.javascript[n] = { pattern: s }); var o = s.inside || {}; s.inside = o, o["maybe-class-name"] = /^[A-Z][\s\S]*/ } }(Prism);
|
|
17
|
+
Prism.languages.json = { property: { pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/, lookbehind: !0, greedy: !0 }, string: { pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/, lookbehind: !0, greedy: !0 }, comment: { pattern: /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/, greedy: !0 }, number: /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i, punctuation: /[{}[\],]/, operator: /:/, boolean: /\b(?:false|true)\b/, null: { pattern: /\bnull\b/, alias: "keyword" } }, Prism.languages.webmanifest = Prism.languages.json;
|
|
18
|
+
!function (n) { var e = /("|')(?:\\(?:\r\n?|\n|.)|(?!\1)[^\\\r\n])*\1/; n.languages.json5 = n.languages.extend("json", { property: [{ pattern: RegExp(e.source + "(?=\\s*:)"), greedy: !0 }, { pattern: /(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/, alias: "unquoted" }], string: { pattern: e, greedy: !0 }, number: /[+-]?\b(?:NaN|Infinity|0x[a-fA-F\d]+)\b|[+-]?(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[eE][+-]?\d+\b)?/ }) }(Prism);
|
|
19
|
+
!function (e) { var t = e.languages.javascript["template-string"], n = t.pattern.source, r = t.inside.interpolation, a = r.inside["interpolation-punctuation"], i = r.pattern.source; function o(t, r) { if (e.languages[t]) return { pattern: RegExp("((?:" + r + ")\\s*)" + n), lookbehind: !0, greedy: !0, inside: { "template-punctuation": { pattern: /^`|`$/, alias: "string" }, "embedded-code": { pattern: /[\s\S]+/, alias: t } } } } function s(e, t) { return "___" + t.toUpperCase() + "_" + e + "___" } function p(t, n, r) { var a = { code: t, grammar: n, language: r }; return e.hooks.run("before-tokenize", a), a.tokens = e.tokenize(a.code, a.grammar), e.hooks.run("after-tokenize", a), a.tokens } function l(t) { var n = {}; n["interpolation-punctuation"] = a; var i = e.tokenize(t, n); if (3 === i.length) { var o = [1, 1]; o.push.apply(o, p(i[1], e.languages.javascript, "javascript")), i.splice.apply(i, o) } return new e.Token("interpolation", i, r.alias, t) } function g(t, n, r) { var a = e.tokenize(t, { interpolation: { pattern: RegExp(i), lookbehind: !0 } }), o = 0, g = {}, u = p(a.map((function (e) { if ("string" == typeof e) return e; for (var n, a = e.content; -1 !== t.indexOf(n = s(o++, r));); return g[n] = a, n })).join(""), n, r), c = Object.keys(g); return o = 0, function e(t) { for (var n = 0; n < t.length; n++) { if (o >= c.length) return; var r = t[n]; if ("string" == typeof r || "string" == typeof r.content) { var a = c[o], i = "string" == typeof r ? r : r.content, s = i.indexOf(a); if (-1 !== s) { ++o; var p = i.substring(0, s), u = l(g[a]), f = i.substring(s + a.length), y = []; if (p && y.push(p), y.push(u), f) { var v = [f]; e(v), y.push.apply(y, v) } "string" == typeof r ? (t.splice.apply(t, [n, 1].concat(y)), n += y.length - 1) : r.content = y } } else { var d = r.content; Array.isArray(d) ? e(d) : e([d]) } } }(u), new e.Token(r, u, "language-" + r, t) } e.languages.javascript["template-string"] = [o("css", "\\b(?:styled(?:\\([^)]*\\))?(?:\\s*\\.\\s*\\w+(?:\\([^)]*\\))*)*|css(?:\\s*\\.\\s*(?:global|resolve))?|createGlobalStyle|keyframes)"), o("html", "\\bhtml|\\.\\s*(?:inner|outer)HTML\\s*\\+?="), o("svg", "\\bsvg"), o("markdown", "\\b(?:markdown|md)"), o("graphql", "\\b(?:gql|graphql(?:\\s*\\.\\s*experimental)?)"), o("sql", "\\bsql"), t].filter(Boolean); var u = { javascript: !0, js: !0, typescript: !0, ts: !0, jsx: !0, tsx: !0 }; function c(e) { return "string" == typeof e ? e : Array.isArray(e) ? e.map(c).join("") : c(e.content) } e.hooks.add("after-tokenize", (function (t) { t.language in u && function t(n) { for (var r = 0, a = n.length; r < a; r++) { var i = n[r]; if ("string" != typeof i) { var o = i.content; if (Array.isArray(o)) if ("template-string" === i.type) { var s = o[1]; if (3 === o.length && "string" != typeof s && "embedded-code" === s.type) { var p = c(s), l = s.alias, u = Array.isArray(l) ? l[0] : l, f = e.languages[u]; if (!f) continue; o[1] = g(p, f, u) } } else t(o); else "string" != typeof o && t([o]) } } }(t.tokens) })) }(Prism);
|
|
20
|
+
!function (a) { var e = { pattern: /\\[\\(){}[\]^$+*?|.]/, alias: "escape" }, n = /\\(?:x[\da-fA-F]{2}|u[\da-fA-F]{4}|u\{[\da-fA-F]+\}|0[0-7]{0,2}|[123][0-7]{2}|c[a-zA-Z]|.)/, t = "(?:[^\\\\-]|" + n.source + ")", s = RegExp(t + "-" + t), i = { pattern: /(<|')[^<>']+(?=[>']$)/, lookbehind: !0, alias: "variable" }; a.languages.regex = { "char-class": { pattern: /((?:^|[^\\])(?:\\\\)*)\[(?:[^\\\]]|\\[\s\S])*\]/, lookbehind: !0, inside: { "char-class-negation": { pattern: /(^\[)\^/, lookbehind: !0, alias: "operator" }, "char-class-punctuation": { pattern: /^\[|\]$/, alias: "punctuation" }, range: { pattern: s, inside: { escape: n, "range-punctuation": { pattern: /-/, alias: "operator" } } }, "special-escape": e, "char-set": { pattern: /\\[wsd]|\\p\{[^{}]+\}/i, alias: "class-name" }, escape: n } }, "special-escape": e, "char-set": { pattern: /\.|\\[wsd]|\\p\{[^{}]+\}/i, alias: "class-name" }, backreference: [{ pattern: /\\(?![123][0-7]{2})[1-9]/, alias: "keyword" }, { pattern: /\\k<[^<>']+>/, alias: "keyword", inside: { "group-name": i } }], anchor: { pattern: /[$^]|\\[ABbGZz]/, alias: "function" }, escape: n, group: [{ pattern: /\((?:\?(?:<[^<>']+>|'[^<>']+'|[>:]|<?[=!]|[idmnsuxU]+(?:-[idmnsuxU]+)?:?))?/, alias: "punctuation", inside: { "group-name": i } }, { pattern: /\)/, alias: "punctuation" }], quantifier: { pattern: /(?:[+*?]|\{\d+(?:,\d*)?\})[?+]?/, alias: "number" }, alternation: { pattern: /\|/, alias: "keyword" } } }(Prism);
|
|
21
|
+
!function (e) { var n = /[*&][^\s[\]{},]+/, r = /!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/, t = "(?:" + r.source + "(?:[ \t]+" + n.source + ")?|" + n.source + "(?:[ \t]+" + r.source + ")?)", a = "(?:[^\\s\\x00-\\x08\\x0e-\\x1f!\"#%&'*,\\-:>?@[\\]`{|}\\x7f-\\x84\\x86-\\x9f\\ud800-\\udfff\\ufffe\\uffff]|[?:-]<PLAIN>)(?:[ \t]*(?:(?![#:])<PLAIN>|:<PLAIN>))*".replace(/<PLAIN>/g, (function () { return "[^\\s\\x00-\\x08\\x0e-\\x1f,[\\]{}\\x7f-\\x84\\x86-\\x9f\\ud800-\\udfff\\ufffe\\uffff]" })), d = "\"(?:[^\"\\\\\r\n]|\\\\.)*\"|'(?:[^'\\\\\r\n]|\\\\.)*'"; function o(e, n) { n = (n || "").replace(/m/g, "") + "m"; var r = "([:\\-,[{]\\s*(?:\\s<<prop>>[ \t]+)?)(?:<<value>>)(?=[ \t]*(?:$|,|\\]|\\}|(?:[\r\n]\\s*)?#))".replace(/<<prop>>/g, (function () { return t })).replace(/<<value>>/g, (function () { return e })); return RegExp(r, n) } e.languages.yaml = { scalar: { pattern: RegExp("([\\-:]\\s*(?:\\s<<prop>>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\\S[^\r\n]*(?:\\2[^\r\n]+)*)".replace(/<<prop>>/g, (function () { return t }))), lookbehind: !0, alias: "string" }, comment: /#.*/, key: { pattern: RegExp("((?:^|[:\\-,[{\r\n?])[ \t]*(?:<<prop>>[ \t]+)?)<<key>>(?=\\s*:\\s)".replace(/<<prop>>/g, (function () { return t })).replace(/<<key>>/g, (function () { return "(?:" + a + "|" + d + ")" }))), lookbehind: !0, greedy: !0, alias: "atrule" }, directive: { pattern: /(^[ \t]*)%.+/m, lookbehind: !0, alias: "important" }, datetime: { pattern: o("\\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*)?)?"), lookbehind: !0, alias: "number" }, boolean: { pattern: o("false|true", "i"), lookbehind: !0, alias: "important" }, null: { pattern: o("null|~", "i"), lookbehind: !0, alias: "important" }, string: { pattern: o(d), lookbehind: !0, greedy: !0 }, number: { pattern: o("[+-]?(?:0x[\\da-f]+|0o[0-7]+|(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:e[+-]?\\d+)?|\\.inf|\\.nan)", "i"), lookbehind: !0 }, tag: r, important: n, punctuation: /---|[:[\]{}\-,|>?]|\.\.\./ }, e.languages.yml = e.languages.yaml }(Prism);
|
|
22
|
+
!function () { if ("undefined" != typeof Prism && "undefined" != typeof document) { var e = "line-numbers", n = /\n(?!$)/g, t = Prism.plugins.lineNumbers = { getLine: function (n, t) { if ("PRE" === n.tagName && n.classList.contains(e)) { var i = n.querySelector(".line-numbers-rows"); if (i) { var r = parseInt(n.getAttribute("data-start"), 10) || 1, s = r + (i.children.length - 1); t < r && (t = r), t > s && (t = s); var l = t - r; return i.children[l] } } }, resize: function (e) { r([e]) }, assumeViewportIndependence: !0 }, i = void 0; window.addEventListener("resize", (function () { t.assumeViewportIndependence && i === window.innerWidth || (i = window.innerWidth, r(Array.prototype.slice.call(document.querySelectorAll("pre.line-numbers")))) })), Prism.hooks.add("complete", (function (t) { if (t.code) { var i = t.element, s = i.parentNode; if (s && /pre/i.test(s.nodeName) && !i.querySelector(".line-numbers-rows") && Prism.util.isActive(i, e)) { i.classList.remove(e), s.classList.add(e); var l, o = t.code.match(n), a = o ? o.length + 1 : 1, u = new Array(a + 1).join("<span></span>"); (l = document.createElement("span")).setAttribute("aria-hidden", "true"), l.className = "line-numbers-rows", l.innerHTML = u, s.hasAttribute("data-start") && (s.style.counterReset = "linenumber " + (parseInt(s.getAttribute("data-start"), 10) - 1)), t.element.appendChild(l), r([s]), Prism.hooks.run("line-numbers", t) } } })), Prism.hooks.add("line-numbers", (function (e) { e.plugins = e.plugins || {}, e.plugins.lineNumbers = !0 })) } function r(e) { if (0 != (e = e.filter((function (e) { var n, t = (n = e, n ? window.getComputedStyle ? getComputedStyle(n) : n.currentStyle || null : null)["white-space"]; return "pre-wrap" === t || "pre-line" === t }))).length) { var t = e.map((function (e) { var t = e.querySelector("code"), i = e.querySelector(".line-numbers-rows"); if (t && i) { var r = e.querySelector(".line-numbers-sizer"), s = t.textContent.split(n); r || ((r = document.createElement("span")).className = "line-numbers-sizer", t.appendChild(r)), r.innerHTML = "0", r.style.display = "block"; var l = r.getBoundingClientRect().height; return r.innerHTML = "", { element: e, lines: s, lineHeights: [], oneLinerHeight: l, sizer: r } } })).filter(Boolean); t.forEach((function (e) { var n = e.sizer, t = e.lines, i = e.lineHeights, r = e.oneLinerHeight; i[t.length - 1] = void 0, t.forEach((function (e, t) { if (e && e.length > 1) { var s = n.appendChild(document.createElement("span")); s.style.display = "block", s.textContent = e } else i[t] = r })) })), t.forEach((function (e) { for (var n = e.sizer, t = e.lineHeights, i = 0, r = 0; r < t.length; r++)void 0 === t[r] && (t[r] = n.children[i++].getBoundingClientRect().height) })), t.forEach((function (e) { var n = e.sizer, t = e.element.querySelector(".line-numbers-rows"); n.style.display = "none", n.innerHTML = "", e.lineHeights.forEach((function (e, n) { t.children[n].style.height = e + "px" })) })) } } }();
|
|
23
|
+
"undefined" != typeof Prism && Prism.hooks.add("wrap", (function (e) { "keyword" === e.type && e.classes.push("keyword-" + e.content) }));
|
|
24
|
+
|