chrome-devtools-frontend 1.0.1636056 → 1.0.1640418
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/front_end/core/common/Color.ts +0 -4
- package/front_end/core/host/AidaClientTypes.ts +8 -6
- package/front_end/core/root/Runtime.ts +2 -2
- package/front_end/core/sdk/DOMStorageModel.ts +1 -1
- package/front_end/core/sdk/SourceMap.ts +8 -3
- package/front_end/core/sdk/TargetManager.ts +14 -1
- package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshot.ts +147 -0
- package/front_end/generated/ARIAProperties.js +17 -4
- package/front_end/generated/InspectorBackendCommands.ts +13 -7
- package/front_end/generated/SupportedCSSProperties.js +1 -0
- package/front_end/generated/protocol-mapping.d.ts +7 -0
- package/front_end/generated/protocol-proxy-api.d.ts +14 -0
- package/front_end/generated/protocol.ts +120 -2
- package/front_end/global_typings/global_defs.d.ts +13 -0
- package/front_end/models/ai_assistance/AiAgent2.ts +116 -0
- package/front_end/models/ai_assistance/AiConversation.ts +22 -36
- package/front_end/models/ai_assistance/AiHistoryStorage.ts +0 -1
- package/front_end/models/ai_assistance/AiOrigins.ts +46 -0
- package/front_end/models/ai_assistance/AiUtils.ts +9 -0
- package/front_end/models/ai_assistance/README.md +16 -0
- package/front_end/models/ai_assistance/StorageItem.ts +30 -26
- package/front_end/models/ai_assistance/agents/AccessibilityAgent.ts +12 -5
- package/front_end/models/ai_assistance/agents/AiAgent.ts +86 -32
- package/front_end/models/ai_assistance/agents/ContextSelectionAgent.snapshot.txt +2 -2
- package/front_end/models/ai_assistance/agents/ContextSelectionAgent.ts +31 -10
- package/front_end/models/ai_assistance/agents/ConversationSummaryAgent.ts +1 -1
- package/front_end/models/ai_assistance/agents/FileAgent.ts +2 -2
- package/front_end/models/ai_assistance/agents/GreenDevAgent.ts +1 -3
- package/front_end/models/ai_assistance/agents/NetworkAgent.snapshot.txt +19 -0
- package/front_end/models/ai_assistance/agents/NetworkAgent.ts +9 -4
- package/front_end/models/ai_assistance/agents/PerformanceAgent.snapshot.txt +2 -2
- package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +41 -12
- package/front_end/models/ai_assistance/agents/StorageAgent.ts +442 -122
- package/front_end/models/ai_assistance/agents/StylingAgent.ts +2 -2
- package/front_end/models/ai_assistance/ai_assistance.ts +4 -2
- package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.snapshot.txt +2 -2
- package/front_end/models/ai_assistance/performance/AIContext.ts +7 -8
- package/front_end/models/ai_assistance/skills/README.md +40 -0
- package/front_end/models/ai_assistance/skills/Skill.ts +13 -0
- package/front_end/models/ai_assistance/skills/SkillRegistry.ts +10 -0
- package/front_end/models/ai_assistance/skills/styling.md +6 -0
- package/front_end/models/bindings/CompilerScriptMapping.ts +12 -4
- package/front_end/models/breakpoints/BreakpointManager.ts +54 -2
- package/front_end/models/greendev/Prototypes.ts +0 -7
- package/front_end/models/heap_snapshot/HeapSnapshotModel.ts +20 -0
- package/front_end/models/heap_snapshot/HeapSnapshotProxy.ts +5 -0
- package/front_end/models/issues_manager/EmailVerificationRequestIssue.ts +293 -0
- package/front_end/models/issues_manager/IssuesManager.ts +5 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestDnsFetchFailed.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestDnsInvalidRecord.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestInvalidEmail.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestKeyBindingSigningFailed.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestRpOriginIsOpaque.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestTokenHttpNotFound.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestTokenInvalidContentType.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestTokenInvalidResponse.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestTokenInvalidSdJwt.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestTokenMalformedSdJwt.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestTokenNoResponse.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestUserLoggedOut.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownAccountsEndpointCrossOrigin.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownHttpNotFound.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownInvalidContentType.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownInvalidResponse.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownIssuanceEndpointCrossOrigin.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownListEmpty.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownMissingAccountsEndpoint.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownMissingIssuanceEndpoint.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownNoResponse.md +1 -0
- package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownUnsupportedSigningAlgorithm.md +1 -0
- package/front_end/models/issues_manager/issues_manager.ts +2 -0
- package/front_end/models/javascript_metadata/NativeFunctions.js +1748 -1739
- package/front_end/models/live-metrics/web-vitals-injected/web-vitals-injected.ts +1 -1
- package/front_end/models/stack_trace/DetailedErrorStackParser.ts +9 -1
- package/front_end/models/stack_trace/StackTraceImpl.ts +29 -9
- package/front_end/models/stack_trace/StackTraceModel.ts +23 -11
- package/front_end/models/stack_trace/Trie.ts +11 -1
- package/front_end/models/trace/extras/TraceTree.ts +20 -1
- package/front_end/models/trace/insights/Common.ts +9 -0
- package/front_end/models/trace/lantern/core/NetworkAnalyzer.ts +21 -25
- package/front_end/panels/ai_assistance/AiAssistancePanel.ts +19 -75
- package/front_end/panels/ai_assistance/components/AccessibilityAgentMarkdownRenderer.ts +10 -3
- package/front_end/panels/ai_assistance/components/ChatMessage.ts +148 -2
- package/front_end/panels/ai_assistance/components/PerformanceAgentMarkdownRenderer.ts +2 -3
- package/front_end/panels/ai_assistance/components/chatMessage.css +27 -0
- package/front_end/panels/application/CookieItemsView.ts +24 -0
- package/front_end/panels/application/DOMStorageItemsView.ts +9 -4
- package/front_end/panels/application/preloading/components/PreloadingString.ts +6 -0
- package/front_end/panels/application/preloading/components/UsedPreloadingView.ts +4 -4
- package/front_end/panels/console/ConsoleViewMessage.ts +13 -102
- package/front_end/panels/elements/StandaloneStylesContainer.ts +10 -0
- package/front_end/panels/elements/StylePropertiesSection.ts +6 -2
- package/front_end/panels/elements/StylePropertyTreeElement.ts +30 -1
- package/front_end/panels/elements/StylesContainer.ts +3 -0
- package/front_end/panels/elements/StylesSidebarPane.ts +54 -4
- package/front_end/panels/elements/elements-meta.ts +14 -0
- package/front_end/panels/layer_viewer/layerDetailsView.css +1 -1
- package/front_end/panels/lighthouse/LighthouseController.ts +1 -1
- package/front_end/panels/lighthouse/LighthouseProtocolService.ts +4 -4
- package/front_end/panels/network/NetworkDataGridNode.ts +14 -0
- package/front_end/panels/network/NetworkLogViewColumns.ts +2 -2
- package/front_end/panels/network/RequestHeadersView.ts +55 -19
- package/front_end/panels/network/networkTimingTable.css +2 -4
- package/front_end/panels/recorder/components/ReplaySection.ts +28 -16
- package/front_end/panels/recorder/converters/LighthouseConverter.snapshot.txt +47 -0
- package/front_end/panels/recorder/converters/PuppeteerConverter.snapshot.txt +49 -0
- package/front_end/panels/recorder/converters/PuppeteerReplayConverter.snapshot.txt +33 -0
- package/front_end/panels/settings/SettingsScreen.ts +1 -2
- package/front_end/panels/sources/BreakpointsView.ts +23 -42
- package/front_end/panels/sources/DebuggerPlugin.ts +12 -5
- package/front_end/panels/sources/ScopeChainSidebarPane.ts +169 -106
- package/front_end/panels/timeline/components/IgnoreListSetting.ts +1 -0
- package/front_end/third_party/chromium/README.chromium +1 -1
- package/front_end/third_party/lighthouse/lighthouse-dt-bundle.js +2 -2
- package/front_end/third_party/marked/README.chromium +3 -6
- package/front_end/third_party/marked/package/README.md +5 -5
- package/front_end/third_party/marked/package/bin/main.js +27 -22
- package/front_end/third_party/marked/package/bin/marked.js +2 -1
- package/front_end/third_party/marked/package/lib/marked.esm.d.ts +346 -256
- package/front_end/third_party/marked/package/lib/marked.esm.js +67 -2698
- package/front_end/third_party/marked/package/lib/marked.esm.js.map +7 -1
- package/front_end/third_party/marked/package/lib/marked.umd.js +69 -2722
- package/front_end/third_party/marked/package/lib/marked.umd.js.map +7 -1
- package/front_end/third_party/marked/package/man/marked.1 +4 -2
- package/front_end/third_party/marked/package/man/marked.1.md +2 -1
- package/front_end/third_party/marked/package/package.json +49 -57
- package/front_end/third_party/puppeteer-replay/README.chromium +2 -2
- package/front_end/third_party/puppeteer-replay/package/lib/cli.js +84 -80
- package/front_end/third_party/puppeteer-replay/package/lib/cli.js.map +1 -1
- package/front_end/third_party/puppeteer-replay/package/lib/extension-test.js +79 -83
- package/front_end/third_party/puppeteer-replay/package/lib/extension-test.js.map +1 -1
- package/front_end/third_party/puppeteer-replay/package/lib/main.d.ts +43 -171
- package/front_end/third_party/puppeteer-replay/package/lib/main.js +51 -206
- package/front_end/third_party/puppeteer-replay/package/lib/main.js.map +1 -1
- package/front_end/third_party/puppeteer-replay/package/package.json +37 -67
- package/front_end/tsconfig.json +1 -1
- package/front_end/ui/components/markdown_view/CodeBlock.ts +17 -6
- package/front_end/ui/components/markdown_view/MarkdownView.ts +39 -3
- package/front_end/ui/components/markdown_view/codeBlock.css +11 -0
- package/front_end/ui/components/markdown_view/markdownView.css +17 -0
- package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +0 -79
- package/front_end/ui/legacy/components/object_ui/RemoteObjectPreviewFormatter.ts +16 -4
- package/front_end/ui/visual_logging/KnownContextValues.ts +4 -0
- package/inspector_overlay/testing/InspectorOverlayHelpers.ts +2 -0
- package/mcp/mcp.ts +1 -6
- package/package.json +14 -16
- package/front_end/models/ai_assistance/agents/BreakpointDebuggerAgent.ts +0 -1015
- package/front_end/models/ai_assistance/agents/BreakpointDebuggerAgentOverlay.ts +0 -87
- package/front_end/third_party/marked/package/bin/marked +0 -215
- package/front_end/third_party/marked/package/lib/marked.cjs +0 -2726
- package/front_end/third_party/marked/package/lib/marked.cjs.map +0 -1
- package/front_end/third_party/marked/package/lib/marked.d.cts +0 -670
- package/front_end/third_party/marked/package/lib/marked.js +0 -2780
- package/front_end/third_party/marked/package/man/marked.1.txt +0 -86
- package/front_end/third_party/marked/package/marked.min.js +0 -6
- package/front_end/third_party/marked/package/src/Lexer.js +0 -492
- package/front_end/third_party/marked/package/src/Parser.js +0 -286
- package/front_end/third_party/marked/package/src/Renderer.js +0 -166
- package/front_end/third_party/marked/package/src/Slugger.js +0 -49
- package/front_end/third_party/marked/package/src/TextRenderer.js +0 -42
- package/front_end/third_party/marked/package/src/Tokenizer.js +0 -755
- package/front_end/third_party/marked/package/src/defaults.js +0 -29
- package/front_end/third_party/marked/package/src/helpers.js +0 -249
- package/front_end/third_party/marked/package/src/marked.js +0 -350
- package/front_end/third_party/marked/package/src/rules.js +0 -285
- package/front_end/third_party/puppeteer-replay/package/lib/cjs/main.cjs +0 -2099
- package/front_end/third_party/puppeteer-replay/package/lib/cjs/main.cjs.map +0 -1
- package/front_end/third_party/puppeteer-replay/package/lib/cjs/main.d.cts +0 -686
- package/front_end/third_party/puppeteer-replay/package/lib/cjs/main.d.ts +0 -35
- package/mcp/HostBindings.ts +0 -319
- /package/front_end/third_party/marked/package/{LICENSE.md → LICENSE} +0 -0
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
import { defaults } from './defaults.js';
|
|
2
|
-
import {
|
|
3
|
-
unescape
|
|
4
|
-
} from './helpers.js';
|
|
5
|
-
import { Renderer } from './Renderer.js';
|
|
6
|
-
import { Slugger } from './Slugger.js';
|
|
7
|
-
import { TextRenderer } from './TextRenderer.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Parsing & Compiling
|
|
11
|
-
*/
|
|
12
|
-
export class Parser {
|
|
13
|
-
constructor(options) {
|
|
14
|
-
this.options = options || defaults;
|
|
15
|
-
this.options.renderer = this.options.renderer || new Renderer();
|
|
16
|
-
this.renderer = this.options.renderer;
|
|
17
|
-
this.renderer.options = this.options;
|
|
18
|
-
this.textRenderer = new TextRenderer();
|
|
19
|
-
this.slugger = new Slugger();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Static Parse Method
|
|
24
|
-
*/
|
|
25
|
-
static parse(tokens, options) {
|
|
26
|
-
const parser = new Parser(options);
|
|
27
|
-
return parser.parse(tokens);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Static Parse Inline Method
|
|
32
|
-
*/
|
|
33
|
-
static parseInline(tokens, options) {
|
|
34
|
-
const parser = new Parser(options);
|
|
35
|
-
return parser.parseInline(tokens);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Parse Loop
|
|
40
|
-
*/
|
|
41
|
-
parse(tokens, top = true) {
|
|
42
|
-
let out = '',
|
|
43
|
-
i,
|
|
44
|
-
j,
|
|
45
|
-
k,
|
|
46
|
-
l2,
|
|
47
|
-
l3,
|
|
48
|
-
row,
|
|
49
|
-
cell,
|
|
50
|
-
header,
|
|
51
|
-
body,
|
|
52
|
-
token,
|
|
53
|
-
ordered,
|
|
54
|
-
start,
|
|
55
|
-
loose,
|
|
56
|
-
itemBody,
|
|
57
|
-
item,
|
|
58
|
-
checked,
|
|
59
|
-
task,
|
|
60
|
-
checkbox,
|
|
61
|
-
ret;
|
|
62
|
-
|
|
63
|
-
const l = tokens.length;
|
|
64
|
-
for (i = 0; i < l; i++) {
|
|
65
|
-
token = tokens[i];
|
|
66
|
-
|
|
67
|
-
// Run any renderer extensions
|
|
68
|
-
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
|
|
69
|
-
ret = this.options.extensions.renderers[token.type].call({ parser: this }, token);
|
|
70
|
-
if (ret !== false || !['space', 'hr', 'heading', 'code', 'table', 'blockquote', 'list', 'html', 'paragraph', 'text'].includes(token.type)) {
|
|
71
|
-
out += ret || '';
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
switch (token.type) {
|
|
77
|
-
case 'space': {
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
case 'hr': {
|
|
81
|
-
out += this.renderer.hr();
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
case 'heading': {
|
|
85
|
-
out += this.renderer.heading(
|
|
86
|
-
this.parseInline(token.tokens),
|
|
87
|
-
token.depth,
|
|
88
|
-
unescape(this.parseInline(token.tokens, this.textRenderer)),
|
|
89
|
-
this.slugger);
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
case 'code': {
|
|
93
|
-
out += this.renderer.code(token.text,
|
|
94
|
-
token.lang,
|
|
95
|
-
token.escaped);
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
case 'table': {
|
|
99
|
-
header = '';
|
|
100
|
-
|
|
101
|
-
// header
|
|
102
|
-
cell = '';
|
|
103
|
-
l2 = token.header.length;
|
|
104
|
-
for (j = 0; j < l2; j++) {
|
|
105
|
-
cell += this.renderer.tablecell(
|
|
106
|
-
this.parseInline(token.header[j].tokens),
|
|
107
|
-
{ header: true, align: token.align[j] }
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
header += this.renderer.tablerow(cell);
|
|
111
|
-
|
|
112
|
-
body = '';
|
|
113
|
-
l2 = token.rows.length;
|
|
114
|
-
for (j = 0; j < l2; j++) {
|
|
115
|
-
row = token.rows[j];
|
|
116
|
-
|
|
117
|
-
cell = '';
|
|
118
|
-
l3 = row.length;
|
|
119
|
-
for (k = 0; k < l3; k++) {
|
|
120
|
-
cell += this.renderer.tablecell(
|
|
121
|
-
this.parseInline(row[k].tokens),
|
|
122
|
-
{ header: false, align: token.align[k] }
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
body += this.renderer.tablerow(cell);
|
|
127
|
-
}
|
|
128
|
-
out += this.renderer.table(header, body);
|
|
129
|
-
continue;
|
|
130
|
-
}
|
|
131
|
-
case 'blockquote': {
|
|
132
|
-
body = this.parse(token.tokens);
|
|
133
|
-
out += this.renderer.blockquote(body);
|
|
134
|
-
continue;
|
|
135
|
-
}
|
|
136
|
-
case 'list': {
|
|
137
|
-
ordered = token.ordered;
|
|
138
|
-
start = token.start;
|
|
139
|
-
loose = token.loose;
|
|
140
|
-
l2 = token.items.length;
|
|
141
|
-
|
|
142
|
-
body = '';
|
|
143
|
-
for (j = 0; j < l2; j++) {
|
|
144
|
-
item = token.items[j];
|
|
145
|
-
checked = item.checked;
|
|
146
|
-
task = item.task;
|
|
147
|
-
|
|
148
|
-
itemBody = '';
|
|
149
|
-
if (item.task) {
|
|
150
|
-
checkbox = this.renderer.checkbox(checked);
|
|
151
|
-
if (loose) {
|
|
152
|
-
if (item.tokens.length > 0 && item.tokens[0].type === 'paragraph') {
|
|
153
|
-
item.tokens[0].text = checkbox + ' ' + item.tokens[0].text;
|
|
154
|
-
if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === 'text') {
|
|
155
|
-
item.tokens[0].tokens[0].text = checkbox + ' ' + item.tokens[0].tokens[0].text;
|
|
156
|
-
}
|
|
157
|
-
} else {
|
|
158
|
-
item.tokens.unshift({
|
|
159
|
-
type: 'text',
|
|
160
|
-
text: checkbox
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
} else {
|
|
164
|
-
itemBody += checkbox;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
itemBody += this.parse(item.tokens, loose);
|
|
169
|
-
body += this.renderer.listitem(itemBody, task, checked);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
out += this.renderer.list(body, ordered, start);
|
|
173
|
-
continue;
|
|
174
|
-
}
|
|
175
|
-
case 'html': {
|
|
176
|
-
// TODO parse inline content if parameter markdown=1
|
|
177
|
-
out += this.renderer.html(token.text);
|
|
178
|
-
continue;
|
|
179
|
-
}
|
|
180
|
-
case 'paragraph': {
|
|
181
|
-
out += this.renderer.paragraph(this.parseInline(token.tokens));
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
case 'text': {
|
|
185
|
-
body = token.tokens ? this.parseInline(token.tokens) : token.text;
|
|
186
|
-
while (i + 1 < l && tokens[i + 1].type === 'text') {
|
|
187
|
-
token = tokens[++i];
|
|
188
|
-
body += '\n' + (token.tokens ? this.parseInline(token.tokens) : token.text);
|
|
189
|
-
}
|
|
190
|
-
out += top ? this.renderer.paragraph(body) : body;
|
|
191
|
-
continue;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
default: {
|
|
195
|
-
const errMsg = 'Token with "' + token.type + '" type was not found.';
|
|
196
|
-
if (this.options.silent) {
|
|
197
|
-
console.error(errMsg);
|
|
198
|
-
return;
|
|
199
|
-
} else {
|
|
200
|
-
throw new Error(errMsg);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
return out;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Parse Inline Tokens
|
|
211
|
-
*/
|
|
212
|
-
parseInline(tokens, renderer) {
|
|
213
|
-
renderer = renderer || this.renderer;
|
|
214
|
-
let out = '',
|
|
215
|
-
i,
|
|
216
|
-
token,
|
|
217
|
-
ret;
|
|
218
|
-
|
|
219
|
-
const l = tokens.length;
|
|
220
|
-
for (i = 0; i < l; i++) {
|
|
221
|
-
token = tokens[i];
|
|
222
|
-
|
|
223
|
-
// Run any renderer extensions
|
|
224
|
-
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
|
|
225
|
-
ret = this.options.extensions.renderers[token.type].call({ parser: this }, token);
|
|
226
|
-
if (ret !== false || !['escape', 'html', 'link', 'image', 'strong', 'em', 'codespan', 'br', 'del', 'text'].includes(token.type)) {
|
|
227
|
-
out += ret || '';
|
|
228
|
-
continue;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
switch (token.type) {
|
|
233
|
-
case 'escape': {
|
|
234
|
-
out += renderer.text(token.text);
|
|
235
|
-
break;
|
|
236
|
-
}
|
|
237
|
-
case 'html': {
|
|
238
|
-
out += renderer.html(token.text);
|
|
239
|
-
break;
|
|
240
|
-
}
|
|
241
|
-
case 'link': {
|
|
242
|
-
out += renderer.link(token.href, token.title, this.parseInline(token.tokens, renderer));
|
|
243
|
-
break;
|
|
244
|
-
}
|
|
245
|
-
case 'image': {
|
|
246
|
-
out += renderer.image(token.href, token.title, token.text);
|
|
247
|
-
break;
|
|
248
|
-
}
|
|
249
|
-
case 'strong': {
|
|
250
|
-
out += renderer.strong(this.parseInline(token.tokens, renderer));
|
|
251
|
-
break;
|
|
252
|
-
}
|
|
253
|
-
case 'em': {
|
|
254
|
-
out += renderer.em(this.parseInline(token.tokens, renderer));
|
|
255
|
-
break;
|
|
256
|
-
}
|
|
257
|
-
case 'codespan': {
|
|
258
|
-
out += renderer.codespan(token.text);
|
|
259
|
-
break;
|
|
260
|
-
}
|
|
261
|
-
case 'br': {
|
|
262
|
-
out += renderer.br();
|
|
263
|
-
break;
|
|
264
|
-
}
|
|
265
|
-
case 'del': {
|
|
266
|
-
out += renderer.del(this.parseInline(token.tokens, renderer));
|
|
267
|
-
break;
|
|
268
|
-
}
|
|
269
|
-
case 'text': {
|
|
270
|
-
out += renderer.text(token.text);
|
|
271
|
-
break;
|
|
272
|
-
}
|
|
273
|
-
default: {
|
|
274
|
-
const errMsg = 'Token with "' + token.type + '" type was not found.';
|
|
275
|
-
if (this.options.silent) {
|
|
276
|
-
console.error(errMsg);
|
|
277
|
-
return;
|
|
278
|
-
} else {
|
|
279
|
-
throw new Error(errMsg);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
return out;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { defaults } from './defaults.js';
|
|
2
|
-
import {
|
|
3
|
-
cleanUrl,
|
|
4
|
-
escape
|
|
5
|
-
} from './helpers.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Renderer
|
|
9
|
-
*/
|
|
10
|
-
export class Renderer {
|
|
11
|
-
constructor(options) {
|
|
12
|
-
this.options = options || defaults;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
code(code, infostring, escaped) {
|
|
16
|
-
const lang = (infostring || '').match(/\S*/)[0];
|
|
17
|
-
if (this.options.highlight) {
|
|
18
|
-
const out = this.options.highlight(code, lang);
|
|
19
|
-
if (out != null && out !== code) {
|
|
20
|
-
escaped = true;
|
|
21
|
-
code = out;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
code = code.replace(/\n$/, '') + '\n';
|
|
26
|
-
|
|
27
|
-
if (!lang) {
|
|
28
|
-
return '<pre><code>'
|
|
29
|
-
+ (escaped ? code : escape(code, true))
|
|
30
|
-
+ '</code></pre>\n';
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return '<pre><code class="'
|
|
34
|
-
+ this.options.langPrefix
|
|
35
|
-
+ escape(lang, true)
|
|
36
|
-
+ '">'
|
|
37
|
-
+ (escaped ? code : escape(code, true))
|
|
38
|
-
+ '</code></pre>\n';
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
blockquote(quote) {
|
|
42
|
-
return '<blockquote>\n' + quote + '</blockquote>\n';
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
html(html) {
|
|
46
|
-
return html;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
heading(text, level, raw, slugger) {
|
|
50
|
-
if (this.options.headerIds) {
|
|
51
|
-
return '<h'
|
|
52
|
-
+ level
|
|
53
|
-
+ ' id="'
|
|
54
|
-
+ this.options.headerPrefix
|
|
55
|
-
+ slugger.slug(raw)
|
|
56
|
-
+ '">'
|
|
57
|
-
+ text
|
|
58
|
-
+ '</h'
|
|
59
|
-
+ level
|
|
60
|
-
+ '>\n';
|
|
61
|
-
}
|
|
62
|
-
// ignore IDs
|
|
63
|
-
return '<h' + level + '>' + text + '</h' + level + '>\n';
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
hr() {
|
|
67
|
-
return this.options.xhtml ? '<hr/>\n' : '<hr>\n';
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
list(body, ordered, start) {
|
|
71
|
-
const type = ordered ? 'ol' : 'ul',
|
|
72
|
-
startatt = (ordered && start !== 1) ? (' start="' + start + '"') : '';
|
|
73
|
-
return '<' + type + startatt + '>\n' + body + '</' + type + '>\n';
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
listitem(text) {
|
|
77
|
-
return '<li>' + text + '</li>\n';
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
checkbox(checked) {
|
|
81
|
-
return '<input '
|
|
82
|
-
+ (checked ? 'checked="" ' : '')
|
|
83
|
-
+ 'disabled="" type="checkbox"'
|
|
84
|
-
+ (this.options.xhtml ? ' /' : '')
|
|
85
|
-
+ '> ';
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
paragraph(text) {
|
|
89
|
-
return '<p>' + text + '</p>\n';
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
table(header, body) {
|
|
93
|
-
if (body) body = '<tbody>' + body + '</tbody>';
|
|
94
|
-
|
|
95
|
-
return '<table>\n'
|
|
96
|
-
+ '<thead>\n'
|
|
97
|
-
+ header
|
|
98
|
-
+ '</thead>\n'
|
|
99
|
-
+ body
|
|
100
|
-
+ '</table>\n';
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
tablerow(content) {
|
|
104
|
-
return '<tr>\n' + content + '</tr>\n';
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
tablecell(content, flags) {
|
|
108
|
-
const type = flags.header ? 'th' : 'td';
|
|
109
|
-
const tag = flags.align
|
|
110
|
-
? '<' + type + ' align="' + flags.align + '">'
|
|
111
|
-
: '<' + type + '>';
|
|
112
|
-
return tag + content + '</' + type + '>\n';
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// span level renderer
|
|
116
|
-
strong(text) {
|
|
117
|
-
return '<strong>' + text + '</strong>';
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
em(text) {
|
|
121
|
-
return '<em>' + text + '</em>';
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
codespan(text) {
|
|
125
|
-
return '<code>' + text + '</code>';
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
br() {
|
|
129
|
-
return this.options.xhtml ? '<br/>' : '<br>';
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
del(text) {
|
|
133
|
-
return '<del>' + text + '</del>';
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
link(href, title, text) {
|
|
137
|
-
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
|
138
|
-
if (href === null) {
|
|
139
|
-
return text;
|
|
140
|
-
}
|
|
141
|
-
let out = '<a href="' + escape(href) + '"';
|
|
142
|
-
if (title) {
|
|
143
|
-
out += ' title="' + title + '"';
|
|
144
|
-
}
|
|
145
|
-
out += '>' + text + '</a>';
|
|
146
|
-
return out;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
image(href, title, text) {
|
|
150
|
-
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
|
151
|
-
if (href === null) {
|
|
152
|
-
return text;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
let out = '<img src="' + href + '" alt="' + text + '"';
|
|
156
|
-
if (title) {
|
|
157
|
-
out += ' title="' + title + '"';
|
|
158
|
-
}
|
|
159
|
-
out += this.options.xhtml ? '/>' : '>';
|
|
160
|
-
return out;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
text(text) {
|
|
164
|
-
return text;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Slugger generates header id
|
|
3
|
-
*/
|
|
4
|
-
export class Slugger {
|
|
5
|
-
constructor() {
|
|
6
|
-
this.seen = {};
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
serialize(value) {
|
|
10
|
-
return value
|
|
11
|
-
.toLowerCase()
|
|
12
|
-
.trim()
|
|
13
|
-
// remove html tags
|
|
14
|
-
.replace(/<[!\/a-z].*?>/ig, '')
|
|
15
|
-
// remove unwanted chars
|
|
16
|
-
.replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, '')
|
|
17
|
-
.replace(/\s/g, '-');
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Finds the next safe (unique) slug to use
|
|
22
|
-
*/
|
|
23
|
-
getNextSafeSlug(originalSlug, isDryRun) {
|
|
24
|
-
let slug = originalSlug;
|
|
25
|
-
let occurenceAccumulator = 0;
|
|
26
|
-
if (this.seen.hasOwnProperty(slug)) {
|
|
27
|
-
occurenceAccumulator = this.seen[originalSlug];
|
|
28
|
-
do {
|
|
29
|
-
occurenceAccumulator++;
|
|
30
|
-
slug = originalSlug + '-' + occurenceAccumulator;
|
|
31
|
-
} while (this.seen.hasOwnProperty(slug));
|
|
32
|
-
}
|
|
33
|
-
if (!isDryRun) {
|
|
34
|
-
this.seen[originalSlug] = occurenceAccumulator;
|
|
35
|
-
this.seen[slug] = 0;
|
|
36
|
-
}
|
|
37
|
-
return slug;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Convert string to unique id
|
|
42
|
-
* @param {object} options
|
|
43
|
-
* @param {boolean} options.dryrun Generates the next unique slug without updating the internal accumulator.
|
|
44
|
-
*/
|
|
45
|
-
slug(value, options = {}) {
|
|
46
|
-
const slug = this.serialize(value);
|
|
47
|
-
return this.getNextSafeSlug(slug, options.dryrun);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TextRenderer
|
|
3
|
-
* returns only the textual part of the token
|
|
4
|
-
*/
|
|
5
|
-
export class TextRenderer {
|
|
6
|
-
// no need for block level renderers
|
|
7
|
-
strong(text) {
|
|
8
|
-
return text;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
em(text) {
|
|
12
|
-
return text;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
codespan(text) {
|
|
16
|
-
return text;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
del(text) {
|
|
20
|
-
return text;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
html(text) {
|
|
24
|
-
return text;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
text(text) {
|
|
28
|
-
return text;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
link(href, title, text) {
|
|
32
|
-
return '' + text;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
image(href, title, text) {
|
|
36
|
-
return '' + text;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
br() {
|
|
40
|
-
return '';
|
|
41
|
-
}
|
|
42
|
-
}
|