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,755 +0,0 @@
|
|
|
1
|
-
import { defaults } from './defaults.js';
|
|
2
|
-
import {
|
|
3
|
-
escape,
|
|
4
|
-
findClosingBracket
|
|
5
|
-
,
|
|
6
|
-
rtrim,
|
|
7
|
-
splitCells} from './helpers.js';
|
|
8
|
-
|
|
9
|
-
function outputLink(cap, link, raw, lexer) {
|
|
10
|
-
const href = link.href;
|
|
11
|
-
const title = link.title ? escape(link.title) : null;
|
|
12
|
-
const text = cap[1].replace(/\\([\[\]])/g, '$1');
|
|
13
|
-
|
|
14
|
-
if (cap[0].charAt(0) !== '!') {
|
|
15
|
-
lexer.state.inLink = true;
|
|
16
|
-
const token = {
|
|
17
|
-
type: 'link',
|
|
18
|
-
raw,
|
|
19
|
-
href,
|
|
20
|
-
title,
|
|
21
|
-
text,
|
|
22
|
-
tokens: lexer.inlineTokens(text, [])
|
|
23
|
-
};
|
|
24
|
-
lexer.state.inLink = false;
|
|
25
|
-
return token;
|
|
26
|
-
} else {
|
|
27
|
-
return {
|
|
28
|
-
type: 'image',
|
|
29
|
-
raw,
|
|
30
|
-
href,
|
|
31
|
-
title,
|
|
32
|
-
text: escape(text)
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function indentCodeCompensation(raw, text) {
|
|
38
|
-
const matchIndentToCode = raw.match(/^(\s+)(?:```)/);
|
|
39
|
-
|
|
40
|
-
if (matchIndentToCode === null) {
|
|
41
|
-
return text;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const indentToCode = matchIndentToCode[1];
|
|
45
|
-
|
|
46
|
-
return text
|
|
47
|
-
.split('\n')
|
|
48
|
-
.map(node => {
|
|
49
|
-
const matchIndentInNode = node.match(/^\s+/);
|
|
50
|
-
if (matchIndentInNode === null) {
|
|
51
|
-
return node;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const [indentInNode] = matchIndentInNode;
|
|
55
|
-
|
|
56
|
-
if (indentInNode.length >= indentToCode.length) {
|
|
57
|
-
return node.slice(indentToCode.length);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return node;
|
|
61
|
-
})
|
|
62
|
-
.join('\n');
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Tokenizer
|
|
67
|
-
*/
|
|
68
|
-
export class Tokenizer {
|
|
69
|
-
constructor(options) {
|
|
70
|
-
this.options = options || defaults;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
space(src) {
|
|
74
|
-
const cap = this.rules.block.newline.exec(src);
|
|
75
|
-
if (cap) {
|
|
76
|
-
if (cap[0].length > 1) {
|
|
77
|
-
return {
|
|
78
|
-
type: 'space',
|
|
79
|
-
raw: cap[0]
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
return { raw: '\n' };
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
code(src) {
|
|
87
|
-
const cap = this.rules.block.code.exec(src);
|
|
88
|
-
if (cap) {
|
|
89
|
-
const text = cap[0].replace(/^ {1,4}/gm, '');
|
|
90
|
-
return {
|
|
91
|
-
type: 'code',
|
|
92
|
-
raw: cap[0],
|
|
93
|
-
codeBlockStyle: 'indented',
|
|
94
|
-
text: !this.options.pedantic
|
|
95
|
-
? rtrim(text, '\n')
|
|
96
|
-
: text
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
fences(src) {
|
|
102
|
-
const cap = this.rules.block.fences.exec(src);
|
|
103
|
-
if (cap) {
|
|
104
|
-
const raw = cap[0];
|
|
105
|
-
const text = indentCodeCompensation(raw, cap[3] || '');
|
|
106
|
-
|
|
107
|
-
return {
|
|
108
|
-
type: 'code',
|
|
109
|
-
raw,
|
|
110
|
-
lang: cap[2] ? cap[2].trim() : cap[2],
|
|
111
|
-
text
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
heading(src) {
|
|
117
|
-
const cap = this.rules.block.heading.exec(src);
|
|
118
|
-
if (cap) {
|
|
119
|
-
let text = cap[2].trim();
|
|
120
|
-
|
|
121
|
-
// remove trailing #s
|
|
122
|
-
if (/#$/.test(text)) {
|
|
123
|
-
const trimmed = rtrim(text, '#');
|
|
124
|
-
if (this.options.pedantic) {
|
|
125
|
-
text = trimmed.trim();
|
|
126
|
-
} else if (!trimmed || / $/.test(trimmed)) {
|
|
127
|
-
// CommonMark requires space before trailing #s
|
|
128
|
-
text = trimmed.trim();
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const token = {
|
|
133
|
-
type: 'heading',
|
|
134
|
-
raw: cap[0],
|
|
135
|
-
depth: cap[1].length,
|
|
136
|
-
text: text,
|
|
137
|
-
tokens: []
|
|
138
|
-
};
|
|
139
|
-
this.lexer.inline(token.text, token.tokens);
|
|
140
|
-
return token;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
hr(src) {
|
|
145
|
-
const cap = this.rules.block.hr.exec(src);
|
|
146
|
-
if (cap) {
|
|
147
|
-
return {
|
|
148
|
-
type: 'hr',
|
|
149
|
-
raw: cap[0]
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
blockquote(src) {
|
|
155
|
-
const cap = this.rules.block.blockquote.exec(src);
|
|
156
|
-
if (cap) {
|
|
157
|
-
const text = cap[0].replace(/^ *> ?/gm, '');
|
|
158
|
-
|
|
159
|
-
return {
|
|
160
|
-
type: 'blockquote',
|
|
161
|
-
raw: cap[0],
|
|
162
|
-
tokens: this.lexer.blockTokens(text, []),
|
|
163
|
-
text
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
list(src) {
|
|
169
|
-
let cap = this.rules.block.list.exec(src);
|
|
170
|
-
if (cap) {
|
|
171
|
-
let raw, istask, ischecked, indent, i, blankLine, endsWithBlankLine,
|
|
172
|
-
line, lines, itemContents;
|
|
173
|
-
|
|
174
|
-
let bull = cap[1].trim();
|
|
175
|
-
const isordered = bull.length > 1;
|
|
176
|
-
|
|
177
|
-
const list = {
|
|
178
|
-
type: 'list',
|
|
179
|
-
raw: '',
|
|
180
|
-
ordered: isordered,
|
|
181
|
-
start: isordered ? +bull.slice(0, -1) : '',
|
|
182
|
-
loose: false,
|
|
183
|
-
items: []
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
bull = isordered ? `\\d{1,9}\\${bull.slice(-1)}` : `\\${bull}`;
|
|
187
|
-
|
|
188
|
-
if (this.options.pedantic) {
|
|
189
|
-
bull = isordered ? bull : '[*+-]';
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// Get next list item
|
|
193
|
-
const itemRegex = new RegExp(`^( {0,3}${bull})((?: [^\\n]*| *)(?:\\n[^\\n]*)*(?:\\n|$))`);
|
|
194
|
-
|
|
195
|
-
// Get each top-level item
|
|
196
|
-
while (src) {
|
|
197
|
-
if (this.rules.block.hr.test(src)) { // End list if we encounter an HR (possibly move into itemRegex?)
|
|
198
|
-
break;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
if (!(cap = itemRegex.exec(src))) {
|
|
202
|
-
break;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
lines = cap[2].split('\n');
|
|
206
|
-
|
|
207
|
-
if (this.options.pedantic) {
|
|
208
|
-
indent = 2;
|
|
209
|
-
itemContents = lines[0].trimLeft();
|
|
210
|
-
} else {
|
|
211
|
-
indent = cap[2].search(/[^ ]/); // Find first non-space char
|
|
212
|
-
indent = cap[1].length + (indent > 4 ? 1 : indent); // intented code blocks after 4 spaces; indent is always 1
|
|
213
|
-
itemContents = lines[0].slice(indent - cap[1].length);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
blankLine = false;
|
|
217
|
-
raw = cap[0];
|
|
218
|
-
|
|
219
|
-
if (!lines[0] && /^ *$/.test(lines[1])) { // items begin with at most one blank line
|
|
220
|
-
raw = cap[1] + lines.slice(0, 2).join('\n') + '\n';
|
|
221
|
-
list.loose = true;
|
|
222
|
-
lines = [];
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])`);
|
|
226
|
-
|
|
227
|
-
for (i = 1; i < lines.length; i++) {
|
|
228
|
-
line = lines[i];
|
|
229
|
-
|
|
230
|
-
if (this.options.pedantic) { // Re-align to follow commonmark nesting rules
|
|
231
|
-
line = line.replace(/^ {1,4}(?=( {4})*[^ ])/g, ' ');
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
// End list item if found start of new bullet
|
|
235
|
-
if (nextBulletRegex.test(line)) {
|
|
236
|
-
raw = cap[1] + lines.slice(0, i).join('\n') + '\n';
|
|
237
|
-
break;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// Until we encounter a blank line, item contents do not need indentation
|
|
241
|
-
if (!blankLine) {
|
|
242
|
-
if (!line.trim()) { // Check if current line is empty
|
|
243
|
-
blankLine = true;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
// Dedent if possible
|
|
247
|
-
if (line.search(/[^ ]/) >= indent) {
|
|
248
|
-
itemContents += '\n' + line.slice(indent);
|
|
249
|
-
} else {
|
|
250
|
-
itemContents += '\n' + line;
|
|
251
|
-
}
|
|
252
|
-
continue;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
// Dedent this line
|
|
256
|
-
if (line.search(/[^ ]/) >= indent || !line.trim()) {
|
|
257
|
-
itemContents += '\n' + line.slice(indent);
|
|
258
|
-
continue;
|
|
259
|
-
} else { // Line was not properly indented; end of this item
|
|
260
|
-
raw = cap[1] + lines.slice(0, i).join('\n') + '\n';
|
|
261
|
-
break;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
if (!list.loose) {
|
|
266
|
-
// If the previous item ended with a blank line, the list is loose
|
|
267
|
-
if (endsWithBlankLine) {
|
|
268
|
-
list.loose = true;
|
|
269
|
-
} else if (/\n *\n *$/.test(raw)) {
|
|
270
|
-
endsWithBlankLine = true;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
// Check for task list items
|
|
275
|
-
if (this.options.gfm) {
|
|
276
|
-
istask = /^\[[ xX]\] /.exec(itemContents);
|
|
277
|
-
if (istask) {
|
|
278
|
-
ischecked = istask[0] !== '[ ] ';
|
|
279
|
-
itemContents = itemContents.replace(/^\[[ xX]\] +/, '');
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
list.items.push({
|
|
284
|
-
type: 'list_item',
|
|
285
|
-
raw: raw,
|
|
286
|
-
task: !!istask,
|
|
287
|
-
checked: ischecked,
|
|
288
|
-
loose: false,
|
|
289
|
-
text: itemContents
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
list.raw += raw;
|
|
293
|
-
src = src.slice(raw.length);
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
// Do not consume newlines at end of final item. Alternatively, make itemRegex *start* with any newlines to simplify/speed up endsWithBlankLine logic
|
|
297
|
-
list.items[list.items.length - 1].raw = raw.trimRight();
|
|
298
|
-
list.items[list.items.length - 1].text = itemContents.trimRight();
|
|
299
|
-
list.raw = list.raw.trimRight();
|
|
300
|
-
|
|
301
|
-
const l = list.items.length;
|
|
302
|
-
|
|
303
|
-
// Item child tokens handled here at end because we needed to have the final item to trim it first
|
|
304
|
-
for (i = 0; i < l; i++) {
|
|
305
|
-
this.lexer.state.top = false;
|
|
306
|
-
list.items[i].tokens = this.lexer.blockTokens(list.items[i].text, []);
|
|
307
|
-
if (list.items[i].tokens.some(t => t.type === 'space')) {
|
|
308
|
-
list.loose = true;
|
|
309
|
-
list.items[i].loose = true;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
return list;
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
html(src) {
|
|
318
|
-
const cap = this.rules.block.html.exec(src);
|
|
319
|
-
if (cap) {
|
|
320
|
-
const token = {
|
|
321
|
-
type: 'html',
|
|
322
|
-
raw: cap[0],
|
|
323
|
-
pre: !this.options.sanitizer
|
|
324
|
-
&& (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
|
|
325
|
-
text: cap[0]
|
|
326
|
-
};
|
|
327
|
-
if (this.options.sanitize) {
|
|
328
|
-
token.type = 'paragraph';
|
|
329
|
-
token.text = this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]);
|
|
330
|
-
token.tokens = [];
|
|
331
|
-
this.lexer.inline(token.text, token.tokens);
|
|
332
|
-
}
|
|
333
|
-
return token;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
def(src) {
|
|
338
|
-
const cap = this.rules.block.def.exec(src);
|
|
339
|
-
if (cap) {
|
|
340
|
-
if (cap[3]) cap[3] = cap[3].substring(1, cap[3].length - 1);
|
|
341
|
-
const tag = cap[1].toLowerCase().replace(/\s+/g, ' ');
|
|
342
|
-
return {
|
|
343
|
-
type: 'def',
|
|
344
|
-
tag,
|
|
345
|
-
raw: cap[0],
|
|
346
|
-
href: cap[2],
|
|
347
|
-
title: cap[3]
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
table(src) {
|
|
353
|
-
const cap = this.rules.block.table.exec(src);
|
|
354
|
-
if (cap) {
|
|
355
|
-
const item = {
|
|
356
|
-
type: 'table',
|
|
357
|
-
header: splitCells(cap[1]).map(c => { return { text: c }; }),
|
|
358
|
-
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
|
|
359
|
-
rows: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : []
|
|
360
|
-
};
|
|
361
|
-
|
|
362
|
-
if (item.header.length === item.align.length) {
|
|
363
|
-
item.raw = cap[0];
|
|
364
|
-
|
|
365
|
-
let l = item.align.length;
|
|
366
|
-
let i, j, k, row;
|
|
367
|
-
for (i = 0; i < l; i++) {
|
|
368
|
-
if (/^ *-+: *$/.test(item.align[i])) {
|
|
369
|
-
item.align[i] = 'right';
|
|
370
|
-
} else if (/^ *:-+: *$/.test(item.align[i])) {
|
|
371
|
-
item.align[i] = 'center';
|
|
372
|
-
} else if (/^ *:-+ *$/.test(item.align[i])) {
|
|
373
|
-
item.align[i] = 'left';
|
|
374
|
-
} else {
|
|
375
|
-
item.align[i] = null;
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
l = item.rows.length;
|
|
380
|
-
for (i = 0; i < l; i++) {
|
|
381
|
-
item.rows[i] = splitCells(item.rows[i], item.header.length).map(c => { return { text: c }; });
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
// parse child tokens inside headers and cells
|
|
385
|
-
|
|
386
|
-
// header child tokens
|
|
387
|
-
l = item.header.length;
|
|
388
|
-
for (j = 0; j < l; j++) {
|
|
389
|
-
item.header[j].tokens = [];
|
|
390
|
-
this.lexer.inlineTokens(item.header[j].text, item.header[j].tokens);
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
// cell child tokens
|
|
394
|
-
l = item.rows.length;
|
|
395
|
-
for (j = 0; j < l; j++) {
|
|
396
|
-
row = item.rows[j];
|
|
397
|
-
for (k = 0; k < row.length; k++) {
|
|
398
|
-
row[k].tokens = [];
|
|
399
|
-
this.lexer.inlineTokens(row[k].text, row[k].tokens);
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
return item;
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
lheading(src) {
|
|
409
|
-
const cap = this.rules.block.lheading.exec(src);
|
|
410
|
-
if (cap) {
|
|
411
|
-
const token = {
|
|
412
|
-
type: 'heading',
|
|
413
|
-
raw: cap[0],
|
|
414
|
-
depth: cap[2].charAt(0) === '=' ? 1 : 2,
|
|
415
|
-
text: cap[1],
|
|
416
|
-
tokens: []
|
|
417
|
-
};
|
|
418
|
-
this.lexer.inline(token.text, token.tokens);
|
|
419
|
-
return token;
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
paragraph(src) {
|
|
424
|
-
const cap = this.rules.block.paragraph.exec(src);
|
|
425
|
-
if (cap) {
|
|
426
|
-
const token = {
|
|
427
|
-
type: 'paragraph',
|
|
428
|
-
raw: cap[0],
|
|
429
|
-
text: cap[1].charAt(cap[1].length - 1) === '\n'
|
|
430
|
-
? cap[1].slice(0, -1)
|
|
431
|
-
: cap[1],
|
|
432
|
-
tokens: []
|
|
433
|
-
};
|
|
434
|
-
this.lexer.inline(token.text, token.tokens);
|
|
435
|
-
return token;
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
text(src) {
|
|
440
|
-
const cap = this.rules.block.text.exec(src);
|
|
441
|
-
if (cap) {
|
|
442
|
-
const token = {
|
|
443
|
-
type: 'text',
|
|
444
|
-
raw: cap[0],
|
|
445
|
-
text: cap[0],
|
|
446
|
-
tokens: []
|
|
447
|
-
};
|
|
448
|
-
this.lexer.inline(token.text, token.tokens);
|
|
449
|
-
return token;
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
escape(src) {
|
|
454
|
-
const cap = this.rules.inline.escape.exec(src);
|
|
455
|
-
if (cap) {
|
|
456
|
-
return {
|
|
457
|
-
type: 'escape',
|
|
458
|
-
raw: cap[0],
|
|
459
|
-
text: escape(cap[1])
|
|
460
|
-
};
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
tag(src) {
|
|
465
|
-
const cap = this.rules.inline.tag.exec(src);
|
|
466
|
-
if (cap) {
|
|
467
|
-
if (!this.lexer.state.inLink && /^<a /i.test(cap[0])) {
|
|
468
|
-
this.lexer.state.inLink = true;
|
|
469
|
-
} else if (this.lexer.state.inLink && /^<\/a>/i.test(cap[0])) {
|
|
470
|
-
this.lexer.state.inLink = false;
|
|
471
|
-
}
|
|
472
|
-
if (!this.lexer.state.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
|
|
473
|
-
this.lexer.state.inRawBlock = true;
|
|
474
|
-
} else if (this.lexer.state.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
|
|
475
|
-
this.lexer.state.inRawBlock = false;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
return {
|
|
479
|
-
type: this.options.sanitize
|
|
480
|
-
? 'text'
|
|
481
|
-
: 'html',
|
|
482
|
-
raw: cap[0],
|
|
483
|
-
inLink: this.lexer.state.inLink,
|
|
484
|
-
inRawBlock: this.lexer.state.inRawBlock,
|
|
485
|
-
text: this.options.sanitize
|
|
486
|
-
? (this.options.sanitizer
|
|
487
|
-
? this.options.sanitizer(cap[0])
|
|
488
|
-
: escape(cap[0]))
|
|
489
|
-
: cap[0]
|
|
490
|
-
};
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
link(src) {
|
|
495
|
-
const cap = this.rules.inline.link.exec(src);
|
|
496
|
-
if (cap) {
|
|
497
|
-
const trimmedUrl = cap[2].trim();
|
|
498
|
-
if (!this.options.pedantic && /^</.test(trimmedUrl)) {
|
|
499
|
-
// commonmark requires matching angle brackets
|
|
500
|
-
if (!(/>$/.test(trimmedUrl))) {
|
|
501
|
-
return;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
// ending angle bracket cannot be escaped
|
|
505
|
-
const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), '\\');
|
|
506
|
-
if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) {
|
|
507
|
-
return;
|
|
508
|
-
}
|
|
509
|
-
} else {
|
|
510
|
-
// find closing parenthesis
|
|
511
|
-
const lastParenIndex = findClosingBracket(cap[2], '()');
|
|
512
|
-
if (lastParenIndex > -1) {
|
|
513
|
-
const start = cap[0].indexOf('!') === 0 ? 5 : 4;
|
|
514
|
-
const linkLen = start + cap[1].length + lastParenIndex;
|
|
515
|
-
cap[2] = cap[2].substring(0, lastParenIndex);
|
|
516
|
-
cap[0] = cap[0].substring(0, linkLen).trim();
|
|
517
|
-
cap[3] = '';
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
let href = cap[2];
|
|
521
|
-
let title = '';
|
|
522
|
-
if (this.options.pedantic) {
|
|
523
|
-
// split pedantic href and title
|
|
524
|
-
const link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
|
|
525
|
-
|
|
526
|
-
if (link) {
|
|
527
|
-
href = link[1];
|
|
528
|
-
title = link[3];
|
|
529
|
-
}
|
|
530
|
-
} else {
|
|
531
|
-
title = cap[3] ? cap[3].slice(1, -1) : '';
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
href = href.trim();
|
|
535
|
-
if (/^</.test(href)) {
|
|
536
|
-
if (this.options.pedantic && !(/>$/.test(trimmedUrl))) {
|
|
537
|
-
// pedantic allows starting angle bracket without ending angle bracket
|
|
538
|
-
href = href.slice(1);
|
|
539
|
-
} else {
|
|
540
|
-
href = href.slice(1, -1);
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
return outputLink(cap, {
|
|
544
|
-
href: href ? href.replace(this.rules.inline._escapes, '$1') : href,
|
|
545
|
-
title: title ? title.replace(this.rules.inline._escapes, '$1') : title
|
|
546
|
-
}, cap[0], this.lexer);
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
reflink(src, links) {
|
|
551
|
-
let cap;
|
|
552
|
-
if ((cap = this.rules.inline.reflink.exec(src))
|
|
553
|
-
|| (cap = this.rules.inline.nolink.exec(src))) {
|
|
554
|
-
let link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
|
|
555
|
-
link = links[link.toLowerCase()];
|
|
556
|
-
if (!link || !link.href) {
|
|
557
|
-
const text = cap[0].charAt(0);
|
|
558
|
-
return {
|
|
559
|
-
type: 'text',
|
|
560
|
-
raw: text,
|
|
561
|
-
text
|
|
562
|
-
};
|
|
563
|
-
}
|
|
564
|
-
return outputLink(cap, link, cap[0], this.lexer);
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
emStrong(src, maskedSrc, prevChar = '') {
|
|
569
|
-
let match = this.rules.inline.emStrong.lDelim.exec(src);
|
|
570
|
-
if (!match) return;
|
|
571
|
-
|
|
572
|
-
// _ can't be between two alphanumerics. \p{L}\p{N} includes non-english alphabet/numbers as well
|
|
573
|
-
if (match[3] && prevChar.match(/[\p{L}\p{N}]/u)) return;
|
|
574
|
-
|
|
575
|
-
const nextChar = match[1] || match[2] || '';
|
|
576
|
-
|
|
577
|
-
if (!nextChar || (nextChar && (prevChar === '' || this.rules.inline.punctuation.exec(prevChar)))) {
|
|
578
|
-
const lLength = match[0].length - 1;
|
|
579
|
-
let rDelim, rLength, delimTotal = lLength, midDelimTotal = 0;
|
|
580
|
-
|
|
581
|
-
const endReg = match[0][0] === '*' ? this.rules.inline.emStrong.rDelimAst : this.rules.inline.emStrong.rDelimUnd;
|
|
582
|
-
endReg.lastIndex = 0;
|
|
583
|
-
|
|
584
|
-
// Clip maskedSrc to same section of string as src (move to lexer?)
|
|
585
|
-
maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
|
|
586
|
-
|
|
587
|
-
while ((match = endReg.exec(maskedSrc)) != null) {
|
|
588
|
-
rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
|
|
589
|
-
|
|
590
|
-
if (!rDelim) continue; // skip single * in __abc*abc__
|
|
591
|
-
|
|
592
|
-
rLength = rDelim.length;
|
|
593
|
-
|
|
594
|
-
if (match[3] || match[4]) { // found another Left Delim
|
|
595
|
-
delimTotal += rLength;
|
|
596
|
-
continue;
|
|
597
|
-
} else if (match[5] || match[6]) { // either Left or Right Delim
|
|
598
|
-
if (lLength % 3 && !((lLength + rLength) % 3)) {
|
|
599
|
-
midDelimTotal += rLength;
|
|
600
|
-
continue; // CommonMark Emphasis Rules 9-10
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
delimTotal -= rLength;
|
|
605
|
-
|
|
606
|
-
if (delimTotal > 0) continue; // Haven't found enough closing delimiters
|
|
607
|
-
|
|
608
|
-
// Remove extra characters. *a*** -> *a*
|
|
609
|
-
rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
|
|
610
|
-
|
|
611
|
-
// Create `em` if smallest delimiter has odd char count. *a***
|
|
612
|
-
if (Math.min(lLength, rLength) % 2) {
|
|
613
|
-
const text = src.slice(1, lLength + match.index + rLength);
|
|
614
|
-
return {
|
|
615
|
-
type: 'em',
|
|
616
|
-
raw: src.slice(0, lLength + match.index + rLength + 1),
|
|
617
|
-
text,
|
|
618
|
-
tokens: this.lexer.inlineTokens(text, [])
|
|
619
|
-
};
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
// Create 'strong' if smallest delimiter has even char count. **a***
|
|
623
|
-
const text = src.slice(2, lLength + match.index + rLength - 1);
|
|
624
|
-
return {
|
|
625
|
-
type: 'strong',
|
|
626
|
-
raw: src.slice(0, lLength + match.index + rLength + 1),
|
|
627
|
-
text,
|
|
628
|
-
tokens: this.lexer.inlineTokens(text, [])
|
|
629
|
-
};
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
codespan(src) {
|
|
635
|
-
const cap = this.rules.inline.code.exec(src);
|
|
636
|
-
if (cap) {
|
|
637
|
-
let text = cap[2].replace(/\n/g, ' ');
|
|
638
|
-
const hasNonSpaceChars = /[^ ]/.test(text);
|
|
639
|
-
const hasSpaceCharsOnBothEnds = /^ /.test(text) && / $/.test(text);
|
|
640
|
-
if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
|
|
641
|
-
text = text.substring(1, text.length - 1);
|
|
642
|
-
}
|
|
643
|
-
text = escape(text, true);
|
|
644
|
-
return {
|
|
645
|
-
type: 'codespan',
|
|
646
|
-
raw: cap[0],
|
|
647
|
-
text
|
|
648
|
-
};
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
br(src) {
|
|
653
|
-
const cap = this.rules.inline.br.exec(src);
|
|
654
|
-
if (cap) {
|
|
655
|
-
return {
|
|
656
|
-
type: 'br',
|
|
657
|
-
raw: cap[0]
|
|
658
|
-
};
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
del(src) {
|
|
663
|
-
const cap = this.rules.inline.del.exec(src);
|
|
664
|
-
if (cap) {
|
|
665
|
-
return {
|
|
666
|
-
type: 'del',
|
|
667
|
-
raw: cap[0],
|
|
668
|
-
text: cap[2],
|
|
669
|
-
tokens: this.lexer.inlineTokens(cap[2], [])
|
|
670
|
-
};
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
autolink(src, mangle) {
|
|
675
|
-
const cap = this.rules.inline.autolink.exec(src);
|
|
676
|
-
if (cap) {
|
|
677
|
-
let text, href;
|
|
678
|
-
if (cap[2] === '@') {
|
|
679
|
-
text = escape(this.options.mangle ? mangle(cap[1]) : cap[1]);
|
|
680
|
-
href = 'mailto:' + text;
|
|
681
|
-
} else {
|
|
682
|
-
text = escape(cap[1]);
|
|
683
|
-
href = text;
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
return {
|
|
687
|
-
type: 'link',
|
|
688
|
-
raw: cap[0],
|
|
689
|
-
text,
|
|
690
|
-
href,
|
|
691
|
-
tokens: [
|
|
692
|
-
{
|
|
693
|
-
type: 'text',
|
|
694
|
-
raw: text,
|
|
695
|
-
text
|
|
696
|
-
}
|
|
697
|
-
]
|
|
698
|
-
};
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
url(src, mangle) {
|
|
703
|
-
let cap;
|
|
704
|
-
if (cap = this.rules.inline.url.exec(src)) {
|
|
705
|
-
let text, href;
|
|
706
|
-
if (cap[2] === '@') {
|
|
707
|
-
text = escape(this.options.mangle ? mangle(cap[0]) : cap[0]);
|
|
708
|
-
href = 'mailto:' + text;
|
|
709
|
-
} else {
|
|
710
|
-
// do extended autolink path validation
|
|
711
|
-
let prevCapZero;
|
|
712
|
-
do {
|
|
713
|
-
prevCapZero = cap[0];
|
|
714
|
-
cap[0] = this.rules.inline._backpedal.exec(cap[0])[0];
|
|
715
|
-
} while (prevCapZero !== cap[0]);
|
|
716
|
-
text = escape(cap[0]);
|
|
717
|
-
if (cap[1] === 'www.') {
|
|
718
|
-
href = 'http://' + text;
|
|
719
|
-
} else {
|
|
720
|
-
href = text;
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
return {
|
|
724
|
-
type: 'link',
|
|
725
|
-
raw: cap[0],
|
|
726
|
-
text,
|
|
727
|
-
href,
|
|
728
|
-
tokens: [
|
|
729
|
-
{
|
|
730
|
-
type: 'text',
|
|
731
|
-
raw: text,
|
|
732
|
-
text
|
|
733
|
-
}
|
|
734
|
-
]
|
|
735
|
-
};
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
inlineText(src, smartypants) {
|
|
740
|
-
const cap = this.rules.inline.text.exec(src);
|
|
741
|
-
if (cap) {
|
|
742
|
-
let text;
|
|
743
|
-
if (this.lexer.state.inRawBlock) {
|
|
744
|
-
text = this.options.sanitize ? (this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0])) : cap[0];
|
|
745
|
-
} else {
|
|
746
|
-
text = escape(this.options.smartypants ? smartypants(cap[0]) : cap[0]);
|
|
747
|
-
}
|
|
748
|
-
return {
|
|
749
|
-
type: 'text',
|
|
750
|
-
raw: cap[0],
|
|
751
|
-
text
|
|
752
|
-
};
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
}
|