chrome-devtools-frontend 1.0.943986 → 1.0.945579
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/config/gni/devtools_grd_files.gni +4 -0
- package/config/gni/devtools_image_files.gni +1 -0
- package/front_end/Images/src/circled_exclamation_icon.svg +3 -0
- package/front_end/core/common/ParsedURL.ts +1 -1
- package/front_end/core/host/UserMetrics.ts +2 -1
- package/front_end/core/i18n/i18nImpl.ts +7 -4
- package/front_end/core/i18n/locales/en-US.json +3 -72
- package/front_end/core/i18n/locales/en-XL.json +15 -84
- package/front_end/core/protocol_client/NodeURL.ts +1 -0
- package/front_end/core/sdk/CSSMetadata.ts +0 -1
- package/front_end/core/sdk/CSSStyleDeclaration.ts +4 -0
- package/front_end/core/sdk/CSSStyleSheetHeader.ts +2 -3
- package/front_end/core/sdk/CompilerSourceMappingContentProvider.ts +2 -3
- package/front_end/core/sdk/Cookie.ts +17 -0
- package/front_end/core/sdk/CookieModel.ts +1 -0
- package/front_end/core/sdk/DebuggerModel.ts +5 -4
- package/front_end/core/sdk/NetworkManager.ts +4 -1
- package/front_end/core/sdk/NetworkRequest.ts +2 -2
- package/front_end/core/sdk/OverlayModel.ts +0 -9
- package/front_end/core/sdk/Resource.ts +2 -2
- package/front_end/core/sdk/Script.ts +2 -3
- package/front_end/core/sdk/sdk-meta.ts +0 -26
- package/front_end/entrypoints/inspector_main/RenderingOptions.ts +0 -13
- package/front_end/entrypoints/main/MainImpl.ts +4 -0
- package/front_end/generated/protocol.d.ts +0 -4
- package/front_end/models/bindings/BreakpointManager.ts +3 -4
- package/front_end/models/bindings/ResourceMapping.ts +1 -2
- package/front_end/models/bindings/StylesSourceMapping.ts +1 -2
- package/front_end/models/emulation/EmulatedDevices.ts +2 -4
- package/front_end/models/persistence/IsolatedFileSystem.ts +7 -6
- package/front_end/models/persistence/PersistenceActions.ts +4 -1
- package/front_end/models/persistence/PlatformFileSystem.ts +3 -4
- package/front_end/models/text_utils/ContentProvider.ts +1 -2
- package/front_end/models/text_utils/StaticContentProvider.ts +2 -3
- package/front_end/models/workspace/UISourceCode.ts +2 -2
- package/front_end/models/workspace_diff/WorkspaceDiff.ts +20 -6
- package/front_end/panels/animation/animationTimeline.css +2 -0
- package/front_end/panels/application/BackForwardCacheStrings.ts +15 -75
- package/front_end/panels/application/BackForwardCacheView.ts +8 -1
- package/front_end/panels/application/ReportingApiView.ts +15 -1
- package/front_end/panels/application/components/EndpointsGrid.ts +63 -4
- package/front_end/panels/application/components/FrameDetailsView.ts +21 -34
- package/front_end/panels/changes/ChangesView.ts +8 -7
- package/front_end/panels/console/ConsolePinPane.ts +1 -0
- package/front_end/panels/console/ConsolePrompt.ts +121 -171
- package/front_end/panels/console/ConsoleView.ts +1 -1
- package/front_end/panels/console/consoleView.css +1 -1
- package/front_end/panels/css_overview/cssOverviewCompletedView.css +2 -2
- package/front_end/panels/elements/AccessibilityTreeUtils.ts +2 -1
- package/front_end/panels/elements/ElementsTreeElement.ts +1 -0
- package/front_end/panels/elements/StyleEditorWidget.ts +13 -2
- package/front_end/panels/elements/StylePropertyHighlighter.ts +29 -19
- package/front_end/panels/elements/StylePropertyTreeElement.ts +8 -12
- package/front_end/panels/elements/StylesSidebarPane.ts +36 -10
- package/front_end/panels/elements/components/AccessibilityTreeNode.ts +27 -3
- package/front_end/panels/emulation/DeviceModeView.ts +3 -0
- package/front_end/panels/help/ReleaseNoteText.ts +3 -1
- package/front_end/panels/network/NetworkDataGridNode.ts +5 -1
- package/front_end/panels/snippets/ScriptSnippetFileSystem.ts +1 -1
- package/front_end/panels/sources/BreakpointEditDialog.ts +1 -0
- package/front_end/panels/sources/DebuggerPlugin.ts +1 -1
- package/front_end/panels/sources/NavigatorView.ts +1 -1
- package/front_end/panels/sources/UISourceCodeFrame.ts +0 -1
- package/front_end/panels/timeline/TimelineFlameChartDataProvider.ts +3 -34
- package/front_end/panels/timeline/TimelineUIUtils.ts +51 -3
- package/front_end/services/window_bounds/WindowBoundsService.ts +27 -0
- package/front_end/services/window_bounds/window_bounds.ts +9 -0
- package/front_end/third_party/acorn/README.chromium +2 -2
- package/front_end/third_party/acorn/acorn.ts +1 -1
- package/front_end/third_party/acorn/package/CHANGELOG.md +31 -1
- package/front_end/third_party/acorn/package/README.md +1 -1
- package/front_end/third_party/acorn/package/dist/acorn.d.ts +3 -0
- package/front_end/third_party/acorn/package/dist/acorn.js +772 -708
- package/front_end/third_party/acorn/package/dist/acorn.mjs +767 -703
- package/front_end/third_party/acorn/package/dist/bin.js +47 -21
- package/front_end/third_party/acorn/package/package.json +1 -1
- package/front_end/third_party/acorn-loose/README.chromium +2 -2
- package/front_end/third_party/acorn-loose/package/CHANGELOG.md +12 -0
- package/front_end/third_party/acorn-loose/package/dist/acorn-loose.js +27 -7
- package/front_end/third_party/acorn-loose/package/dist/acorn-loose.mjs +28 -8
- package/front_end/third_party/acorn-loose/package/package.json +2 -2
- package/front_end/third_party/codemirror.next/bundle.ts +4 -3
- package/front_end/third_party/codemirror.next/chunk/codemirror.js +1 -1
- package/front_end/third_party/codemirror.next/codemirror.next.d.ts +39 -1
- package/front_end/third_party/codemirror.next/codemirror.next.js +1 -1
- package/front_end/third_party/codemirror.next/package.json +4 -4
- package/front_end/third_party/i18n/i18n-impl.ts +1 -1
- package/front_end/third_party/lit-html/README.chromium +2 -2
- package/front_end/third_party/lit-html/package/CHANGELOG.md +216 -28
- package/front_end/third_party/lit-html/package/LICENSE +9 -9
- package/front_end/third_party/lit-html/package/README.md +12 -162
- package/front_end/third_party/lit-html/package/async-directive.d.ts +23 -54
- package/front_end/third_party/lit-html/package/async-directive.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/async-directive.js +2 -7
- package/front_end/third_party/lit-html/package/async-directive.js.map +1 -1
- package/front_end/third_party/lit-html/package/development/async-directive.d.ts +23 -54
- package/front_end/third_party/lit-html/package/development/async-directive.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/development/async-directive.js +44 -194
- package/front_end/third_party/lit-html/package/development/async-directive.js.map +1 -1
- package/front_end/third_party/lit-html/package/development/directive-helpers.d.ts +6 -5
- package/front_end/third_party/lit-html/package/development/directive-helpers.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/development/directive-helpers.js +25 -9
- package/front_end/third_party/lit-html/package/development/directive-helpers.js.map +1 -1
- package/front_end/third_party/lit-html/package/development/directive.d.ts +3 -16
- package/front_end/third_party/lit-html/package/development/directive.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/development/directive.js +6 -1
- package/front_end/third_party/lit-html/package/development/directive.js.map +1 -1
- package/front_end/third_party/lit-html/package/development/directives/async-append.d.ts +7 -14
- package/front_end/third_party/lit-html/package/development/directives/async-append.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/development/directives/async-append.js +17 -58
- package/front_end/third_party/lit-html/package/development/directives/async-append.js.map +1 -1
- package/front_end/third_party/lit-html/package/development/directives/async-replace.d.ts +9 -14
- package/front_end/third_party/lit-html/package/development/directives/async-replace.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/development/directives/async-replace.js +57 -37
- package/front_end/third_party/lit-html/package/development/directives/async-replace.js.map +1 -1
- package/front_end/third_party/lit-html/package/development/directives/cache.d.ts +2 -3
- package/front_end/third_party/lit-html/package/development/directives/cache.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/development/directives/cache.js +4 -6
- package/front_end/third_party/lit-html/package/development/directives/cache.js.map +1 -1
- package/front_end/third_party/lit-html/package/development/directives/class-map.d.ts +2 -2
- package/front_end/third_party/lit-html/package/development/directives/class-map.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/development/directives/class-map.js +17 -7
- package/front_end/third_party/lit-html/package/development/directives/class-map.js.map +1 -1
- package/front_end/third_party/lit-html/package/development/directives/guard.d.ts +3 -2
- package/front_end/third_party/lit-html/package/development/directives/guard.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/development/directives/guard.js +3 -2
- package/front_end/third_party/lit-html/package/development/directives/guard.js.map +1 -1
- package/front_end/third_party/lit-html/package/development/directives/live.d.ts +4 -3
- package/front_end/third_party/lit-html/package/development/directives/live.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/development/directives/live.js +5 -7
- package/front_end/third_party/lit-html/package/development/directives/live.js.map +1 -1
- package/front_end/third_party/lit-html/package/development/directives/private-async-helpers.d.ts +58 -0
- package/front_end/third_party/lit-html/package/development/directives/private-async-helpers.d.ts.map +1 -0
- package/front_end/third_party/lit-html/package/development/directives/private-async-helpers.js +85 -0
- package/front_end/third_party/lit-html/package/development/directives/private-async-helpers.js.map +1 -0
- package/front_end/third_party/lit-html/package/development/directives/ref.d.ts +14 -11
- package/front_end/third_party/lit-html/package/development/directives/ref.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/development/directives/ref.js +13 -11
- package/front_end/third_party/lit-html/package/development/directives/ref.js.map +1 -1
- package/front_end/third_party/lit-html/package/development/directives/repeat.d.ts +8 -4
- package/front_end/third_party/lit-html/package/development/directives/repeat.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/development/directives/repeat.js +23 -9
- package/front_end/third_party/lit-html/package/development/directives/repeat.js.map +1 -1
- package/front_end/third_party/lit-html/package/development/directives/style-map.d.ts +1 -2
- package/front_end/third_party/lit-html/package/development/directives/style-map.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/development/directives/style-map.js +1 -2
- package/front_end/third_party/lit-html/package/development/directives/style-map.js.map +1 -1
- package/front_end/third_party/lit-html/package/development/directives/template-content.d.ts +1 -2
- package/front_end/third_party/lit-html/package/development/directives/template-content.js +1 -2
- package/front_end/third_party/lit-html/package/development/directives/unsafe-html.d.ts +6 -4
- package/front_end/third_party/lit-html/package/development/directives/unsafe-html.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/development/directives/unsafe-html.js +7 -5
- package/front_end/third_party/lit-html/package/development/directives/unsafe-html.js.map +1 -1
- package/front_end/third_party/lit-html/package/development/directives/unsafe-svg.d.ts +4 -1
- package/front_end/third_party/lit-html/package/development/directives/unsafe-svg.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/development/directives/unsafe-svg.js +3 -0
- package/front_end/third_party/lit-html/package/development/directives/unsafe-svg.js.map +1 -1
- package/front_end/third_party/lit-html/package/development/directives/until.d.ts +12 -8
- package/front_end/third_party/lit-html/package/development/directives/until.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/development/directives/until.js +63 -23
- package/front_end/third_party/lit-html/package/development/directives/until.js.map +1 -1
- package/front_end/third_party/lit-html/package/development/experimental-hydrate.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/development/experimental-hydrate.js +9 -8
- package/front_end/third_party/lit-html/package/development/experimental-hydrate.js.map +1 -1
- package/front_end/third_party/lit-html/package/development/lit-html.d.ts +81 -136
- package/front_end/third_party/lit-html/package/development/lit-html.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/development/lit-html.js +249 -76
- package/front_end/third_party/lit-html/package/development/lit-html.js.map +1 -1
- package/front_end/third_party/lit-html/package/development/polyfill-support.d.ts +1 -41
- package/front_end/third_party/lit-html/package/development/polyfill-support.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/development/polyfill-support.js +40 -21
- package/front_end/third_party/lit-html/package/development/polyfill-support.js.map +1 -1
- package/front_end/third_party/lit-html/package/development/private-ssr-support.d.ts +12 -10
- package/front_end/third_party/lit-html/package/development/private-ssr-support.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/development/private-ssr-support.js +11 -3
- package/front_end/third_party/lit-html/package/development/private-ssr-support.js.map +1 -1
- package/front_end/third_party/lit-html/package/development/static.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/development/static.js +6 -5
- package/front_end/third_party/lit-html/package/development/static.js.map +1 -1
- package/front_end/third_party/lit-html/package/directive-helpers.d.ts +6 -5
- package/front_end/third_party/lit-html/package/directive-helpers.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/directive-helpers.js +2 -2
- package/front_end/third_party/lit-html/package/directive-helpers.js.map +1 -1
- package/front_end/third_party/lit-html/package/directive.d.ts +3 -16
- package/front_end/third_party/lit-html/package/directive.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/directive.js +1 -1
- package/front_end/third_party/lit-html/package/directive.js.map +1 -1
- package/front_end/third_party/lit-html/package/directives/async-append.d.ts +7 -14
- package/front_end/third_party/lit-html/package/directives/async-append.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/directives/async-append.js +2 -6
- package/front_end/third_party/lit-html/package/directives/async-append.js.map +1 -1
- package/front_end/third_party/lit-html/package/directives/async-replace.d.ts +9 -14
- package/front_end/third_party/lit-html/package/directives/async-replace.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/directives/async-replace.js +2 -5
- package/front_end/third_party/lit-html/package/directives/async-replace.js.map +1 -1
- package/front_end/third_party/lit-html/package/directives/cache.d.ts +2 -3
- package/front_end/third_party/lit-html/package/directives/cache.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/directives/cache.js +2 -5
- package/front_end/third_party/lit-html/package/directives/cache.js.map +1 -1
- package/front_end/third_party/lit-html/package/directives/class-map.d.ts +2 -2
- package/front_end/third_party/lit-html/package/directives/class-map.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/directives/class-map.js +2 -4
- package/front_end/third_party/lit-html/package/directives/class-map.js.map +1 -1
- package/front_end/third_party/lit-html/package/directives/guard.d.ts +3 -2
- package/front_end/third_party/lit-html/package/directives/guard.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/directives/guard.js +2 -4
- package/front_end/third_party/lit-html/package/directives/guard.js.map +1 -1
- package/front_end/third_party/lit-html/package/directives/live.d.ts +4 -3
- package/front_end/third_party/lit-html/package/directives/live.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/directives/live.js +1 -4
- package/front_end/third_party/lit-html/package/directives/live.js.map +1 -1
- package/front_end/third_party/lit-html/package/directives/private-async-helpers.d.ts +58 -0
- package/front_end/third_party/lit-html/package/directives/private-async-helpers.d.ts.map +1 -0
- package/front_end/third_party/lit-html/package/directives/private-async-helpers.js +7 -0
- package/front_end/third_party/lit-html/package/directives/private-async-helpers.js.map +1 -0
- package/front_end/third_party/lit-html/package/directives/ref.d.ts +14 -11
- package/front_end/third_party/lit-html/package/directives/ref.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/directives/ref.js +2 -5
- package/front_end/third_party/lit-html/package/directives/ref.js.map +1 -1
- package/front_end/third_party/lit-html/package/directives/repeat.d.ts +8 -4
- package/front_end/third_party/lit-html/package/directives/repeat.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/directives/repeat.js +2 -5
- package/front_end/third_party/lit-html/package/directives/repeat.js.map +1 -1
- package/front_end/third_party/lit-html/package/directives/style-map.d.ts +1 -2
- package/front_end/third_party/lit-html/package/directives/style-map.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/directives/style-map.js +2 -4
- package/front_end/third_party/lit-html/package/directives/style-map.js.map +1 -1
- package/front_end/third_party/lit-html/package/directives/template-content.d.ts +1 -2
- package/front_end/third_party/lit-html/package/directives/template-content.js +2 -4
- package/front_end/third_party/lit-html/package/directives/template-content.js.map +1 -1
- package/front_end/third_party/lit-html/package/directives/unsafe-html.d.ts +6 -4
- package/front_end/third_party/lit-html/package/directives/unsafe-html.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/directives/unsafe-html.js +2 -4
- package/front_end/third_party/lit-html/package/directives/unsafe-html.js.map +1 -1
- package/front_end/third_party/lit-html/package/directives/unsafe-svg.d.ts +4 -1
- package/front_end/third_party/lit-html/package/directives/unsafe-svg.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/directives/unsafe-svg.js.map +1 -1
- package/front_end/third_party/lit-html/package/directives/until.d.ts +12 -8
- package/front_end/third_party/lit-html/package/directives/until.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/directives/until.js +2 -6
- package/front_end/third_party/lit-html/package/directives/until.js.map +1 -1
- package/front_end/third_party/lit-html/package/experimental-hydrate.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/experimental-hydrate.js +2 -5
- package/front_end/third_party/lit-html/package/experimental-hydrate.js.map +1 -1
- package/front_end/third_party/lit-html/package/lit-html.d.ts +81 -136
- package/front_end/third_party/lit-html/package/lit-html.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/lit-html.js +1 -1
- package/front_end/third_party/lit-html/package/lit-html.js.map +1 -1
- package/front_end/third_party/lit-html/package/package.json +75 -24
- package/front_end/third_party/lit-html/package/polyfill-support.d.ts +1 -41
- package/front_end/third_party/lit-html/package/polyfill-support.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/polyfill-support.js +1 -1
- package/front_end/third_party/lit-html/package/polyfill-support.js.map +1 -1
- package/front_end/third_party/lit-html/package/private-ssr-support.d.ts +12 -10
- package/front_end/third_party/lit-html/package/private-ssr-support.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/private-ssr-support.js +2 -2
- package/front_end/third_party/lit-html/package/private-ssr-support.js.map +1 -1
- package/front_end/third_party/lit-html/package/static.d.ts.map +1 -1
- package/front_end/third_party/lit-html/package/static.js +1 -1
- package/front_end/third_party/lit-html/package/static.js.map +1 -1
- package/front_end/third_party/marked/README.chromium +2 -2
- package/front_end/third_party/marked/marked.ts +2 -2
- package/front_end/third_party/marked/package/README.md +7 -1
- package/front_end/third_party/marked/package/bin/marked.js +214 -0
- package/front_end/third_party/marked/package/lib/marked.cjs +2907 -0
- package/front_end/third_party/marked/package/lib/marked.esm.d.ts +1 -3
- package/front_end/third_party/marked/package/lib/marked.esm.js +627 -586
- package/front_end/third_party/marked/package/lib/marked.umd.js +2913 -0
- package/front_end/third_party/marked/package/man/marked.1 +5 -24
- package/front_end/third_party/marked/package/man/marked.1.txt +21 -31
- package/front_end/third_party/marked/package/marked.min.js +1 -1
- package/front_end/third_party/marked/package/package.json +41 -32
- package/front_end/third_party/marked/package/src/Lexer.js +109 -108
- package/front_end/third_party/marked/package/src/Parser.js +38 -15
- package/front_end/third_party/marked/package/src/Renderer.js +5 -5
- package/front_end/third_party/marked/package/src/Slugger.js +2 -2
- package/front_end/third_party/marked/package/src/TextRenderer.js +2 -2
- package/front_end/third_party/marked/package/src/Tokenizer.js +215 -190
- package/front_end/third_party/marked/package/src/defaults.js +6 -9
- package/front_end/third_party/marked/package/src/helpers.js +16 -27
- package/front_end/third_party/marked/package/src/marked.js +146 -63
- package/front_end/third_party/marked/package/src/rules.js +20 -45
- package/front_end/third_party/wasmparser/README.chromium +2 -2
- package/front_end/third_party/wasmparser/package/.github/workflows/main.yml +47 -0
- package/front_end/third_party/wasmparser/package/CHANGELOG.md +12 -0
- package/front_end/third_party/wasmparser/package/dist/cjs/WasmParser.js +53 -53
- package/front_end/third_party/wasmparser/package/dist/cjs/WasmParser.js.map +1 -1
- package/front_end/third_party/wasmparser/package/dist/esm/WasmParser.js +53 -53
- package/front_end/third_party/wasmparser/package/dist/esm/WasmParser.js.map +1 -1
- package/front_end/third_party/wasmparser/package/package.json +1 -1
- package/front_end/third_party/wasmparser/package/src/WasmParser.ts +53 -53
- package/front_end/ui/components/adorners/Adorner.ts +14 -14
- package/front_end/ui/components/buttons/Button.ts +116 -42
- package/front_end/ui/components/data_grid/DataGrid.ts +122 -122
- package/front_end/ui/components/data_grid/DataGridController.ts +42 -42
- package/front_end/ui/components/diff_view/DiffView.ts +4 -4
- package/front_end/ui/components/docs/button/basic.html +3 -0
- package/front_end/ui/components/docs/button/basic.ts +16 -0
- package/front_end/ui/components/expandable_list/ExpandableList.ts +11 -11
- package/front_end/ui/components/icon_button/Icon.ts +24 -21
- package/front_end/ui/components/icon_button/IconButton.ts +31 -31
- package/front_end/ui/components/issue_counter/IssueCounter.ts +52 -52
- package/front_end/ui/components/issue_counter/IssueLinkIcon.ts +42 -42
- package/front_end/ui/components/linear_memory_inspector/LinearMemoryInspector.ts +67 -67
- package/front_end/ui/components/linear_memory_inspector/LinearMemoryInspectorController.ts +22 -22
- package/front_end/ui/components/linear_memory_inspector/LinearMemoryInspectorPane.ts +36 -36
- package/front_end/ui/components/linear_memory_inspector/LinearMemoryNavigator.ts +19 -19
- package/front_end/ui/components/linear_memory_inspector/LinearMemoryValueInterpreter.ts +25 -25
- package/front_end/ui/components/linear_memory_inspector/LinearMemoryViewer.ts +52 -52
- package/front_end/ui/components/linear_memory_inspector/ValueInterpreterDisplay.ts +21 -21
- package/front_end/ui/components/linear_memory_inspector/ValueInterpreterSettings.ts +6 -6
- package/front_end/ui/components/markdown_view/MarkdownImage.ts +14 -14
- package/front_end/ui/components/markdown_view/MarkdownLink.ts +8 -8
- package/front_end/ui/components/markdown_view/MarkdownView.ts +6 -6
- package/front_end/ui/components/render_coordinator/RenderCoordinator.ts +33 -33
- package/front_end/ui/components/report_view/ReportView.ts +18 -18
- package/front_end/ui/components/request_link_icon/RequestLinkIcon.ts +53 -53
- package/front_end/ui/components/settings/SettingCheckbox.ts +15 -15
- package/front_end/ui/components/survey_link/SurveyLink.ts +28 -28
- package/front_end/ui/components/text_editor/TextEditor.ts +65 -36
- package/front_end/ui/components/text_editor/config.ts +36 -14
- package/front_end/ui/components/text_editor/javascript.ts +20 -15
- package/front_end/ui/components/text_editor/theme.ts +29 -4
- package/front_end/ui/components/text_prompt/TextPrompt.ts +19 -19
- package/front_end/ui/components/tree_outline/TreeOutline.ts +56 -56
- package/front_end/ui/legacy/Infobar.ts +9 -0
- package/front_end/ui/legacy/InspectorView.ts +1 -1
- package/front_end/ui/legacy/ViewManager.ts +6 -0
- package/front_end/ui/legacy/components/cookie_table/CookiesTable.ts +20 -0
- package/front_end/ui/legacy/components/source_frame/SourceFrame.ts +1 -0
- package/front_end/ui/legacy/components/utils/Linkifier.ts +49 -79
- package/front_end/ui/legacy/tabbedPane.css +1 -1
- package/front_end/ui/legacy/themeColors.css +2 -0
- package/inspector_overlay/main.ts +3 -0
- package/package.json +1 -1
|
@@ -9,16 +9,11 @@
|
|
|
9
9
|
* The code in this file is generated from files in ./src/
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
function createCommonjsModule(fn) {
|
|
13
|
-
var module = { exports: {} };
|
|
14
|
-
return fn(module, module.exports), module.exports;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
var defaults$5 = createCommonjsModule(function (module) {
|
|
18
12
|
function getDefaults() {
|
|
19
13
|
return {
|
|
20
14
|
baseUrl: null,
|
|
21
15
|
breaks: false,
|
|
16
|
+
extensions: null,
|
|
22
17
|
gfm: true,
|
|
23
18
|
headerIds: true,
|
|
24
19
|
headerPrefix: '',
|
|
@@ -38,17 +33,12 @@ function getDefaults() {
|
|
|
38
33
|
};
|
|
39
34
|
}
|
|
40
35
|
|
|
36
|
+
let defaults = getDefaults();
|
|
37
|
+
|
|
41
38
|
function changeDefaults(newDefaults) {
|
|
42
|
-
|
|
39
|
+
defaults = newDefaults;
|
|
43
40
|
}
|
|
44
41
|
|
|
45
|
-
module.exports = {
|
|
46
|
-
defaults: getDefaults(),
|
|
47
|
-
getDefaults,
|
|
48
|
-
changeDefaults
|
|
49
|
-
};
|
|
50
|
-
});
|
|
51
|
-
|
|
52
42
|
/**
|
|
53
43
|
* Helpers
|
|
54
44
|
*/
|
|
@@ -64,7 +54,7 @@ const escapeReplacements = {
|
|
|
64
54
|
"'": '''
|
|
65
55
|
};
|
|
66
56
|
const getEscapeReplacement = (ch) => escapeReplacements[ch];
|
|
67
|
-
function escape
|
|
57
|
+
function escape(html, encode) {
|
|
68
58
|
if (encode) {
|
|
69
59
|
if (escapeTest.test(html)) {
|
|
70
60
|
return html.replace(escapeReplace, getEscapeReplacement);
|
|
@@ -80,7 +70,7 @@ function escape$3(html, encode) {
|
|
|
80
70
|
|
|
81
71
|
const unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
|
|
82
72
|
|
|
83
|
-
function unescape
|
|
73
|
+
function unescape(html) {
|
|
84
74
|
// explicitly match decimal, hex, and named HTML entities
|
|
85
75
|
return html.replace(unescapeTest, (_, n) => {
|
|
86
76
|
n = n.toLowerCase();
|
|
@@ -95,7 +85,7 @@ function unescape$1(html) {
|
|
|
95
85
|
}
|
|
96
86
|
|
|
97
87
|
const caret = /(^|[^\[])\^/g;
|
|
98
|
-
function edit
|
|
88
|
+
function edit(regex, opt) {
|
|
99
89
|
regex = regex.source || regex;
|
|
100
90
|
opt = opt || '';
|
|
101
91
|
const obj = {
|
|
@@ -114,11 +104,11 @@ function edit$1(regex, opt) {
|
|
|
114
104
|
|
|
115
105
|
const nonWordAndColonTest = /[^\w:]/g;
|
|
116
106
|
const originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
|
|
117
|
-
function cleanUrl
|
|
107
|
+
function cleanUrl(sanitize, base, href) {
|
|
118
108
|
if (sanitize) {
|
|
119
109
|
let prot;
|
|
120
110
|
try {
|
|
121
|
-
prot = decodeURIComponent(unescape
|
|
111
|
+
prot = decodeURIComponent(unescape(href))
|
|
122
112
|
.replace(nonWordAndColonTest, '')
|
|
123
113
|
.toLowerCase();
|
|
124
114
|
} catch (e) {
|
|
@@ -152,7 +142,7 @@ function resolveUrl(base, href) {
|
|
|
152
142
|
if (justDomain.test(base)) {
|
|
153
143
|
baseUrls[' ' + base] = base + '/';
|
|
154
144
|
} else {
|
|
155
|
-
baseUrls[' ' + base] = rtrim
|
|
145
|
+
baseUrls[' ' + base] = rtrim(base, '/', true);
|
|
156
146
|
}
|
|
157
147
|
}
|
|
158
148
|
base = baseUrls[' ' + base];
|
|
@@ -173,9 +163,9 @@ function resolveUrl(base, href) {
|
|
|
173
163
|
}
|
|
174
164
|
}
|
|
175
165
|
|
|
176
|
-
const noopTest
|
|
166
|
+
const noopTest = { exec: function noopTest() {} };
|
|
177
167
|
|
|
178
|
-
function merge
|
|
168
|
+
function merge(obj) {
|
|
179
169
|
let i = 1,
|
|
180
170
|
target,
|
|
181
171
|
key;
|
|
@@ -192,7 +182,7 @@ function merge$2(obj) {
|
|
|
192
182
|
return obj;
|
|
193
183
|
}
|
|
194
184
|
|
|
195
|
-
function splitCells
|
|
185
|
+
function splitCells(tableRow, count) {
|
|
196
186
|
// ensure that every cell-delimiting pipe has a space
|
|
197
187
|
// before it to distinguish it from an escaped pipe
|
|
198
188
|
const row = tableRow.replace(/\|/g, (match, offset, str) => {
|
|
@@ -211,6 +201,10 @@ function splitCells$1(tableRow, count) {
|
|
|
211
201
|
cells = row.split(/ \|/);
|
|
212
202
|
let i = 0;
|
|
213
203
|
|
|
204
|
+
// First/last cell in a row cannot be empty if it has no leading/trailing pipe
|
|
205
|
+
if (!cells[0].trim()) { cells.shift(); }
|
|
206
|
+
if (!cells[cells.length - 1].trim()) { cells.pop(); }
|
|
207
|
+
|
|
214
208
|
if (cells.length > count) {
|
|
215
209
|
cells.splice(count);
|
|
216
210
|
} else {
|
|
@@ -227,7 +221,7 @@ function splitCells$1(tableRow, count) {
|
|
|
227
221
|
// Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
|
|
228
222
|
// /c*$/ is vulnerable to REDOS.
|
|
229
223
|
// invert: Remove suffix of non-c chars instead. Default falsey.
|
|
230
|
-
function rtrim
|
|
224
|
+
function rtrim(str, c, invert) {
|
|
231
225
|
const l = str.length;
|
|
232
226
|
if (l === 0) {
|
|
233
227
|
return '';
|
|
@@ -251,7 +245,7 @@ function rtrim$1(str, c, invert) {
|
|
|
251
245
|
return str.substr(0, l - suffLen);
|
|
252
246
|
}
|
|
253
247
|
|
|
254
|
-
function findClosingBracket
|
|
248
|
+
function findClosingBracket(str, b) {
|
|
255
249
|
if (str.indexOf(b[1]) === -1) {
|
|
256
250
|
return -1;
|
|
257
251
|
}
|
|
@@ -273,14 +267,14 @@ function findClosingBracket$1(str, b) {
|
|
|
273
267
|
return -1;
|
|
274
268
|
}
|
|
275
269
|
|
|
276
|
-
function checkSanitizeDeprecation
|
|
270
|
+
function checkSanitizeDeprecation(opt) {
|
|
277
271
|
if (opt && opt.sanitize && !opt.silent) {
|
|
278
272
|
console.warn('marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options');
|
|
279
273
|
}
|
|
280
274
|
}
|
|
281
275
|
|
|
282
276
|
// copied from https://stackoverflow.com/a/5450113/806777
|
|
283
|
-
function repeatString
|
|
277
|
+
function repeatString(pattern, count) {
|
|
284
278
|
if (count < 1) {
|
|
285
279
|
return '';
|
|
286
280
|
}
|
|
@@ -295,49 +289,30 @@ function repeatString$1(pattern, count) {
|
|
|
295
289
|
return result + pattern;
|
|
296
290
|
}
|
|
297
291
|
|
|
298
|
-
|
|
299
|
-
escape: escape$3,
|
|
300
|
-
unescape: unescape$1,
|
|
301
|
-
edit: edit$1,
|
|
302
|
-
cleanUrl: cleanUrl$1,
|
|
303
|
-
resolveUrl,
|
|
304
|
-
noopTest: noopTest$1,
|
|
305
|
-
merge: merge$2,
|
|
306
|
-
splitCells: splitCells$1,
|
|
307
|
-
rtrim: rtrim$1,
|
|
308
|
-
findClosingBracket: findClosingBracket$1,
|
|
309
|
-
checkSanitizeDeprecation: checkSanitizeDeprecation$1,
|
|
310
|
-
repeatString: repeatString$1
|
|
311
|
-
};
|
|
312
|
-
|
|
313
|
-
const { defaults: defaults$4 } = defaults$5;
|
|
314
|
-
const {
|
|
315
|
-
rtrim,
|
|
316
|
-
splitCells,
|
|
317
|
-
escape: escape$2,
|
|
318
|
-
findClosingBracket
|
|
319
|
-
} = helpers;
|
|
320
|
-
|
|
321
|
-
function outputLink(cap, link, raw) {
|
|
292
|
+
function outputLink(cap, link, raw, lexer) {
|
|
322
293
|
const href = link.href;
|
|
323
|
-
const title = link.title ? escape
|
|
294
|
+
const title = link.title ? escape(link.title) : null;
|
|
324
295
|
const text = cap[1].replace(/\\([\[\]])/g, '$1');
|
|
325
296
|
|
|
326
297
|
if (cap[0].charAt(0) !== '!') {
|
|
327
|
-
|
|
298
|
+
lexer.state.inLink = true;
|
|
299
|
+
const token = {
|
|
328
300
|
type: 'link',
|
|
329
301
|
raw,
|
|
330
302
|
href,
|
|
331
303
|
title,
|
|
332
|
-
text
|
|
304
|
+
text,
|
|
305
|
+
tokens: lexer.inlineTokens(text, [])
|
|
333
306
|
};
|
|
307
|
+
lexer.state.inLink = false;
|
|
308
|
+
return token;
|
|
334
309
|
} else {
|
|
335
310
|
return {
|
|
336
311
|
type: 'image',
|
|
337
312
|
raw,
|
|
338
313
|
href,
|
|
339
314
|
title,
|
|
340
|
-
text: escape
|
|
315
|
+
text: escape(text)
|
|
341
316
|
};
|
|
342
317
|
}
|
|
343
318
|
}
|
|
@@ -373,9 +348,9 @@ function indentCodeCompensation(raw, text) {
|
|
|
373
348
|
/**
|
|
374
349
|
* Tokenizer
|
|
375
350
|
*/
|
|
376
|
-
|
|
351
|
+
class Tokenizer {
|
|
377
352
|
constructor(options) {
|
|
378
|
-
this.options = options || defaults
|
|
353
|
+
this.options = options || defaults;
|
|
379
354
|
}
|
|
380
355
|
|
|
381
356
|
space(src) {
|
|
@@ -437,48 +412,15 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
437
412
|
}
|
|
438
413
|
}
|
|
439
414
|
|
|
440
|
-
|
|
415
|
+
const token = {
|
|
441
416
|
type: 'heading',
|
|
442
417
|
raw: cap[0],
|
|
443
418
|
depth: cap[1].length,
|
|
444
|
-
text: text
|
|
419
|
+
text: text,
|
|
420
|
+
tokens: []
|
|
445
421
|
};
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
nptable(src) {
|
|
450
|
-
const cap = this.rules.block.nptable.exec(src);
|
|
451
|
-
if (cap) {
|
|
452
|
-
const item = {
|
|
453
|
-
type: 'table',
|
|
454
|
-
header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
|
|
455
|
-
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
|
|
456
|
-
cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : [],
|
|
457
|
-
raw: cap[0]
|
|
458
|
-
};
|
|
459
|
-
|
|
460
|
-
if (item.header.length === item.align.length) {
|
|
461
|
-
let l = item.align.length;
|
|
462
|
-
let i;
|
|
463
|
-
for (i = 0; i < l; i++) {
|
|
464
|
-
if (/^ *-+: *$/.test(item.align[i])) {
|
|
465
|
-
item.align[i] = 'right';
|
|
466
|
-
} else if (/^ *:-+: *$/.test(item.align[i])) {
|
|
467
|
-
item.align[i] = 'center';
|
|
468
|
-
} else if (/^ *:-+ *$/.test(item.align[i])) {
|
|
469
|
-
item.align[i] = 'left';
|
|
470
|
-
} else {
|
|
471
|
-
item.align[i] = null;
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
l = item.cells.length;
|
|
476
|
-
for (i = 0; i < l; i++) {
|
|
477
|
-
item.cells[i] = splitCells(item.cells[i], item.header.length);
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
return item;
|
|
481
|
-
}
|
|
422
|
+
this.lexer.inline(token.text, token.tokens);
|
|
423
|
+
return token;
|
|
482
424
|
}
|
|
483
425
|
}
|
|
484
426
|
|
|
@@ -500,138 +442,155 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
500
442
|
return {
|
|
501
443
|
type: 'blockquote',
|
|
502
444
|
raw: cap[0],
|
|
445
|
+
tokens: this.lexer.blockTokens(text, []),
|
|
503
446
|
text
|
|
504
447
|
};
|
|
505
448
|
}
|
|
506
449
|
}
|
|
507
450
|
|
|
508
451
|
list(src) {
|
|
509
|
-
|
|
452
|
+
let cap = this.rules.block.list.exec(src);
|
|
510
453
|
if (cap) {
|
|
511
|
-
let raw
|
|
512
|
-
|
|
454
|
+
let raw, istask, ischecked, indent, i, blankLine, endsWithBlankLine,
|
|
455
|
+
line, lines, itemContents;
|
|
456
|
+
|
|
457
|
+
let bull = cap[1].trim();
|
|
513
458
|
const isordered = bull.length > 1;
|
|
514
459
|
|
|
515
460
|
const list = {
|
|
516
461
|
type: 'list',
|
|
517
|
-
raw,
|
|
462
|
+
raw: '',
|
|
518
463
|
ordered: isordered,
|
|
519
464
|
start: isordered ? +bull.slice(0, -1) : '',
|
|
520
465
|
loose: false,
|
|
521
466
|
items: []
|
|
522
467
|
};
|
|
523
468
|
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
let l = itemMatch.length;
|
|
539
|
-
bcurr = this.rules.block.listItemStart.exec(itemMatch[0]);
|
|
540
|
-
for (let i = 0; i < l; i++) {
|
|
541
|
-
item = itemMatch[i];
|
|
542
|
-
raw = item;
|
|
543
|
-
|
|
544
|
-
if (!this.options.pedantic) {
|
|
545
|
-
// Determine if current item contains the end of the list
|
|
546
|
-
endMatch = item.match(new RegExp('\\n\\s*\\n {0,' + (bcurr[0].length - 1) + '}\\S'));
|
|
547
|
-
if (endMatch) {
|
|
548
|
-
addBack = item.length - endMatch.index + itemMatch.slice(i + 1).join('\n').length;
|
|
549
|
-
list.raw = list.raw.substring(0, list.raw.length - addBack);
|
|
550
|
-
|
|
551
|
-
item = item.substring(0, endMatch.index);
|
|
552
|
-
raw = item;
|
|
553
|
-
l = i + 1;
|
|
554
|
-
}
|
|
469
|
+
bull = isordered ? `\\d{1,9}\\${bull.slice(-1)}` : `\\${bull}`;
|
|
470
|
+
|
|
471
|
+
if (this.options.pedantic) {
|
|
472
|
+
bull = isordered ? bull : '[*+-]';
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
// Get next list item
|
|
476
|
+
const itemRegex = new RegExp(`^( {0,3}${bull})((?: [^\\n]*| *)(?:\\n[^\\n]*)*(?:\\n|$))`);
|
|
477
|
+
|
|
478
|
+
// Get each top-level item
|
|
479
|
+
while (src) {
|
|
480
|
+
if (this.rules.block.hr.test(src)) { // End list if we encounter an HR (possibly move into itemRegex?)
|
|
481
|
+
break;
|
|
555
482
|
}
|
|
556
483
|
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
if (i !== l - 1) {
|
|
560
|
-
bnext = this.rules.block.listItemStart.exec(itemMatch[i + 1]);
|
|
561
|
-
if (
|
|
562
|
-
!this.options.pedantic
|
|
563
|
-
? bnext[1].length >= bcurr[0].length || bnext[1].length > 3
|
|
564
|
-
: bnext[1].length > bcurr[1].length
|
|
565
|
-
) {
|
|
566
|
-
// nested list or continuation
|
|
567
|
-
itemMatch.splice(i, 2, itemMatch[i] + (!this.options.pedantic && bnext[1].length < bcurr[0].length && !itemMatch[i].match(/\n$/) ? '' : '\n') + itemMatch[i + 1]);
|
|
568
|
-
i--;
|
|
569
|
-
l--;
|
|
570
|
-
continue;
|
|
571
|
-
} else if (
|
|
572
|
-
// different bullet style
|
|
573
|
-
!this.options.pedantic || this.options.smartLists
|
|
574
|
-
? bnext[2][bnext[2].length - 1] !== bull[bull.length - 1]
|
|
575
|
-
: isordered === (bnext[2].length === 1)
|
|
576
|
-
) {
|
|
577
|
-
addBack = itemMatch.slice(i + 1).join('\n').length;
|
|
578
|
-
list.raw = list.raw.substring(0, list.raw.length - addBack);
|
|
579
|
-
i = l - 1;
|
|
580
|
-
}
|
|
581
|
-
bcurr = bnext;
|
|
484
|
+
if (!(cap = itemRegex.exec(src))) {
|
|
485
|
+
break;
|
|
582
486
|
}
|
|
583
487
|
|
|
584
|
-
|
|
585
|
-
// so it is seen as the next token.
|
|
586
|
-
space = item.length;
|
|
587
|
-
item = item.replace(/^ *([*+-]|\d+[.)]) ?/, '');
|
|
488
|
+
lines = cap[2].split('\n');
|
|
588
489
|
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
490
|
+
if (this.options.pedantic) {
|
|
491
|
+
indent = 2;
|
|
492
|
+
itemContents = lines[0].trimLeft();
|
|
493
|
+
} else {
|
|
494
|
+
indent = cap[2].search(/[^ ]/); // Find first non-space char
|
|
495
|
+
indent = cap[1].length + (indent > 4 ? 1 : indent); // intented code blocks after 4 spaces; indent is always 1
|
|
496
|
+
itemContents = lines[0].slice(indent - cap[1].length);
|
|
596
497
|
}
|
|
597
498
|
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
499
|
+
blankLine = false;
|
|
500
|
+
raw = cap[0];
|
|
501
|
+
|
|
502
|
+
if (!lines[0] && /^ *$/.test(lines[1])) { // items begin with at most one blank line
|
|
503
|
+
raw = cap[1] + lines.slice(0, 2).join('\n') + '\n';
|
|
504
|
+
list.loose = true;
|
|
505
|
+
lines = [];
|
|
602
506
|
}
|
|
603
507
|
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
508
|
+
const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])`);
|
|
509
|
+
|
|
510
|
+
for (i = 1; i < lines.length; i++) {
|
|
511
|
+
line = lines[i];
|
|
512
|
+
|
|
513
|
+
if (this.options.pedantic) { // Re-align to follow commonmark nesting rules
|
|
514
|
+
line = line.replace(/^ {1,4}(?=( {4})*[^ ])/g, ' ');
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
// End list item if found start of new bullet
|
|
518
|
+
if (nextBulletRegex.test(line)) {
|
|
519
|
+
raw = cap[1] + lines.slice(0, i).join('\n') + '\n';
|
|
520
|
+
break;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
// Until we encounter a blank line, item contents do not need indentation
|
|
524
|
+
if (!blankLine) {
|
|
525
|
+
if (!line.trim()) { // Check if current line is empty
|
|
526
|
+
blankLine = true;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
// Dedent if possible
|
|
530
|
+
if (line.search(/[^ ]/) >= indent) {
|
|
531
|
+
itemContents += '\n' + line.slice(indent);
|
|
532
|
+
} else {
|
|
533
|
+
itemContents += '\n' + line;
|
|
534
|
+
}
|
|
535
|
+
continue;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
// Dedent this line
|
|
539
|
+
if (line.search(/[^ ]/) >= indent || !line.trim()) {
|
|
540
|
+
itemContents += '\n' + line.slice(indent);
|
|
541
|
+
continue;
|
|
542
|
+
} else { // Line was not properly indented; end of this item
|
|
543
|
+
raw = cap[1] + lines.slice(0, i).join('\n') + '\n';
|
|
544
|
+
break;
|
|
545
|
+
}
|
|
611
546
|
}
|
|
612
547
|
|
|
613
|
-
if (loose) {
|
|
614
|
-
list
|
|
548
|
+
if (!list.loose) {
|
|
549
|
+
// If the previous item ended with a blank line, the list is loose
|
|
550
|
+
if (endsWithBlankLine) {
|
|
551
|
+
list.loose = true;
|
|
552
|
+
} else if (/\n *\n *$/.test(raw)) {
|
|
553
|
+
endsWithBlankLine = true;
|
|
554
|
+
}
|
|
615
555
|
}
|
|
616
556
|
|
|
617
557
|
// Check for task list items
|
|
618
558
|
if (this.options.gfm) {
|
|
619
|
-
istask = /^\[[ xX]\] /.
|
|
620
|
-
ischecked = undefined;
|
|
559
|
+
istask = /^\[[ xX]\] /.exec(itemContents);
|
|
621
560
|
if (istask) {
|
|
622
|
-
ischecked =
|
|
623
|
-
|
|
561
|
+
ischecked = istask[0] !== '[ ] ';
|
|
562
|
+
itemContents = itemContents.replace(/^\[[ xX]\] +/, '');
|
|
624
563
|
}
|
|
625
564
|
}
|
|
626
565
|
|
|
627
566
|
list.items.push({
|
|
628
567
|
type: 'list_item',
|
|
629
|
-
raw,
|
|
630
|
-
task: istask,
|
|
568
|
+
raw: raw,
|
|
569
|
+
task: !!istask,
|
|
631
570
|
checked: ischecked,
|
|
632
|
-
loose:
|
|
633
|
-
text:
|
|
571
|
+
loose: false,
|
|
572
|
+
text: itemContents
|
|
634
573
|
});
|
|
574
|
+
|
|
575
|
+
list.raw += raw;
|
|
576
|
+
src = src.slice(raw.length);
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// Do not consume newlines at end of final item. Alternatively, make itemRegex *start* with any newlines to simplify/speed up endsWithBlankLine logic
|
|
580
|
+
list.items[list.items.length - 1].raw = raw.trimRight();
|
|
581
|
+
list.items[list.items.length - 1].text = itemContents.trimRight();
|
|
582
|
+
list.raw = list.raw.trimRight();
|
|
583
|
+
|
|
584
|
+
const l = list.items.length;
|
|
585
|
+
|
|
586
|
+
// Item child tokens handled here at end because we needed to have the final item to trim it first
|
|
587
|
+
for (i = 0; i < l; i++) {
|
|
588
|
+
this.lexer.state.top = false;
|
|
589
|
+
list.items[i].tokens = this.lexer.blockTokens(list.items[i].text, []);
|
|
590
|
+
if (list.items[i].tokens.some(t => t.type === 'space')) {
|
|
591
|
+
list.loose = true;
|
|
592
|
+
list.items[i].loose = true;
|
|
593
|
+
}
|
|
635
594
|
}
|
|
636
595
|
|
|
637
596
|
return list;
|
|
@@ -641,15 +600,20 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
641
600
|
html(src) {
|
|
642
601
|
const cap = this.rules.block.html.exec(src);
|
|
643
602
|
if (cap) {
|
|
644
|
-
|
|
645
|
-
type:
|
|
646
|
-
? 'paragraph'
|
|
647
|
-
: 'html',
|
|
603
|
+
const token = {
|
|
604
|
+
type: 'html',
|
|
648
605
|
raw: cap[0],
|
|
649
606
|
pre: !this.options.sanitizer
|
|
650
607
|
&& (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
|
|
651
|
-
text:
|
|
608
|
+
text: cap[0]
|
|
652
609
|
};
|
|
610
|
+
if (this.options.sanitize) {
|
|
611
|
+
token.type = 'paragraph';
|
|
612
|
+
token.text = this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]);
|
|
613
|
+
token.tokens = [];
|
|
614
|
+
this.lexer.inline(token.text, token.tokens);
|
|
615
|
+
}
|
|
616
|
+
return token;
|
|
653
617
|
}
|
|
654
618
|
}
|
|
655
619
|
|
|
@@ -673,16 +637,16 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
673
637
|
if (cap) {
|
|
674
638
|
const item = {
|
|
675
639
|
type: 'table',
|
|
676
|
-
header: splitCells(cap[1].
|
|
640
|
+
header: splitCells(cap[1]).map(c => { return { text: c }; }),
|
|
677
641
|
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
|
|
678
|
-
|
|
642
|
+
rows: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : []
|
|
679
643
|
};
|
|
680
644
|
|
|
681
645
|
if (item.header.length === item.align.length) {
|
|
682
646
|
item.raw = cap[0];
|
|
683
647
|
|
|
684
648
|
let l = item.align.length;
|
|
685
|
-
let i;
|
|
649
|
+
let i, j, k, row;
|
|
686
650
|
for (i = 0; i < l; i++) {
|
|
687
651
|
if (/^ *-+: *$/.test(item.align[i])) {
|
|
688
652
|
item.align[i] = 'right';
|
|
@@ -695,11 +659,28 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
695
659
|
}
|
|
696
660
|
}
|
|
697
661
|
|
|
698
|
-
l = item.
|
|
662
|
+
l = item.rows.length;
|
|
699
663
|
for (i = 0; i < l; i++) {
|
|
700
|
-
item.
|
|
701
|
-
|
|
702
|
-
|
|
664
|
+
item.rows[i] = splitCells(item.rows[i], item.header.length).map(c => { return { text: c }; });
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
// parse child tokens inside headers and cells
|
|
668
|
+
|
|
669
|
+
// header child tokens
|
|
670
|
+
l = item.header.length;
|
|
671
|
+
for (j = 0; j < l; j++) {
|
|
672
|
+
item.header[j].tokens = [];
|
|
673
|
+
this.lexer.inlineTokens(item.header[j].text, item.header[j].tokens);
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
// cell child tokens
|
|
677
|
+
l = item.rows.length;
|
|
678
|
+
for (j = 0; j < l; j++) {
|
|
679
|
+
row = item.rows[j];
|
|
680
|
+
for (k = 0; k < row.length; k++) {
|
|
681
|
+
row[k].tokens = [];
|
|
682
|
+
this.lexer.inlineTokens(row[k].text, row[k].tokens);
|
|
683
|
+
}
|
|
703
684
|
}
|
|
704
685
|
|
|
705
686
|
return item;
|
|
@@ -710,36 +691,45 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
710
691
|
lheading(src) {
|
|
711
692
|
const cap = this.rules.block.lheading.exec(src);
|
|
712
693
|
if (cap) {
|
|
713
|
-
|
|
694
|
+
const token = {
|
|
714
695
|
type: 'heading',
|
|
715
696
|
raw: cap[0],
|
|
716
697
|
depth: cap[2].charAt(0) === '=' ? 1 : 2,
|
|
717
|
-
text: cap[1]
|
|
698
|
+
text: cap[1],
|
|
699
|
+
tokens: []
|
|
718
700
|
};
|
|
701
|
+
this.lexer.inline(token.text, token.tokens);
|
|
702
|
+
return token;
|
|
719
703
|
}
|
|
720
704
|
}
|
|
721
705
|
|
|
722
706
|
paragraph(src) {
|
|
723
707
|
const cap = this.rules.block.paragraph.exec(src);
|
|
724
708
|
if (cap) {
|
|
725
|
-
|
|
709
|
+
const token = {
|
|
726
710
|
type: 'paragraph',
|
|
727
711
|
raw: cap[0],
|
|
728
712
|
text: cap[1].charAt(cap[1].length - 1) === '\n'
|
|
729
713
|
? cap[1].slice(0, -1)
|
|
730
|
-
: cap[1]
|
|
714
|
+
: cap[1],
|
|
715
|
+
tokens: []
|
|
731
716
|
};
|
|
717
|
+
this.lexer.inline(token.text, token.tokens);
|
|
718
|
+
return token;
|
|
732
719
|
}
|
|
733
720
|
}
|
|
734
721
|
|
|
735
722
|
text(src) {
|
|
736
723
|
const cap = this.rules.block.text.exec(src);
|
|
737
724
|
if (cap) {
|
|
738
|
-
|
|
725
|
+
const token = {
|
|
739
726
|
type: 'text',
|
|
740
727
|
raw: cap[0],
|
|
741
|
-
text: cap[0]
|
|
728
|
+
text: cap[0],
|
|
729
|
+
tokens: []
|
|
742
730
|
};
|
|
731
|
+
this.lexer.inline(token.text, token.tokens);
|
|
732
|
+
return token;
|
|
743
733
|
}
|
|
744
734
|
}
|
|
745
735
|
|
|
@@ -749,23 +739,23 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
749
739
|
return {
|
|
750
740
|
type: 'escape',
|
|
751
741
|
raw: cap[0],
|
|
752
|
-
text: escape
|
|
742
|
+
text: escape(cap[1])
|
|
753
743
|
};
|
|
754
744
|
}
|
|
755
745
|
}
|
|
756
746
|
|
|
757
|
-
tag(src
|
|
747
|
+
tag(src) {
|
|
758
748
|
const cap = this.rules.inline.tag.exec(src);
|
|
759
749
|
if (cap) {
|
|
760
|
-
if (!inLink && /^<a /i.test(cap[0])) {
|
|
761
|
-
inLink = true;
|
|
762
|
-
} else if (inLink && /^<\/a>/i.test(cap[0])) {
|
|
763
|
-
inLink = false;
|
|
750
|
+
if (!this.lexer.state.inLink && /^<a /i.test(cap[0])) {
|
|
751
|
+
this.lexer.state.inLink = true;
|
|
752
|
+
} else if (this.lexer.state.inLink && /^<\/a>/i.test(cap[0])) {
|
|
753
|
+
this.lexer.state.inLink = false;
|
|
764
754
|
}
|
|
765
|
-
if (!inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
|
|
766
|
-
inRawBlock = true;
|
|
767
|
-
} else if (inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
|
|
768
|
-
inRawBlock = false;
|
|
755
|
+
if (!this.lexer.state.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
|
|
756
|
+
this.lexer.state.inRawBlock = true;
|
|
757
|
+
} else if (this.lexer.state.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
|
|
758
|
+
this.lexer.state.inRawBlock = false;
|
|
769
759
|
}
|
|
770
760
|
|
|
771
761
|
return {
|
|
@@ -773,12 +763,12 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
773
763
|
? 'text'
|
|
774
764
|
: 'html',
|
|
775
765
|
raw: cap[0],
|
|
776
|
-
inLink,
|
|
777
|
-
inRawBlock,
|
|
766
|
+
inLink: this.lexer.state.inLink,
|
|
767
|
+
inRawBlock: this.lexer.state.inRawBlock,
|
|
778
768
|
text: this.options.sanitize
|
|
779
769
|
? (this.options.sanitizer
|
|
780
770
|
? this.options.sanitizer(cap[0])
|
|
781
|
-
: escape
|
|
771
|
+
: escape(cap[0]))
|
|
782
772
|
: cap[0]
|
|
783
773
|
};
|
|
784
774
|
}
|
|
@@ -836,7 +826,7 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
836
826
|
return outputLink(cap, {
|
|
837
827
|
href: href ? href.replace(this.rules.inline._escapes, '$1') : href,
|
|
838
828
|
title: title ? title.replace(this.rules.inline._escapes, '$1') : title
|
|
839
|
-
}, cap[0]);
|
|
829
|
+
}, cap[0], this.lexer);
|
|
840
830
|
}
|
|
841
831
|
}
|
|
842
832
|
|
|
@@ -854,7 +844,7 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
854
844
|
text
|
|
855
845
|
};
|
|
856
846
|
}
|
|
857
|
-
return outputLink(cap, link, cap[0]);
|
|
847
|
+
return outputLink(cap, link, cap[0], this.lexer);
|
|
858
848
|
}
|
|
859
849
|
}
|
|
860
850
|
|
|
@@ -862,7 +852,8 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
862
852
|
let match = this.rules.inline.emStrong.lDelim.exec(src);
|
|
863
853
|
if (!match) return;
|
|
864
854
|
|
|
865
|
-
|
|
855
|
+
// _ can't be between two alphanumerics. \p{L}\p{N} includes non-english alphabet/numbers as well
|
|
856
|
+
if (match[3] && prevChar.match(/[\p{L}\p{N}]/u)) return;
|
|
866
857
|
|
|
867
858
|
const nextChar = match[1] || match[2] || '';
|
|
868
859
|
|
|
@@ -873,12 +864,13 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
873
864
|
const endReg = match[0][0] === '*' ? this.rules.inline.emStrong.rDelimAst : this.rules.inline.emStrong.rDelimUnd;
|
|
874
865
|
endReg.lastIndex = 0;
|
|
875
866
|
|
|
876
|
-
|
|
867
|
+
// Clip maskedSrc to same section of string as src (move to lexer?)
|
|
868
|
+
maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
|
|
877
869
|
|
|
878
870
|
while ((match = endReg.exec(maskedSrc)) != null) {
|
|
879
871
|
rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
|
|
880
872
|
|
|
881
|
-
if (!rDelim) continue; //
|
|
873
|
+
if (!rDelim) continue; // skip single * in __abc*abc__
|
|
882
874
|
|
|
883
875
|
rLength = rDelim.length;
|
|
884
876
|
|
|
@@ -896,25 +888,28 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
896
888
|
|
|
897
889
|
if (delimTotal > 0) continue; // Haven't found enough closing delimiters
|
|
898
890
|
|
|
899
|
-
//
|
|
900
|
-
|
|
901
|
-
rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
|
|
902
|
-
}
|
|
891
|
+
// Remove extra characters. *a*** -> *a*
|
|
892
|
+
rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
|
|
903
893
|
|
|
894
|
+
// Create `em` if smallest delimiter has odd char count. *a***
|
|
904
895
|
if (Math.min(lLength, rLength) % 2) {
|
|
896
|
+
const text = src.slice(1, lLength + match.index + rLength);
|
|
905
897
|
return {
|
|
906
898
|
type: 'em',
|
|
907
899
|
raw: src.slice(0, lLength + match.index + rLength + 1),
|
|
908
|
-
text
|
|
909
|
-
|
|
910
|
-
}
|
|
911
|
-
if (Math.min(lLength, rLength) % 2 === 0) {
|
|
912
|
-
return {
|
|
913
|
-
type: 'strong',
|
|
914
|
-
raw: src.slice(0, lLength + match.index + rLength + 1),
|
|
915
|
-
text: src.slice(2, lLength + match.index + rLength - 1)
|
|
900
|
+
text,
|
|
901
|
+
tokens: this.lexer.inlineTokens(text, [])
|
|
916
902
|
};
|
|
917
903
|
}
|
|
904
|
+
|
|
905
|
+
// Create 'strong' if smallest delimiter has even char count. **a***
|
|
906
|
+
const text = src.slice(2, lLength + match.index + rLength - 1);
|
|
907
|
+
return {
|
|
908
|
+
type: 'strong',
|
|
909
|
+
raw: src.slice(0, lLength + match.index + rLength + 1),
|
|
910
|
+
text,
|
|
911
|
+
tokens: this.lexer.inlineTokens(text, [])
|
|
912
|
+
};
|
|
918
913
|
}
|
|
919
914
|
}
|
|
920
915
|
}
|
|
@@ -928,7 +923,7 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
928
923
|
if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
|
|
929
924
|
text = text.substring(1, text.length - 1);
|
|
930
925
|
}
|
|
931
|
-
text = escape
|
|
926
|
+
text = escape(text, true);
|
|
932
927
|
return {
|
|
933
928
|
type: 'codespan',
|
|
934
929
|
raw: cap[0],
|
|
@@ -953,7 +948,8 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
953
948
|
return {
|
|
954
949
|
type: 'del',
|
|
955
950
|
raw: cap[0],
|
|
956
|
-
text: cap[2]
|
|
951
|
+
text: cap[2],
|
|
952
|
+
tokens: this.lexer.inlineTokens(cap[2], [])
|
|
957
953
|
};
|
|
958
954
|
}
|
|
959
955
|
}
|
|
@@ -963,10 +959,10 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
963
959
|
if (cap) {
|
|
964
960
|
let text, href;
|
|
965
961
|
if (cap[2] === '@') {
|
|
966
|
-
text = escape
|
|
962
|
+
text = escape(this.options.mangle ? mangle(cap[1]) : cap[1]);
|
|
967
963
|
href = 'mailto:' + text;
|
|
968
964
|
} else {
|
|
969
|
-
text = escape
|
|
965
|
+
text = escape(cap[1]);
|
|
970
966
|
href = text;
|
|
971
967
|
}
|
|
972
968
|
|
|
@@ -991,7 +987,7 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
991
987
|
if (cap = this.rules.inline.url.exec(src)) {
|
|
992
988
|
let text, href;
|
|
993
989
|
if (cap[2] === '@') {
|
|
994
|
-
text = escape
|
|
990
|
+
text = escape(this.options.mangle ? mangle(cap[0]) : cap[0]);
|
|
995
991
|
href = 'mailto:' + text;
|
|
996
992
|
} else {
|
|
997
993
|
// do extended autolink path validation
|
|
@@ -1000,7 +996,7 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
1000
996
|
prevCapZero = cap[0];
|
|
1001
997
|
cap[0] = this.rules.inline._backpedal.exec(cap[0])[0];
|
|
1002
998
|
} while (prevCapZero !== cap[0]);
|
|
1003
|
-
text = escape
|
|
999
|
+
text = escape(cap[0]);
|
|
1004
1000
|
if (cap[1] === 'www.') {
|
|
1005
1001
|
href = 'http://' + text;
|
|
1006
1002
|
} else {
|
|
@@ -1023,14 +1019,14 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
1023
1019
|
}
|
|
1024
1020
|
}
|
|
1025
1021
|
|
|
1026
|
-
inlineText(src,
|
|
1022
|
+
inlineText(src, smartypants) {
|
|
1027
1023
|
const cap = this.rules.inline.text.exec(src);
|
|
1028
1024
|
if (cap) {
|
|
1029
1025
|
let text;
|
|
1030
|
-
if (inRawBlock) {
|
|
1031
|
-
text = this.options.sanitize ? (this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape
|
|
1026
|
+
if (this.lexer.state.inRawBlock) {
|
|
1027
|
+
text = this.options.sanitize ? (this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0])) : cap[0];
|
|
1032
1028
|
} else {
|
|
1033
|
-
text = escape
|
|
1029
|
+
text = escape(this.options.smartypants ? smartypants(cap[0]) : cap[0]);
|
|
1034
1030
|
}
|
|
1035
1031
|
return {
|
|
1036
1032
|
type: 'text',
|
|
@@ -1039,37 +1035,30 @@ var Tokenizer_1 = class Tokenizer {
|
|
|
1039
1035
|
};
|
|
1040
1036
|
}
|
|
1041
1037
|
}
|
|
1042
|
-
}
|
|
1043
|
-
|
|
1044
|
-
const {
|
|
1045
|
-
noopTest,
|
|
1046
|
-
edit,
|
|
1047
|
-
merge: merge$1
|
|
1048
|
-
} = helpers;
|
|
1038
|
+
}
|
|
1049
1039
|
|
|
1050
1040
|
/**
|
|
1051
1041
|
* Block-Level Grammar
|
|
1052
1042
|
*/
|
|
1053
|
-
const block
|
|
1043
|
+
const block = {
|
|
1054
1044
|
newline: /^(?: *(?:\n|$))+/,
|
|
1055
1045
|
code: /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,
|
|
1056
|
-
fences: /^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(
|
|
1046
|
+
fences: /^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?=\n|$)|$)/,
|
|
1057
1047
|
hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
|
|
1058
1048
|
heading: /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,
|
|
1059
1049
|
blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
|
|
1060
|
-
list: /^( {0,3})(
|
|
1050
|
+
list: /^( {0,3}bull)( [^\n]+?)?(?:\n|$)/,
|
|
1061
1051
|
html: '^ {0,3}(?:' // optional indentation
|
|
1062
|
-
+ '<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
|
|
1052
|
+
+ '<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
|
|
1063
1053
|
+ '|comment[^\\n]*(\\n+|$)' // (2)
|
|
1064
1054
|
+ '|<\\?[\\s\\S]*?(?:\\?>\\n*|$)' // (3)
|
|
1065
1055
|
+ '|<![A-Z][\\s\\S]*?(?:>\\n*|$)' // (4)
|
|
1066
1056
|
+ '|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)' // (5)
|
|
1067
|
-
+ '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n
|
|
1068
|
-
+ '|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n
|
|
1069
|
-
+ '|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n
|
|
1057
|
+
+ '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (6)
|
|
1058
|
+
+ '|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) open tag
|
|
1059
|
+
+ '|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) closing tag
|
|
1070
1060
|
+ ')',
|
|
1071
1061
|
def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
|
|
1072
|
-
nptable: noopTest,
|
|
1073
1062
|
table: noopTest,
|
|
1074
1063
|
lheading: /^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
1075
1064
|
// regex template, placeholders will be replaced according to different paragraph
|
|
@@ -1078,108 +1067,89 @@ const block$1 = {
|
|
|
1078
1067
|
text: /^[^\n]+/
|
|
1079
1068
|
};
|
|
1080
1069
|
|
|
1081
|
-
block
|
|
1082
|
-
block
|
|
1083
|
-
block
|
|
1084
|
-
.replace('label', block
|
|
1085
|
-
.replace('title', block
|
|
1086
|
-
.getRegex();
|
|
1087
|
-
|
|
1088
|
-
block$1.bullet = /(?:[*+-]|\d{1,9}[.)])/;
|
|
1089
|
-
block$1.item = /^( *)(bull) ?[^\n]*(?:\n(?! *bull ?)[^\n]*)*/;
|
|
1090
|
-
block$1.item = edit(block$1.item, 'gm')
|
|
1091
|
-
.replace(/bull/g, block$1.bullet)
|
|
1070
|
+
block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/;
|
|
1071
|
+
block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
|
|
1072
|
+
block.def = edit(block.def)
|
|
1073
|
+
.replace('label', block._label)
|
|
1074
|
+
.replace('title', block._title)
|
|
1092
1075
|
.getRegex();
|
|
1093
1076
|
|
|
1094
|
-
block
|
|
1095
|
-
|
|
1077
|
+
block.bullet = /(?:[*+-]|\d{1,9}[.)])/;
|
|
1078
|
+
block.listItemStart = edit(/^( *)(bull) */)
|
|
1079
|
+
.replace('bull', block.bullet)
|
|
1096
1080
|
.getRegex();
|
|
1097
1081
|
|
|
1098
|
-
block
|
|
1099
|
-
.replace(/bull/g, block
|
|
1082
|
+
block.list = edit(block.list)
|
|
1083
|
+
.replace(/bull/g, block.bullet)
|
|
1100
1084
|
.replace('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))')
|
|
1101
|
-
.replace('def', '\\n+(?=' + block
|
|
1085
|
+
.replace('def', '\\n+(?=' + block.def.source + ')')
|
|
1102
1086
|
.getRegex();
|
|
1103
1087
|
|
|
1104
|
-
block
|
|
1088
|
+
block._tag = 'address|article|aside|base|basefont|blockquote|body|caption'
|
|
1105
1089
|
+ '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption'
|
|
1106
1090
|
+ '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe'
|
|
1107
1091
|
+ '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option'
|
|
1108
1092
|
+ '|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr'
|
|
1109
1093
|
+ '|track|ul';
|
|
1110
|
-
block
|
|
1111
|
-
block
|
|
1112
|
-
.replace('comment', block
|
|
1113
|
-
.replace('tag', block
|
|
1094
|
+
block._comment = /<!--(?!-?>)[\s\S]*?(?:-->|$)/;
|
|
1095
|
+
block.html = edit(block.html, 'i')
|
|
1096
|
+
.replace('comment', block._comment)
|
|
1097
|
+
.replace('tag', block._tag)
|
|
1114
1098
|
.replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/)
|
|
1115
1099
|
.getRegex();
|
|
1116
1100
|
|
|
1117
|
-
block
|
|
1118
|
-
.replace('hr', block
|
|
1101
|
+
block.paragraph = edit(block._paragraph)
|
|
1102
|
+
.replace('hr', block.hr)
|
|
1119
1103
|
.replace('heading', ' {0,3}#{1,6} ')
|
|
1120
1104
|
.replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
|
|
1121
1105
|
.replace('blockquote', ' {0,3}>')
|
|
1122
1106
|
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
|
|
1123
1107
|
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
1124
|
-
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)')
|
|
1125
|
-
.replace('tag', block
|
|
1108
|
+
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
|
|
1109
|
+
.replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
|
|
1126
1110
|
.getRegex();
|
|
1127
1111
|
|
|
1128
|
-
block
|
|
1129
|
-
.replace('paragraph', block
|
|
1112
|
+
block.blockquote = edit(block.blockquote)
|
|
1113
|
+
.replace('paragraph', block.paragraph)
|
|
1130
1114
|
.getRegex();
|
|
1131
1115
|
|
|
1132
1116
|
/**
|
|
1133
1117
|
* Normal Block Grammar
|
|
1134
1118
|
*/
|
|
1135
1119
|
|
|
1136
|
-
block
|
|
1120
|
+
block.normal = merge({}, block);
|
|
1137
1121
|
|
|
1138
1122
|
/**
|
|
1139
1123
|
* GFM Block Grammar
|
|
1140
1124
|
*/
|
|
1141
1125
|
|
|
1142
|
-
block
|
|
1143
|
-
|
|
1144
|
-
+ ' {0,3}(
|
|
1145
|
-
+ '(?:\\n((?:(
|
|
1146
|
-
table: '^ *\\|(.+)\\n' // Header
|
|
1147
|
-
+ ' {0,3}\\|?( *[-:]+[-| :]*)' // Align
|
|
1148
|
-
+ '(?:\\n *((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)' // Cells
|
|
1126
|
+
block.gfm = merge({}, block.normal, {
|
|
1127
|
+
table: '^ *([^\\n ].*\\|.*)\\n' // Header
|
|
1128
|
+
+ ' {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?' // Align
|
|
1129
|
+
+ '(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)' // Cells
|
|
1149
1130
|
});
|
|
1150
1131
|
|
|
1151
|
-
block
|
|
1152
|
-
.replace('hr', block
|
|
1153
|
-
.replace('heading', ' {0,3}#{1,6} ')
|
|
1154
|
-
.replace('blockquote', ' {0,3}>')
|
|
1155
|
-
.replace('code', ' {4}[^\\n]')
|
|
1156
|
-
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
|
|
1157
|
-
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
1158
|
-
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)')
|
|
1159
|
-
.replace('tag', block$1._tag) // tables can be interrupted by type (6) html blocks
|
|
1160
|
-
.getRegex();
|
|
1161
|
-
|
|
1162
|
-
block$1.gfm.table = edit(block$1.gfm.table)
|
|
1163
|
-
.replace('hr', block$1.hr)
|
|
1132
|
+
block.gfm.table = edit(block.gfm.table)
|
|
1133
|
+
.replace('hr', block.hr)
|
|
1164
1134
|
.replace('heading', ' {0,3}#{1,6} ')
|
|
1165
1135
|
.replace('blockquote', ' {0,3}>')
|
|
1166
1136
|
.replace('code', ' {4}[^\\n]')
|
|
1167
1137
|
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
|
|
1168
1138
|
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
1169
|
-
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)')
|
|
1170
|
-
.replace('tag', block
|
|
1139
|
+
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
|
|
1140
|
+
.replace('tag', block._tag) // tables can be interrupted by type (6) html blocks
|
|
1171
1141
|
.getRegex();
|
|
1172
1142
|
|
|
1173
1143
|
/**
|
|
1174
1144
|
* Pedantic grammar (original John Gruber's loose markdown specification)
|
|
1175
1145
|
*/
|
|
1176
1146
|
|
|
1177
|
-
block
|
|
1147
|
+
block.pedantic = merge({}, block.normal, {
|
|
1178
1148
|
html: edit(
|
|
1179
1149
|
'^ *(?:comment *(?:\\n|\\s*$)'
|
|
1180
1150
|
+ '|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' // closed tag
|
|
1181
1151
|
+ '|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))')
|
|
1182
|
-
.replace('comment', block
|
|
1152
|
+
.replace('comment', block._comment)
|
|
1183
1153
|
.replace(/tag/g, '(?!(?:'
|
|
1184
1154
|
+ 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub'
|
|
1185
1155
|
+ '|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)'
|
|
@@ -1188,10 +1158,10 @@ block$1.pedantic = merge$1({}, block$1.normal, {
|
|
|
1188
1158
|
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
1189
1159
|
heading: /^(#{1,6})(.*)(?:\n+|$)/,
|
|
1190
1160
|
fences: noopTest, // fences not supported
|
|
1191
|
-
paragraph: edit(block
|
|
1192
|
-
.replace('hr', block
|
|
1161
|
+
paragraph: edit(block.normal._paragraph)
|
|
1162
|
+
.replace('hr', block.hr)
|
|
1193
1163
|
.replace('heading', ' *#{1,6} *[^\n]')
|
|
1194
|
-
.replace('lheading', block
|
|
1164
|
+
.replace('lheading', block.lheading)
|
|
1195
1165
|
.replace('blockquote', ' {0,3}>')
|
|
1196
1166
|
.replace('|fences', '')
|
|
1197
1167
|
.replace('|list', '')
|
|
@@ -1202,7 +1172,7 @@ block$1.pedantic = merge$1({}, block$1.normal, {
|
|
|
1202
1172
|
/**
|
|
1203
1173
|
* Inline-Level Grammar
|
|
1204
1174
|
*/
|
|
1205
|
-
const inline
|
|
1175
|
+
const inline = {
|
|
1206
1176
|
escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
|
|
1207
1177
|
autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
|
|
1208
1178
|
url: noopTest,
|
|
@@ -1219,9 +1189,9 @@ const inline$1 = {
|
|
|
1219
1189
|
emStrong: {
|
|
1220
1190
|
lDelim: /^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,
|
|
1221
1191
|
// (1) and (2) can only be a Right Delimiter. (3) and (4) can only be Left. (5) and (6) can be either Left or Right.
|
|
1222
|
-
// () Skip
|
|
1223
|
-
rDelimAst:
|
|
1224
|
-
rDelimUnd:
|
|
1192
|
+
// () Skip orphan delim inside strong (1) #*** (2) a***#, a*** (3) #***a, ***a (4) ***# (5) #***# (6) a***a
|
|
1193
|
+
rDelimAst: /^[^_*]*?\_\_[^_*]*?\*[^_*]*?(?=\_\_)|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,
|
|
1194
|
+
rDelimUnd: /^[^_*]*?\*\*[^_*]*?\_[^_*]*?(?=\*\*)|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/ // ^- Not allowed for _
|
|
1225
1195
|
},
|
|
1226
1196
|
code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
|
|
1227
1197
|
br: /^( {2,}|\\)\n(?!\s*$)/,
|
|
@@ -1232,73 +1202,73 @@ const inline$1 = {
|
|
|
1232
1202
|
|
|
1233
1203
|
// list of punctuation marks from CommonMark spec
|
|
1234
1204
|
// without * and _ to handle the different emphasis markers * and _
|
|
1235
|
-
inline
|
|
1236
|
-
inline
|
|
1205
|
+
inline._punctuation = '!"#$%&\'()+\\-.,/:;<=>?@\\[\\]`^{|}~';
|
|
1206
|
+
inline.punctuation = edit(inline.punctuation).replace(/punctuation/g, inline._punctuation).getRegex();
|
|
1237
1207
|
|
|
1238
1208
|
// sequences em should skip over [title](link), `code`, <html>
|
|
1239
|
-
inline
|
|
1240
|
-
inline
|
|
1209
|
+
inline.blockSkip = /\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g;
|
|
1210
|
+
inline.escapedEmSt = /\\\*|\\_/g;
|
|
1241
1211
|
|
|
1242
|
-
inline
|
|
1212
|
+
inline._comment = edit(block._comment).replace('(?:-->|$)', '-->').getRegex();
|
|
1243
1213
|
|
|
1244
|
-
inline
|
|
1245
|
-
.replace(/punct/g, inline
|
|
1214
|
+
inline.emStrong.lDelim = edit(inline.emStrong.lDelim)
|
|
1215
|
+
.replace(/punct/g, inline._punctuation)
|
|
1246
1216
|
.getRegex();
|
|
1247
1217
|
|
|
1248
|
-
inline
|
|
1249
|
-
.replace(/punct/g, inline
|
|
1218
|
+
inline.emStrong.rDelimAst = edit(inline.emStrong.rDelimAst, 'g')
|
|
1219
|
+
.replace(/punct/g, inline._punctuation)
|
|
1250
1220
|
.getRegex();
|
|
1251
1221
|
|
|
1252
|
-
inline
|
|
1253
|
-
.replace(/punct/g, inline
|
|
1222
|
+
inline.emStrong.rDelimUnd = edit(inline.emStrong.rDelimUnd, 'g')
|
|
1223
|
+
.replace(/punct/g, inline._punctuation)
|
|
1254
1224
|
.getRegex();
|
|
1255
1225
|
|
|
1256
|
-
inline
|
|
1226
|
+
inline._escapes = /\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;
|
|
1257
1227
|
|
|
1258
|
-
inline
|
|
1259
|
-
inline
|
|
1260
|
-
inline
|
|
1261
|
-
.replace('scheme', inline
|
|
1262
|
-
.replace('email', inline
|
|
1228
|
+
inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
|
|
1229
|
+
inline._email = /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;
|
|
1230
|
+
inline.autolink = edit(inline.autolink)
|
|
1231
|
+
.replace('scheme', inline._scheme)
|
|
1232
|
+
.replace('email', inline._email)
|
|
1263
1233
|
.getRegex();
|
|
1264
1234
|
|
|
1265
|
-
inline
|
|
1235
|
+
inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
|
|
1266
1236
|
|
|
1267
|
-
inline
|
|
1268
|
-
.replace('comment', inline
|
|
1269
|
-
.replace('attribute', inline
|
|
1237
|
+
inline.tag = edit(inline.tag)
|
|
1238
|
+
.replace('comment', inline._comment)
|
|
1239
|
+
.replace('attribute', inline._attribute)
|
|
1270
1240
|
.getRegex();
|
|
1271
1241
|
|
|
1272
|
-
inline
|
|
1273
|
-
inline
|
|
1274
|
-
inline
|
|
1242
|
+
inline._label = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
|
|
1243
|
+
inline._href = /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;
|
|
1244
|
+
inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
|
|
1275
1245
|
|
|
1276
|
-
inline
|
|
1277
|
-
.replace('label', inline
|
|
1278
|
-
.replace('href', inline
|
|
1279
|
-
.replace('title', inline
|
|
1246
|
+
inline.link = edit(inline.link)
|
|
1247
|
+
.replace('label', inline._label)
|
|
1248
|
+
.replace('href', inline._href)
|
|
1249
|
+
.replace('title', inline._title)
|
|
1280
1250
|
.getRegex();
|
|
1281
1251
|
|
|
1282
|
-
inline
|
|
1283
|
-
.replace('label', inline
|
|
1252
|
+
inline.reflink = edit(inline.reflink)
|
|
1253
|
+
.replace('label', inline._label)
|
|
1284
1254
|
.getRegex();
|
|
1285
1255
|
|
|
1286
|
-
inline
|
|
1287
|
-
.replace('reflink', inline
|
|
1288
|
-
.replace('nolink', inline
|
|
1256
|
+
inline.reflinkSearch = edit(inline.reflinkSearch, 'g')
|
|
1257
|
+
.replace('reflink', inline.reflink)
|
|
1258
|
+
.replace('nolink', inline.nolink)
|
|
1289
1259
|
.getRegex();
|
|
1290
1260
|
|
|
1291
1261
|
/**
|
|
1292
1262
|
* Normal Inline Grammar
|
|
1293
1263
|
*/
|
|
1294
1264
|
|
|
1295
|
-
inline
|
|
1265
|
+
inline.normal = merge({}, inline);
|
|
1296
1266
|
|
|
1297
1267
|
/**
|
|
1298
1268
|
* Pedantic Inline Grammar
|
|
1299
1269
|
*/
|
|
1300
1270
|
|
|
1301
|
-
inline
|
|
1271
|
+
inline.pedantic = merge({}, inline.normal, {
|
|
1302
1272
|
strong: {
|
|
1303
1273
|
start: /^__|\*\*/,
|
|
1304
1274
|
middle: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
|
|
@@ -1312,10 +1282,10 @@ inline$1.pedantic = merge$1({}, inline$1.normal, {
|
|
|
1312
1282
|
endUnd: /_(?!_)/g
|
|
1313
1283
|
},
|
|
1314
1284
|
link: edit(/^!?\[(label)\]\((.*?)\)/)
|
|
1315
|
-
.replace('label', inline
|
|
1285
|
+
.replace('label', inline._label)
|
|
1316
1286
|
.getRegex(),
|
|
1317
1287
|
reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/)
|
|
1318
|
-
.replace('label', inline
|
|
1288
|
+
.replace('label', inline._label)
|
|
1319
1289
|
.getRegex()
|
|
1320
1290
|
});
|
|
1321
1291
|
|
|
@@ -1323,39 +1293,30 @@ inline$1.pedantic = merge$1({}, inline$1.normal, {
|
|
|
1323
1293
|
* GFM Inline Grammar
|
|
1324
1294
|
*/
|
|
1325
1295
|
|
|
1326
|
-
inline
|
|
1327
|
-
escape: edit(inline
|
|
1296
|
+
inline.gfm = merge({}, inline.normal, {
|
|
1297
|
+
escape: edit(inline.escape).replace('])', '~|])').getRegex(),
|
|
1328
1298
|
_extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
|
|
1329
1299
|
url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
|
|
1330
1300
|
_backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
|
|
1331
1301
|
del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
|
|
1332
|
-
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))
|
|
1302
|
+
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
|
|
1333
1303
|
});
|
|
1334
1304
|
|
|
1335
|
-
inline
|
|
1336
|
-
.replace('email', inline
|
|
1305
|
+
inline.gfm.url = edit(inline.gfm.url, 'i')
|
|
1306
|
+
.replace('email', inline.gfm._extended_email)
|
|
1337
1307
|
.getRegex();
|
|
1338
1308
|
/**
|
|
1339
1309
|
* GFM + Line Breaks Inline Grammar
|
|
1340
1310
|
*/
|
|
1341
1311
|
|
|
1342
|
-
inline
|
|
1343
|
-
br: edit(inline
|
|
1344
|
-
text: edit(inline
|
|
1312
|
+
inline.breaks = merge({}, inline.gfm, {
|
|
1313
|
+
br: edit(inline.br).replace('{2,}', '*').getRegex(),
|
|
1314
|
+
text: edit(inline.gfm.text)
|
|
1345
1315
|
.replace('\\b_', '\\b_| {2,}\\n')
|
|
1346
1316
|
.replace(/\{2,\}/g, '*')
|
|
1347
1317
|
.getRegex()
|
|
1348
1318
|
});
|
|
1349
1319
|
|
|
1350
|
-
var rules = {
|
|
1351
|
-
block: block$1,
|
|
1352
|
-
inline: inline$1
|
|
1353
|
-
};
|
|
1354
|
-
|
|
1355
|
-
const { defaults: defaults$3 } = defaults$5;
|
|
1356
|
-
const { block, inline } = rules;
|
|
1357
|
-
const { repeatString } = helpers;
|
|
1358
|
-
|
|
1359
1320
|
/**
|
|
1360
1321
|
* smartypants text replacement
|
|
1361
1322
|
*/
|
|
@@ -1400,14 +1361,21 @@ function mangle(text) {
|
|
|
1400
1361
|
/**
|
|
1401
1362
|
* Block Lexer
|
|
1402
1363
|
*/
|
|
1403
|
-
|
|
1364
|
+
class Lexer {
|
|
1404
1365
|
constructor(options) {
|
|
1405
1366
|
this.tokens = [];
|
|
1406
1367
|
this.tokens.links = Object.create(null);
|
|
1407
|
-
this.options = options || defaults
|
|
1408
|
-
this.options.tokenizer = this.options.tokenizer || new
|
|
1368
|
+
this.options = options || defaults;
|
|
1369
|
+
this.options.tokenizer = this.options.tokenizer || new Tokenizer();
|
|
1409
1370
|
this.tokenizer = this.options.tokenizer;
|
|
1410
1371
|
this.tokenizer.options = this.options;
|
|
1372
|
+
this.tokenizer.lexer = this;
|
|
1373
|
+
this.inlineQueue = [];
|
|
1374
|
+
this.state = {
|
|
1375
|
+
inLink: false,
|
|
1376
|
+
inRawBlock: false,
|
|
1377
|
+
top: true
|
|
1378
|
+
};
|
|
1411
1379
|
|
|
1412
1380
|
const rules = {
|
|
1413
1381
|
block: block.normal,
|
|
@@ -1462,9 +1430,12 @@ var Lexer_1 = class Lexer {
|
|
|
1462
1430
|
.replace(/\r\n|\r/g, '\n')
|
|
1463
1431
|
.replace(/\t/g, ' ');
|
|
1464
1432
|
|
|
1465
|
-
this.blockTokens(src, this.tokens
|
|
1433
|
+
this.blockTokens(src, this.tokens);
|
|
1466
1434
|
|
|
1467
|
-
|
|
1435
|
+
let next;
|
|
1436
|
+
while (next = this.inlineQueue.shift()) {
|
|
1437
|
+
this.inlineTokens(next.src, next.tokens);
|
|
1438
|
+
}
|
|
1468
1439
|
|
|
1469
1440
|
return this.tokens;
|
|
1470
1441
|
}
|
|
@@ -1472,13 +1443,26 @@ var Lexer_1 = class Lexer {
|
|
|
1472
1443
|
/**
|
|
1473
1444
|
* Lexing
|
|
1474
1445
|
*/
|
|
1475
|
-
blockTokens(src, tokens = []
|
|
1446
|
+
blockTokens(src, tokens = []) {
|
|
1476
1447
|
if (this.options.pedantic) {
|
|
1477
1448
|
src = src.replace(/^ +$/gm, '');
|
|
1478
1449
|
}
|
|
1479
|
-
let token,
|
|
1450
|
+
let token, lastToken, cutSrc, lastParagraphClipped;
|
|
1480
1451
|
|
|
1481
1452
|
while (src) {
|
|
1453
|
+
if (this.options.extensions
|
|
1454
|
+
&& this.options.extensions.block
|
|
1455
|
+
&& this.options.extensions.block.some((extTokenizer) => {
|
|
1456
|
+
if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
|
|
1457
|
+
src = src.substring(token.raw.length);
|
|
1458
|
+
tokens.push(token);
|
|
1459
|
+
return true;
|
|
1460
|
+
}
|
|
1461
|
+
return false;
|
|
1462
|
+
})) {
|
|
1463
|
+
continue;
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1482
1466
|
// newline
|
|
1483
1467
|
if (token = this.tokenizer.space(src)) {
|
|
1484
1468
|
src = src.substring(token.raw.length);
|
|
@@ -1493,9 +1477,10 @@ var Lexer_1 = class Lexer {
|
|
|
1493
1477
|
src = src.substring(token.raw.length);
|
|
1494
1478
|
lastToken = tokens[tokens.length - 1];
|
|
1495
1479
|
// An indented code block cannot interrupt a paragraph.
|
|
1496
|
-
if (lastToken && lastToken.type === 'paragraph') {
|
|
1480
|
+
if (lastToken && (lastToken.type === 'paragraph' || lastToken.type === 'text')) {
|
|
1497
1481
|
lastToken.raw += '\n' + token.raw;
|
|
1498
1482
|
lastToken.text += '\n' + token.text;
|
|
1483
|
+
this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
|
|
1499
1484
|
} else {
|
|
1500
1485
|
tokens.push(token);
|
|
1501
1486
|
}
|
|
@@ -1516,13 +1501,6 @@ var Lexer_1 = class Lexer {
|
|
|
1516
1501
|
continue;
|
|
1517
1502
|
}
|
|
1518
1503
|
|
|
1519
|
-
// table no leading pipe (gfm)
|
|
1520
|
-
if (token = this.tokenizer.nptable(src)) {
|
|
1521
|
-
src = src.substring(token.raw.length);
|
|
1522
|
-
tokens.push(token);
|
|
1523
|
-
continue;
|
|
1524
|
-
}
|
|
1525
|
-
|
|
1526
1504
|
// hr
|
|
1527
1505
|
if (token = this.tokenizer.hr(src)) {
|
|
1528
1506
|
src = src.substring(token.raw.length);
|
|
@@ -1533,7 +1511,6 @@ var Lexer_1 = class Lexer {
|
|
|
1533
1511
|
// blockquote
|
|
1534
1512
|
if (token = this.tokenizer.blockquote(src)) {
|
|
1535
1513
|
src = src.substring(token.raw.length);
|
|
1536
|
-
token.tokens = this.blockTokens(token.text, [], top);
|
|
1537
1514
|
tokens.push(token);
|
|
1538
1515
|
continue;
|
|
1539
1516
|
}
|
|
@@ -1541,10 +1518,6 @@ var Lexer_1 = class Lexer {
|
|
|
1541
1518
|
// list
|
|
1542
1519
|
if (token = this.tokenizer.list(src)) {
|
|
1543
1520
|
src = src.substring(token.raw.length);
|
|
1544
|
-
l = token.items.length;
|
|
1545
|
-
for (i = 0; i < l; i++) {
|
|
1546
|
-
token.items[i].tokens = this.blockTokens(token.items[i].text, [], false);
|
|
1547
|
-
}
|
|
1548
1521
|
tokens.push(token);
|
|
1549
1522
|
continue;
|
|
1550
1523
|
}
|
|
@@ -1557,9 +1530,14 @@ var Lexer_1 = class Lexer {
|
|
|
1557
1530
|
}
|
|
1558
1531
|
|
|
1559
1532
|
// def
|
|
1560
|
-
if (
|
|
1533
|
+
if (token = this.tokenizer.def(src)) {
|
|
1561
1534
|
src = src.substring(token.raw.length);
|
|
1562
|
-
|
|
1535
|
+
lastToken = tokens[tokens.length - 1];
|
|
1536
|
+
if (lastToken && (lastToken.type === 'paragraph' || lastToken.type === 'text')) {
|
|
1537
|
+
lastToken.raw += '\n' + token.raw;
|
|
1538
|
+
lastToken.text += '\n' + token.raw;
|
|
1539
|
+
this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
|
|
1540
|
+
} else if (!this.tokens.links[token.tag]) {
|
|
1563
1541
|
this.tokens.links[token.tag] = {
|
|
1564
1542
|
href: token.href,
|
|
1565
1543
|
title: token.title
|
|
@@ -1583,9 +1561,32 @@ var Lexer_1 = class Lexer {
|
|
|
1583
1561
|
}
|
|
1584
1562
|
|
|
1585
1563
|
// top-level paragraph
|
|
1586
|
-
|
|
1564
|
+
// prevent paragraph consuming extensions by clipping 'src' to extension start
|
|
1565
|
+
cutSrc = src;
|
|
1566
|
+
if (this.options.extensions && this.options.extensions.startBlock) {
|
|
1567
|
+
let startIndex = Infinity;
|
|
1568
|
+
const tempSrc = src.slice(1);
|
|
1569
|
+
let tempStart;
|
|
1570
|
+
this.options.extensions.startBlock.forEach(function(getStartIndex) {
|
|
1571
|
+
tempStart = getStartIndex.call({ lexer: this }, tempSrc);
|
|
1572
|
+
if (typeof tempStart === 'number' && tempStart >= 0) { startIndex = Math.min(startIndex, tempStart); }
|
|
1573
|
+
});
|
|
1574
|
+
if (startIndex < Infinity && startIndex >= 0) {
|
|
1575
|
+
cutSrc = src.substring(0, startIndex + 1);
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
|
|
1579
|
+
lastToken = tokens[tokens.length - 1];
|
|
1580
|
+
if (lastParagraphClipped && lastToken.type === 'paragraph') {
|
|
1581
|
+
lastToken.raw += '\n' + token.raw;
|
|
1582
|
+
lastToken.text += '\n' + token.text;
|
|
1583
|
+
this.inlineQueue.pop();
|
|
1584
|
+
this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
|
|
1585
|
+
} else {
|
|
1586
|
+
tokens.push(token);
|
|
1587
|
+
}
|
|
1588
|
+
lastParagraphClipped = (cutSrc.length !== src.length);
|
|
1587
1589
|
src = src.substring(token.raw.length);
|
|
1588
|
-
tokens.push(token);
|
|
1589
1590
|
continue;
|
|
1590
1591
|
}
|
|
1591
1592
|
|
|
@@ -1596,6 +1597,8 @@ var Lexer_1 = class Lexer {
|
|
|
1596
1597
|
if (lastToken && lastToken.type === 'text') {
|
|
1597
1598
|
lastToken.raw += '\n' + token.raw;
|
|
1598
1599
|
lastToken.text += '\n' + token.text;
|
|
1600
|
+
this.inlineQueue.pop();
|
|
1601
|
+
this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
|
|
1599
1602
|
} else {
|
|
1600
1603
|
tokens.push(token);
|
|
1601
1604
|
}
|
|
@@ -1613,76 +1616,19 @@ var Lexer_1 = class Lexer {
|
|
|
1613
1616
|
}
|
|
1614
1617
|
}
|
|
1615
1618
|
|
|
1619
|
+
this.state.top = true;
|
|
1616
1620
|
return tokens;
|
|
1617
1621
|
}
|
|
1618
1622
|
|
|
1619
|
-
inline(tokens) {
|
|
1620
|
-
|
|
1621
|
-
j,
|
|
1622
|
-
k,
|
|
1623
|
-
l2,
|
|
1624
|
-
row,
|
|
1625
|
-
token;
|
|
1626
|
-
|
|
1627
|
-
const l = tokens.length;
|
|
1628
|
-
for (i = 0; i < l; i++) {
|
|
1629
|
-
token = tokens[i];
|
|
1630
|
-
switch (token.type) {
|
|
1631
|
-
case 'paragraph':
|
|
1632
|
-
case 'text':
|
|
1633
|
-
case 'heading': {
|
|
1634
|
-
token.tokens = [];
|
|
1635
|
-
this.inlineTokens(token.text, token.tokens);
|
|
1636
|
-
break;
|
|
1637
|
-
}
|
|
1638
|
-
case 'table': {
|
|
1639
|
-
token.tokens = {
|
|
1640
|
-
header: [],
|
|
1641
|
-
cells: []
|
|
1642
|
-
};
|
|
1643
|
-
|
|
1644
|
-
// header
|
|
1645
|
-
l2 = token.header.length;
|
|
1646
|
-
for (j = 0; j < l2; j++) {
|
|
1647
|
-
token.tokens.header[j] = [];
|
|
1648
|
-
this.inlineTokens(token.header[j], token.tokens.header[j]);
|
|
1649
|
-
}
|
|
1650
|
-
|
|
1651
|
-
// cells
|
|
1652
|
-
l2 = token.cells.length;
|
|
1653
|
-
for (j = 0; j < l2; j++) {
|
|
1654
|
-
row = token.cells[j];
|
|
1655
|
-
token.tokens.cells[j] = [];
|
|
1656
|
-
for (k = 0; k < row.length; k++) {
|
|
1657
|
-
token.tokens.cells[j][k] = [];
|
|
1658
|
-
this.inlineTokens(row[k], token.tokens.cells[j][k]);
|
|
1659
|
-
}
|
|
1660
|
-
}
|
|
1661
|
-
|
|
1662
|
-
break;
|
|
1663
|
-
}
|
|
1664
|
-
case 'blockquote': {
|
|
1665
|
-
this.inline(token.tokens);
|
|
1666
|
-
break;
|
|
1667
|
-
}
|
|
1668
|
-
case 'list': {
|
|
1669
|
-
l2 = token.items.length;
|
|
1670
|
-
for (j = 0; j < l2; j++) {
|
|
1671
|
-
this.inline(token.items[j].tokens);
|
|
1672
|
-
}
|
|
1673
|
-
break;
|
|
1674
|
-
}
|
|
1675
|
-
}
|
|
1676
|
-
}
|
|
1677
|
-
|
|
1678
|
-
return tokens;
|
|
1623
|
+
inline(src, tokens) {
|
|
1624
|
+
this.inlineQueue.push({ src, tokens });
|
|
1679
1625
|
}
|
|
1680
1626
|
|
|
1681
1627
|
/**
|
|
1682
1628
|
* Lexing/Compiling
|
|
1683
1629
|
*/
|
|
1684
|
-
inlineTokens(src, tokens = []
|
|
1685
|
-
let token, lastToken;
|
|
1630
|
+
inlineTokens(src, tokens = []) {
|
|
1631
|
+
let token, lastToken, cutSrc;
|
|
1686
1632
|
|
|
1687
1633
|
// String with links masked to avoid interference with em and strong
|
|
1688
1634
|
let maskedSrc = src;
|
|
@@ -1716,6 +1662,20 @@ var Lexer_1 = class Lexer {
|
|
|
1716
1662
|
}
|
|
1717
1663
|
keepPrevChar = false;
|
|
1718
1664
|
|
|
1665
|
+
// extensions
|
|
1666
|
+
if (this.options.extensions
|
|
1667
|
+
&& this.options.extensions.inline
|
|
1668
|
+
&& this.options.extensions.inline.some((extTokenizer) => {
|
|
1669
|
+
if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
|
|
1670
|
+
src = src.substring(token.raw.length);
|
|
1671
|
+
tokens.push(token);
|
|
1672
|
+
return true;
|
|
1673
|
+
}
|
|
1674
|
+
return false;
|
|
1675
|
+
})) {
|
|
1676
|
+
continue;
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1719
1679
|
// escape
|
|
1720
1680
|
if (token = this.tokenizer.escape(src)) {
|
|
1721
1681
|
src = src.substring(token.raw.length);
|
|
@@ -1724,11 +1684,9 @@ var Lexer_1 = class Lexer {
|
|
|
1724
1684
|
}
|
|
1725
1685
|
|
|
1726
1686
|
// tag
|
|
1727
|
-
if (token = this.tokenizer.tag(src
|
|
1687
|
+
if (token = this.tokenizer.tag(src)) {
|
|
1728
1688
|
src = src.substring(token.raw.length);
|
|
1729
|
-
|
|
1730
|
-
inRawBlock = token.inRawBlock;
|
|
1731
|
-
const lastToken = tokens[tokens.length - 1];
|
|
1689
|
+
lastToken = tokens[tokens.length - 1];
|
|
1732
1690
|
if (lastToken && token.type === 'text' && lastToken.type === 'text') {
|
|
1733
1691
|
lastToken.raw += token.raw;
|
|
1734
1692
|
lastToken.text += token.text;
|
|
@@ -1741,9 +1699,6 @@ var Lexer_1 = class Lexer {
|
|
|
1741
1699
|
// link
|
|
1742
1700
|
if (token = this.tokenizer.link(src)) {
|
|
1743
1701
|
src = src.substring(token.raw.length);
|
|
1744
|
-
if (token.type === 'link') {
|
|
1745
|
-
token.tokens = this.inlineTokens(token.text, [], true, inRawBlock);
|
|
1746
|
-
}
|
|
1747
1702
|
tokens.push(token);
|
|
1748
1703
|
continue;
|
|
1749
1704
|
}
|
|
@@ -1751,11 +1706,8 @@ var Lexer_1 = class Lexer {
|
|
|
1751
1706
|
// reflink, nolink
|
|
1752
1707
|
if (token = this.tokenizer.reflink(src, this.tokens.links)) {
|
|
1753
1708
|
src = src.substring(token.raw.length);
|
|
1754
|
-
|
|
1755
|
-
if (token.type === '
|
|
1756
|
-
token.tokens = this.inlineTokens(token.text, [], true, inRawBlock);
|
|
1757
|
-
tokens.push(token);
|
|
1758
|
-
} else if (lastToken && token.type === 'text' && lastToken.type === 'text') {
|
|
1709
|
+
lastToken = tokens[tokens.length - 1];
|
|
1710
|
+
if (lastToken && token.type === 'text' && lastToken.type === 'text') {
|
|
1759
1711
|
lastToken.raw += token.raw;
|
|
1760
1712
|
lastToken.text += token.text;
|
|
1761
1713
|
} else {
|
|
@@ -1767,7 +1719,6 @@ var Lexer_1 = class Lexer {
|
|
|
1767
1719
|
// em & strong
|
|
1768
1720
|
if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) {
|
|
1769
1721
|
src = src.substring(token.raw.length);
|
|
1770
|
-
token.tokens = this.inlineTokens(token.text, [], inLink, inRawBlock);
|
|
1771
1722
|
tokens.push(token);
|
|
1772
1723
|
continue;
|
|
1773
1724
|
}
|
|
@@ -1789,7 +1740,6 @@ var Lexer_1 = class Lexer {
|
|
|
1789
1740
|
// del (gfm)
|
|
1790
1741
|
if (token = this.tokenizer.del(src)) {
|
|
1791
1742
|
src = src.substring(token.raw.length);
|
|
1792
|
-
token.tokens = this.inlineTokens(token.text, [], inLink, inRawBlock);
|
|
1793
1743
|
tokens.push(token);
|
|
1794
1744
|
continue;
|
|
1795
1745
|
}
|
|
@@ -1802,14 +1752,28 @@ var Lexer_1 = class Lexer {
|
|
|
1802
1752
|
}
|
|
1803
1753
|
|
|
1804
1754
|
// url (gfm)
|
|
1805
|
-
if (!inLink && (token = this.tokenizer.url(src, mangle))) {
|
|
1755
|
+
if (!this.state.inLink && (token = this.tokenizer.url(src, mangle))) {
|
|
1806
1756
|
src = src.substring(token.raw.length);
|
|
1807
1757
|
tokens.push(token);
|
|
1808
1758
|
continue;
|
|
1809
1759
|
}
|
|
1810
1760
|
|
|
1811
1761
|
// text
|
|
1812
|
-
|
|
1762
|
+
// prevent inlineText consuming extensions by clipping 'src' to extension start
|
|
1763
|
+
cutSrc = src;
|
|
1764
|
+
if (this.options.extensions && this.options.extensions.startInline) {
|
|
1765
|
+
let startIndex = Infinity;
|
|
1766
|
+
const tempSrc = src.slice(1);
|
|
1767
|
+
let tempStart;
|
|
1768
|
+
this.options.extensions.startInline.forEach(function(getStartIndex) {
|
|
1769
|
+
tempStart = getStartIndex.call({ lexer: this }, tempSrc);
|
|
1770
|
+
if (typeof tempStart === 'number' && tempStart >= 0) { startIndex = Math.min(startIndex, tempStart); }
|
|
1771
|
+
});
|
|
1772
|
+
if (startIndex < Infinity && startIndex >= 0) {
|
|
1773
|
+
cutSrc = src.substring(0, startIndex + 1);
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
if (token = this.tokenizer.inlineText(cutSrc, smartypants)) {
|
|
1813
1777
|
src = src.substring(token.raw.length);
|
|
1814
1778
|
if (token.raw.slice(-1) !== '_') { // Track prevChar before string of ____ started
|
|
1815
1779
|
prevChar = token.raw.slice(-1);
|
|
@@ -1838,20 +1802,14 @@ var Lexer_1 = class Lexer {
|
|
|
1838
1802
|
|
|
1839
1803
|
return tokens;
|
|
1840
1804
|
}
|
|
1841
|
-
}
|
|
1842
|
-
|
|
1843
|
-
const { defaults: defaults$2 } = defaults$5;
|
|
1844
|
-
const {
|
|
1845
|
-
cleanUrl,
|
|
1846
|
-
escape: escape$1
|
|
1847
|
-
} = helpers;
|
|
1805
|
+
}
|
|
1848
1806
|
|
|
1849
1807
|
/**
|
|
1850
1808
|
* Renderer
|
|
1851
1809
|
*/
|
|
1852
|
-
|
|
1810
|
+
class Renderer {
|
|
1853
1811
|
constructor(options) {
|
|
1854
|
-
this.options = options || defaults
|
|
1812
|
+
this.options = options || defaults;
|
|
1855
1813
|
}
|
|
1856
1814
|
|
|
1857
1815
|
code(code, infostring, escaped) {
|
|
@@ -1868,15 +1826,15 @@ var Renderer_1 = class Renderer {
|
|
|
1868
1826
|
|
|
1869
1827
|
if (!lang) {
|
|
1870
1828
|
return '<pre><code>'
|
|
1871
|
-
+ (escaped ? code : escape
|
|
1829
|
+
+ (escaped ? code : escape(code, true))
|
|
1872
1830
|
+ '</code></pre>\n';
|
|
1873
1831
|
}
|
|
1874
1832
|
|
|
1875
1833
|
return '<pre><code class="'
|
|
1876
1834
|
+ this.options.langPrefix
|
|
1877
|
-
+ escape
|
|
1835
|
+
+ escape(lang, true)
|
|
1878
1836
|
+ '">'
|
|
1879
|
-
+ (escaped ? code : escape
|
|
1837
|
+
+ (escaped ? code : escape(code, true))
|
|
1880
1838
|
+ '</code></pre>\n';
|
|
1881
1839
|
}
|
|
1882
1840
|
|
|
@@ -1980,7 +1938,7 @@ var Renderer_1 = class Renderer {
|
|
|
1980
1938
|
if (href === null) {
|
|
1981
1939
|
return text;
|
|
1982
1940
|
}
|
|
1983
|
-
let out = '<a href="' + escape
|
|
1941
|
+
let out = '<a href="' + escape(href) + '"';
|
|
1984
1942
|
if (title) {
|
|
1985
1943
|
out += ' title="' + title + '"';
|
|
1986
1944
|
}
|
|
@@ -2005,13 +1963,13 @@ var Renderer_1 = class Renderer {
|
|
|
2005
1963
|
text(text) {
|
|
2006
1964
|
return text;
|
|
2007
1965
|
}
|
|
2008
|
-
}
|
|
1966
|
+
}
|
|
2009
1967
|
|
|
2010
1968
|
/**
|
|
2011
1969
|
* TextRenderer
|
|
2012
1970
|
* returns only the textual part of the token
|
|
2013
1971
|
*/
|
|
2014
|
-
|
|
1972
|
+
class TextRenderer {
|
|
2015
1973
|
// no need for block level renderers
|
|
2016
1974
|
strong(text) {
|
|
2017
1975
|
return text;
|
|
@@ -2048,12 +2006,12 @@ var TextRenderer_1 = class TextRenderer {
|
|
|
2048
2006
|
br() {
|
|
2049
2007
|
return '';
|
|
2050
2008
|
}
|
|
2051
|
-
}
|
|
2009
|
+
}
|
|
2052
2010
|
|
|
2053
2011
|
/**
|
|
2054
2012
|
* Slugger generates header id
|
|
2055
2013
|
*/
|
|
2056
|
-
|
|
2014
|
+
class Slugger {
|
|
2057
2015
|
constructor() {
|
|
2058
2016
|
this.seen = {};
|
|
2059
2017
|
}
|
|
@@ -2098,24 +2056,19 @@ var Slugger_1 = class Slugger {
|
|
|
2098
2056
|
const slug = this.serialize(value);
|
|
2099
2057
|
return this.getNextSafeSlug(slug, options.dryrun);
|
|
2100
2058
|
}
|
|
2101
|
-
}
|
|
2102
|
-
|
|
2103
|
-
const { defaults: defaults$1 } = defaults$5;
|
|
2104
|
-
const {
|
|
2105
|
-
unescape
|
|
2106
|
-
} = helpers;
|
|
2059
|
+
}
|
|
2107
2060
|
|
|
2108
2061
|
/**
|
|
2109
2062
|
* Parsing & Compiling
|
|
2110
2063
|
*/
|
|
2111
|
-
|
|
2064
|
+
class Parser {
|
|
2112
2065
|
constructor(options) {
|
|
2113
|
-
this.options = options || defaults
|
|
2114
|
-
this.options.renderer = this.options.renderer || new
|
|
2066
|
+
this.options = options || defaults;
|
|
2067
|
+
this.options.renderer = this.options.renderer || new Renderer();
|
|
2115
2068
|
this.renderer = this.options.renderer;
|
|
2116
2069
|
this.renderer.options = this.options;
|
|
2117
|
-
this.textRenderer = new
|
|
2118
|
-
this.slugger = new
|
|
2070
|
+
this.textRenderer = new TextRenderer();
|
|
2071
|
+
this.slugger = new Slugger();
|
|
2119
2072
|
}
|
|
2120
2073
|
|
|
2121
2074
|
/**
|
|
@@ -2156,11 +2109,22 @@ var Parser_1 = class Parser {
|
|
|
2156
2109
|
item,
|
|
2157
2110
|
checked,
|
|
2158
2111
|
task,
|
|
2159
|
-
checkbox
|
|
2112
|
+
checkbox,
|
|
2113
|
+
ret;
|
|
2160
2114
|
|
|
2161
2115
|
const l = tokens.length;
|
|
2162
2116
|
for (i = 0; i < l; i++) {
|
|
2163
2117
|
token = tokens[i];
|
|
2118
|
+
|
|
2119
|
+
// Run any renderer extensions
|
|
2120
|
+
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
|
|
2121
|
+
ret = this.options.extensions.renderers[token.type].call({ parser: this }, token);
|
|
2122
|
+
if (ret !== false || !['space', 'hr', 'heading', 'code', 'table', 'blockquote', 'list', 'html', 'paragraph', 'text'].includes(token.type)) {
|
|
2123
|
+
out += ret || '';
|
|
2124
|
+
continue;
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
|
|
2164
2128
|
switch (token.type) {
|
|
2165
2129
|
case 'space': {
|
|
2166
2130
|
continue;
|
|
@@ -2191,22 +2155,22 @@ var Parser_1 = class Parser {
|
|
|
2191
2155
|
l2 = token.header.length;
|
|
2192
2156
|
for (j = 0; j < l2; j++) {
|
|
2193
2157
|
cell += this.renderer.tablecell(
|
|
2194
|
-
this.parseInline(token.
|
|
2158
|
+
this.parseInline(token.header[j].tokens),
|
|
2195
2159
|
{ header: true, align: token.align[j] }
|
|
2196
2160
|
);
|
|
2197
2161
|
}
|
|
2198
2162
|
header += this.renderer.tablerow(cell);
|
|
2199
2163
|
|
|
2200
2164
|
body = '';
|
|
2201
|
-
l2 = token.
|
|
2165
|
+
l2 = token.rows.length;
|
|
2202
2166
|
for (j = 0; j < l2; j++) {
|
|
2203
|
-
row = token.
|
|
2167
|
+
row = token.rows[j];
|
|
2204
2168
|
|
|
2205
2169
|
cell = '';
|
|
2206
2170
|
l3 = row.length;
|
|
2207
2171
|
for (k = 0; k < l3; k++) {
|
|
2208
2172
|
cell += this.renderer.tablecell(
|
|
2209
|
-
this.parseInline(row[k]),
|
|
2173
|
+
this.parseInline(row[k].tokens),
|
|
2210
2174
|
{ header: false, align: token.align[k] }
|
|
2211
2175
|
);
|
|
2212
2176
|
}
|
|
@@ -2237,7 +2201,7 @@ var Parser_1 = class Parser {
|
|
|
2237
2201
|
if (item.task) {
|
|
2238
2202
|
checkbox = this.renderer.checkbox(checked);
|
|
2239
2203
|
if (loose) {
|
|
2240
|
-
if (item.tokens.length > 0 && item.tokens[0].type === '
|
|
2204
|
+
if (item.tokens.length > 0 && item.tokens[0].type === 'paragraph') {
|
|
2241
2205
|
item.tokens[0].text = checkbox + ' ' + item.tokens[0].text;
|
|
2242
2206
|
if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === 'text') {
|
|
2243
2207
|
item.tokens[0].tokens[0].text = checkbox + ' ' + item.tokens[0].tokens[0].text;
|
|
@@ -2278,6 +2242,7 @@ var Parser_1 = class Parser {
|
|
|
2278
2242
|
out += top ? this.renderer.paragraph(body) : body;
|
|
2279
2243
|
continue;
|
|
2280
2244
|
}
|
|
2245
|
+
|
|
2281
2246
|
default: {
|
|
2282
2247
|
const errMsg = 'Token with "' + token.type + '" type was not found.';
|
|
2283
2248
|
if (this.options.silent) {
|
|
@@ -2300,11 +2265,22 @@ var Parser_1 = class Parser {
|
|
|
2300
2265
|
renderer = renderer || this.renderer;
|
|
2301
2266
|
let out = '',
|
|
2302
2267
|
i,
|
|
2303
|
-
token
|
|
2268
|
+
token,
|
|
2269
|
+
ret;
|
|
2304
2270
|
|
|
2305
2271
|
const l = tokens.length;
|
|
2306
2272
|
for (i = 0; i < l; i++) {
|
|
2307
2273
|
token = tokens[i];
|
|
2274
|
+
|
|
2275
|
+
// Run any renderer extensions
|
|
2276
|
+
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
|
|
2277
|
+
ret = this.options.extensions.renderers[token.type].call({ parser: this }, token);
|
|
2278
|
+
if (ret !== false || !['escape', 'html', 'link', 'image', 'strong', 'em', 'codespan', 'br', 'del', 'text'].includes(token.type)) {
|
|
2279
|
+
out += ret || '';
|
|
2280
|
+
continue;
|
|
2281
|
+
}
|
|
2282
|
+
}
|
|
2283
|
+
|
|
2308
2284
|
switch (token.type) {
|
|
2309
2285
|
case 'escape': {
|
|
2310
2286
|
out += renderer.text(token.text);
|
|
@@ -2359,18 +2335,7 @@ var Parser_1 = class Parser {
|
|
|
2359
2335
|
}
|
|
2360
2336
|
return out;
|
|
2361
2337
|
}
|
|
2362
|
-
}
|
|
2363
|
-
|
|
2364
|
-
const {
|
|
2365
|
-
merge,
|
|
2366
|
-
checkSanitizeDeprecation,
|
|
2367
|
-
escape
|
|
2368
|
-
} = helpers;
|
|
2369
|
-
const {
|
|
2370
|
-
getDefaults,
|
|
2371
|
-
changeDefaults,
|
|
2372
|
-
defaults
|
|
2373
|
-
} = defaults$5;
|
|
2338
|
+
}
|
|
2374
2339
|
|
|
2375
2340
|
/**
|
|
2376
2341
|
* Marked
|
|
@@ -2398,7 +2363,7 @@ function marked(src, opt, callback) {
|
|
|
2398
2363
|
let tokens;
|
|
2399
2364
|
|
|
2400
2365
|
try {
|
|
2401
|
-
tokens =
|
|
2366
|
+
tokens = Lexer.lex(src, opt);
|
|
2402
2367
|
} catch (e) {
|
|
2403
2368
|
return callback(e);
|
|
2404
2369
|
}
|
|
@@ -2408,7 +2373,10 @@ function marked(src, opt, callback) {
|
|
|
2408
2373
|
|
|
2409
2374
|
if (!err) {
|
|
2410
2375
|
try {
|
|
2411
|
-
|
|
2376
|
+
if (opt.walkTokens) {
|
|
2377
|
+
marked.walkTokens(tokens, opt.walkTokens);
|
|
2378
|
+
}
|
|
2379
|
+
out = Parser.parse(tokens, opt);
|
|
2412
2380
|
} catch (e) {
|
|
2413
2381
|
err = e;
|
|
2414
2382
|
}
|
|
@@ -2460,11 +2428,11 @@ function marked(src, opt, callback) {
|
|
|
2460
2428
|
}
|
|
2461
2429
|
|
|
2462
2430
|
try {
|
|
2463
|
-
const tokens =
|
|
2431
|
+
const tokens = Lexer.lex(src, opt);
|
|
2464
2432
|
if (opt.walkTokens) {
|
|
2465
2433
|
marked.walkTokens(tokens, opt.walkTokens);
|
|
2466
2434
|
}
|
|
2467
|
-
return
|
|
2435
|
+
return Parser.parse(tokens, opt);
|
|
2468
2436
|
} catch (e) {
|
|
2469
2437
|
e.message += '\nPlease report this to https://github.com/markedjs/marked.';
|
|
2470
2438
|
if (opt.silent) {
|
|
@@ -2495,46 +2463,114 @@ marked.defaults = defaults;
|
|
|
2495
2463
|
* Use Extension
|
|
2496
2464
|
*/
|
|
2497
2465
|
|
|
2498
|
-
marked.use = function(
|
|
2499
|
-
const opts = merge({},
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2466
|
+
marked.use = function(...args) {
|
|
2467
|
+
const opts = merge({}, ...args);
|
|
2468
|
+
const extensions = marked.defaults.extensions || { renderers: {}, childTokens: {} };
|
|
2469
|
+
let hasExtensions;
|
|
2470
|
+
|
|
2471
|
+
args.forEach((pack) => {
|
|
2472
|
+
// ==-- Parse "addon" extensions --== //
|
|
2473
|
+
if (pack.extensions) {
|
|
2474
|
+
hasExtensions = true;
|
|
2475
|
+
pack.extensions.forEach((ext) => {
|
|
2476
|
+
if (!ext.name) {
|
|
2477
|
+
throw new Error('extension name required');
|
|
2478
|
+
}
|
|
2479
|
+
if (ext.renderer) { // Renderer extensions
|
|
2480
|
+
const prevRenderer = extensions.renderers ? extensions.renderers[ext.name] : null;
|
|
2481
|
+
if (prevRenderer) {
|
|
2482
|
+
// Replace extension with func to run new extension but fall back if false
|
|
2483
|
+
extensions.renderers[ext.name] = function(...args) {
|
|
2484
|
+
let ret = ext.renderer.apply(this, args);
|
|
2485
|
+
if (ret === false) {
|
|
2486
|
+
ret = prevRenderer.apply(this, args);
|
|
2487
|
+
}
|
|
2488
|
+
return ret;
|
|
2489
|
+
};
|
|
2490
|
+
} else {
|
|
2491
|
+
extensions.renderers[ext.name] = ext.renderer;
|
|
2492
|
+
}
|
|
2493
|
+
}
|
|
2494
|
+
if (ext.tokenizer) { // Tokenizer Extensions
|
|
2495
|
+
if (!ext.level || (ext.level !== 'block' && ext.level !== 'inline')) {
|
|
2496
|
+
throw new Error("extension level must be 'block' or 'inline'");
|
|
2497
|
+
}
|
|
2498
|
+
if (extensions[ext.level]) {
|
|
2499
|
+
extensions[ext.level].unshift(ext.tokenizer);
|
|
2500
|
+
} else {
|
|
2501
|
+
extensions[ext.level] = [ext.tokenizer];
|
|
2502
|
+
}
|
|
2503
|
+
if (ext.start) { // Function to check for start of token
|
|
2504
|
+
if (ext.level === 'block') {
|
|
2505
|
+
if (extensions.startBlock) {
|
|
2506
|
+
extensions.startBlock.push(ext.start);
|
|
2507
|
+
} else {
|
|
2508
|
+
extensions.startBlock = [ext.start];
|
|
2509
|
+
}
|
|
2510
|
+
} else if (ext.level === 'inline') {
|
|
2511
|
+
if (extensions.startInline) {
|
|
2512
|
+
extensions.startInline.push(ext.start);
|
|
2513
|
+
} else {
|
|
2514
|
+
extensions.startInline = [ext.start];
|
|
2515
|
+
}
|
|
2516
|
+
}
|
|
2517
|
+
}
|
|
2518
|
+
}
|
|
2519
|
+
if (ext.childTokens) { // Child tokens to be visited by walkTokens
|
|
2520
|
+
extensions.childTokens[ext.name] = ext.childTokens;
|
|
2521
|
+
}
|
|
2522
|
+
});
|
|
2511
2523
|
}
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
ret
|
|
2524
|
+
|
|
2525
|
+
// ==-- Parse "overwrite" extensions --== //
|
|
2526
|
+
if (pack.renderer) {
|
|
2527
|
+
const renderer = marked.defaults.renderer || new Renderer();
|
|
2528
|
+
for (const prop in pack.renderer) {
|
|
2529
|
+
const prevRenderer = renderer[prop];
|
|
2530
|
+
// Replace renderer with func to run extension, but fall back if false
|
|
2531
|
+
renderer[prop] = (...args) => {
|
|
2532
|
+
let ret = pack.renderer[prop].apply(renderer, args);
|
|
2533
|
+
if (ret === false) {
|
|
2534
|
+
ret = prevRenderer.apply(renderer, args);
|
|
2535
|
+
}
|
|
2536
|
+
return ret;
|
|
2537
|
+
};
|
|
2538
|
+
}
|
|
2539
|
+
opts.renderer = renderer;
|
|
2540
|
+
}
|
|
2541
|
+
if (pack.tokenizer) {
|
|
2542
|
+
const tokenizer = marked.defaults.tokenizer || new Tokenizer();
|
|
2543
|
+
for (const prop in pack.tokenizer) {
|
|
2544
|
+
const prevTokenizer = tokenizer[prop];
|
|
2545
|
+
// Replace tokenizer with func to run extension, but fall back if false
|
|
2546
|
+
tokenizer[prop] = (...args) => {
|
|
2547
|
+
let ret = pack.tokenizer[prop].apply(tokenizer, args);
|
|
2548
|
+
if (ret === false) {
|
|
2549
|
+
ret = prevTokenizer.apply(tokenizer, args);
|
|
2550
|
+
}
|
|
2551
|
+
return ret;
|
|
2552
|
+
};
|
|
2553
|
+
}
|
|
2554
|
+
opts.tokenizer = tokenizer;
|
|
2555
|
+
}
|
|
2556
|
+
|
|
2557
|
+
// ==-- Parse WalkTokens extensions --== //
|
|
2558
|
+
if (pack.walkTokens) {
|
|
2559
|
+
const walkTokens = marked.defaults.walkTokens;
|
|
2560
|
+
opts.walkTokens = function(token) {
|
|
2561
|
+
pack.walkTokens.call(this, token);
|
|
2562
|
+
if (walkTokens) {
|
|
2563
|
+
walkTokens.call(this, token);
|
|
2522
2564
|
}
|
|
2523
|
-
return ret;
|
|
2524
2565
|
};
|
|
2525
2566
|
}
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
walkTokens(token);
|
|
2534
|
-
}
|
|
2535
|
-
};
|
|
2536
|
-
}
|
|
2537
|
-
marked.setOptions(opts);
|
|
2567
|
+
|
|
2568
|
+
if (hasExtensions) {
|
|
2569
|
+
opts.extensions = extensions;
|
|
2570
|
+
}
|
|
2571
|
+
|
|
2572
|
+
marked.setOptions(opts);
|
|
2573
|
+
});
|
|
2538
2574
|
};
|
|
2539
2575
|
|
|
2540
2576
|
/**
|
|
@@ -2543,15 +2579,15 @@ marked.use = function(extension) {
|
|
|
2543
2579
|
|
|
2544
2580
|
marked.walkTokens = function(tokens, callback) {
|
|
2545
2581
|
for (const token of tokens) {
|
|
2546
|
-
callback(token);
|
|
2582
|
+
callback.call(marked, token);
|
|
2547
2583
|
switch (token.type) {
|
|
2548
2584
|
case 'table': {
|
|
2549
|
-
for (const cell of token.
|
|
2550
|
-
marked.walkTokens(cell, callback);
|
|
2585
|
+
for (const cell of token.header) {
|
|
2586
|
+
marked.walkTokens(cell.tokens, callback);
|
|
2551
2587
|
}
|
|
2552
|
-
for (const row of token.
|
|
2588
|
+
for (const row of token.rows) {
|
|
2553
2589
|
for (const cell of row) {
|
|
2554
|
-
marked.walkTokens(cell, callback);
|
|
2590
|
+
marked.walkTokens(cell.tokens, callback);
|
|
2555
2591
|
}
|
|
2556
2592
|
}
|
|
2557
2593
|
break;
|
|
@@ -2561,7 +2597,11 @@ marked.walkTokens = function(tokens, callback) {
|
|
|
2561
2597
|
break;
|
|
2562
2598
|
}
|
|
2563
2599
|
default: {
|
|
2564
|
-
if (token.
|
|
2600
|
+
if (marked.defaults.extensions && marked.defaults.extensions.childTokens && marked.defaults.extensions.childTokens[token.type]) { // Walk any extensions
|
|
2601
|
+
marked.defaults.extensions.childTokens[token.type].forEach(function(childTokens) {
|
|
2602
|
+
marked.walkTokens(token[childTokens], callback);
|
|
2603
|
+
});
|
|
2604
|
+
} else if (token.tokens) {
|
|
2565
2605
|
marked.walkTokens(token.tokens, callback);
|
|
2566
2606
|
}
|
|
2567
2607
|
}
|
|
@@ -2586,11 +2626,11 @@ marked.parseInline = function(src, opt) {
|
|
|
2586
2626
|
checkSanitizeDeprecation(opt);
|
|
2587
2627
|
|
|
2588
2628
|
try {
|
|
2589
|
-
const tokens =
|
|
2629
|
+
const tokens = Lexer.lexInline(src, opt);
|
|
2590
2630
|
if (opt.walkTokens) {
|
|
2591
2631
|
marked.walkTokens(tokens, opt.walkTokens);
|
|
2592
2632
|
}
|
|
2593
|
-
return
|
|
2633
|
+
return Parser.parseInline(tokens, opt);
|
|
2594
2634
|
} catch (e) {
|
|
2595
2635
|
e.message += '\nPlease report this to https://github.com/markedjs/marked.';
|
|
2596
2636
|
if (opt.silent) {
|
|
@@ -2605,22 +2645,23 @@ marked.parseInline = function(src, opt) {
|
|
|
2605
2645
|
/**
|
|
2606
2646
|
* Expose
|
|
2607
2647
|
*/
|
|
2608
|
-
|
|
2609
|
-
marked.
|
|
2610
|
-
marked.
|
|
2611
|
-
|
|
2612
|
-
marked.
|
|
2613
|
-
marked.
|
|
2614
|
-
|
|
2615
|
-
marked.
|
|
2616
|
-
marked.lexer = Lexer_1.lex;
|
|
2617
|
-
|
|
2618
|
-
marked.Tokenizer = Tokenizer_1;
|
|
2619
|
-
|
|
2620
|
-
marked.Slugger = Slugger_1;
|
|
2621
|
-
|
|
2648
|
+
marked.Parser = Parser;
|
|
2649
|
+
marked.parser = Parser.parse;
|
|
2650
|
+
marked.Renderer = Renderer;
|
|
2651
|
+
marked.TextRenderer = TextRenderer;
|
|
2652
|
+
marked.Lexer = Lexer;
|
|
2653
|
+
marked.lexer = Lexer.lex;
|
|
2654
|
+
marked.Tokenizer = Tokenizer;
|
|
2655
|
+
marked.Slugger = Slugger;
|
|
2622
2656
|
marked.parse = marked;
|
|
2623
2657
|
|
|
2624
|
-
|
|
2658
|
+
const options = marked.options;
|
|
2659
|
+
const setOptions = marked.setOptions;
|
|
2660
|
+
const use = marked.use;
|
|
2661
|
+
const walkTokens = marked.walkTokens;
|
|
2662
|
+
const parseInline = marked.parseInline;
|
|
2663
|
+
const parse = marked;
|
|
2664
|
+
const parser = Parser.parse;
|
|
2665
|
+
const lexer = Lexer.lex;
|
|
2625
2666
|
|
|
2626
|
-
export
|
|
2667
|
+
export { Lexer, Parser, Renderer, Slugger, TextRenderer, Tokenizer, defaults, getDefaults, lexer, marked, options, parse, parseInline, parser, setOptions, use, walkTokens };
|