chrome-devtools-frontend 1.0.944427 → 1.0.944903
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 +3 -0
- package/front_end/core/common/ParsedURL.ts +1 -1
- package/front_end/core/host/InspectorFrontendHostAPI.ts +5 -5
- package/front_end/core/i18n/locales/en-US.json +3 -15
- package/front_end/core/i18n/locales/en-XL.json +15 -27
- package/front_end/core/protocol_client/NodeURL.ts +1 -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/Resource.ts +2 -2
- package/front_end/core/sdk/Script.ts +2 -3
- 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/persistence/IsolatedFileSystem.ts +7 -6
- package/front_end/models/persistence/IsolatedFileSystemManager.ts +10 -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/panels/animation/animationTimeline.css +2 -0
- 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/snippets/ScriptSnippetFileSystem.ts +1 -1
- 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/codemirror.next/bundle.ts +1 -1
- package/front_end/third_party/codemirror.next/chunk/codemirror.js +1 -1
- package/front_end/third_party/codemirror.next/codemirror.next.d.ts +8 -1
- package/front_end/third_party/codemirror.next/codemirror.next.js +1 -1
- package/front_end/third_party/codemirror.next/package.json +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/text_editor/TextEditor.ts +29 -0
- package/front_end/ui/components/text_editor/config.ts +4 -2
- package/front_end/ui/legacy/ViewManager.ts +6 -0
- package/front_end/ui/legacy/components/cookie_table/CookiesTable.ts +20 -0
- package/package.json +1 -1
|
@@ -0,0 +1,2913 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* marked - a markdown parser
|
|
3
|
+
* Copyright (c) 2011-2021, Christopher Jeffrey. (MIT Licensed)
|
|
4
|
+
* https://github.com/markedjs/marked
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* DO NOT EDIT THIS FILE
|
|
9
|
+
* The code in this file is generated from files in ./src/
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
(function (global, factory) {
|
|
13
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
14
|
+
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
15
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.marked = {}));
|
|
16
|
+
})(this, (function (exports) { 'use strict';
|
|
17
|
+
|
|
18
|
+
function _defineProperties(target, props) {
|
|
19
|
+
for (var i = 0; i < props.length; i++) {
|
|
20
|
+
var descriptor = props[i];
|
|
21
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
22
|
+
descriptor.configurable = true;
|
|
23
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
24
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
29
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
30
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
31
|
+
return Constructor;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
35
|
+
if (!o) return;
|
|
36
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
37
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
38
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
39
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
40
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function _arrayLikeToArray(arr, len) {
|
|
44
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
45
|
+
|
|
46
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
47
|
+
|
|
48
|
+
return arr2;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
52
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
53
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
54
|
+
|
|
55
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
56
|
+
if (it) o = it;
|
|
57
|
+
var i = 0;
|
|
58
|
+
return function () {
|
|
59
|
+
if (i >= o.length) return {
|
|
60
|
+
done: true
|
|
61
|
+
};
|
|
62
|
+
return {
|
|
63
|
+
done: false,
|
|
64
|
+
value: o[i++]
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function getDefaults() {
|
|
73
|
+
return {
|
|
74
|
+
baseUrl: null,
|
|
75
|
+
breaks: false,
|
|
76
|
+
extensions: null,
|
|
77
|
+
gfm: true,
|
|
78
|
+
headerIds: true,
|
|
79
|
+
headerPrefix: '',
|
|
80
|
+
highlight: null,
|
|
81
|
+
langPrefix: 'language-',
|
|
82
|
+
mangle: true,
|
|
83
|
+
pedantic: false,
|
|
84
|
+
renderer: null,
|
|
85
|
+
sanitize: false,
|
|
86
|
+
sanitizer: null,
|
|
87
|
+
silent: false,
|
|
88
|
+
smartLists: false,
|
|
89
|
+
smartypants: false,
|
|
90
|
+
tokenizer: null,
|
|
91
|
+
walkTokens: null,
|
|
92
|
+
xhtml: false
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
exports.defaults = getDefaults();
|
|
96
|
+
function changeDefaults(newDefaults) {
|
|
97
|
+
exports.defaults = newDefaults;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Helpers
|
|
102
|
+
*/
|
|
103
|
+
var escapeTest = /[&<>"']/;
|
|
104
|
+
var escapeReplace = /[&<>"']/g;
|
|
105
|
+
var escapeTestNoEncode = /[<>"']|&(?!#?\w+;)/;
|
|
106
|
+
var escapeReplaceNoEncode = /[<>"']|&(?!#?\w+;)/g;
|
|
107
|
+
var escapeReplacements = {
|
|
108
|
+
'&': '&',
|
|
109
|
+
'<': '<',
|
|
110
|
+
'>': '>',
|
|
111
|
+
'"': '"',
|
|
112
|
+
"'": '''
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
var getEscapeReplacement = function getEscapeReplacement(ch) {
|
|
116
|
+
return escapeReplacements[ch];
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
function escape(html, encode) {
|
|
120
|
+
if (encode) {
|
|
121
|
+
if (escapeTest.test(html)) {
|
|
122
|
+
return html.replace(escapeReplace, getEscapeReplacement);
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
if (escapeTestNoEncode.test(html)) {
|
|
126
|
+
return html.replace(escapeReplaceNoEncode, getEscapeReplacement);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return html;
|
|
131
|
+
}
|
|
132
|
+
var unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
|
|
133
|
+
function unescape(html) {
|
|
134
|
+
// explicitly match decimal, hex, and named HTML entities
|
|
135
|
+
return html.replace(unescapeTest, function (_, n) {
|
|
136
|
+
n = n.toLowerCase();
|
|
137
|
+
if (n === 'colon') return ':';
|
|
138
|
+
|
|
139
|
+
if (n.charAt(0) === '#') {
|
|
140
|
+
return n.charAt(1) === 'x' ? String.fromCharCode(parseInt(n.substring(2), 16)) : String.fromCharCode(+n.substring(1));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return '';
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
var caret = /(^|[^\[])\^/g;
|
|
147
|
+
function edit(regex, opt) {
|
|
148
|
+
regex = regex.source || regex;
|
|
149
|
+
opt = opt || '';
|
|
150
|
+
var obj = {
|
|
151
|
+
replace: function replace(name, val) {
|
|
152
|
+
val = val.source || val;
|
|
153
|
+
val = val.replace(caret, '$1');
|
|
154
|
+
regex = regex.replace(name, val);
|
|
155
|
+
return obj;
|
|
156
|
+
},
|
|
157
|
+
getRegex: function getRegex() {
|
|
158
|
+
return new RegExp(regex, opt);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
return obj;
|
|
162
|
+
}
|
|
163
|
+
var nonWordAndColonTest = /[^\w:]/g;
|
|
164
|
+
var originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
|
|
165
|
+
function cleanUrl(sanitize, base, href) {
|
|
166
|
+
if (sanitize) {
|
|
167
|
+
var prot;
|
|
168
|
+
|
|
169
|
+
try {
|
|
170
|
+
prot = decodeURIComponent(unescape(href)).replace(nonWordAndColonTest, '').toLowerCase();
|
|
171
|
+
} catch (e) {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (base && !originIndependentUrl.test(href)) {
|
|
181
|
+
href = resolveUrl(base, href);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
try {
|
|
185
|
+
href = encodeURI(href).replace(/%25/g, '%');
|
|
186
|
+
} catch (e) {
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return href;
|
|
191
|
+
}
|
|
192
|
+
var baseUrls = {};
|
|
193
|
+
var justDomain = /^[^:]+:\/*[^/]*$/;
|
|
194
|
+
var protocol = /^([^:]+:)[\s\S]*$/;
|
|
195
|
+
var domain = /^([^:]+:\/*[^/]*)[\s\S]*$/;
|
|
196
|
+
function resolveUrl(base, href) {
|
|
197
|
+
if (!baseUrls[' ' + base]) {
|
|
198
|
+
// we can ignore everything in base after the last slash of its path component,
|
|
199
|
+
// but we might need to add _that_
|
|
200
|
+
// https://tools.ietf.org/html/rfc3986#section-3
|
|
201
|
+
if (justDomain.test(base)) {
|
|
202
|
+
baseUrls[' ' + base] = base + '/';
|
|
203
|
+
} else {
|
|
204
|
+
baseUrls[' ' + base] = rtrim(base, '/', true);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
base = baseUrls[' ' + base];
|
|
209
|
+
var relativeBase = base.indexOf(':') === -1;
|
|
210
|
+
|
|
211
|
+
if (href.substring(0, 2) === '//') {
|
|
212
|
+
if (relativeBase) {
|
|
213
|
+
return href;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return base.replace(protocol, '$1') + href;
|
|
217
|
+
} else if (href.charAt(0) === '/') {
|
|
218
|
+
if (relativeBase) {
|
|
219
|
+
return href;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return base.replace(domain, '$1') + href;
|
|
223
|
+
} else {
|
|
224
|
+
return base + href;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
var noopTest = {
|
|
228
|
+
exec: function noopTest() {}
|
|
229
|
+
};
|
|
230
|
+
function merge(obj) {
|
|
231
|
+
var i = 1,
|
|
232
|
+
target,
|
|
233
|
+
key;
|
|
234
|
+
|
|
235
|
+
for (; i < arguments.length; i++) {
|
|
236
|
+
target = arguments[i];
|
|
237
|
+
|
|
238
|
+
for (key in target) {
|
|
239
|
+
if (Object.prototype.hasOwnProperty.call(target, key)) {
|
|
240
|
+
obj[key] = target[key];
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return obj;
|
|
246
|
+
}
|
|
247
|
+
function splitCells(tableRow, count) {
|
|
248
|
+
// ensure that every cell-delimiting pipe has a space
|
|
249
|
+
// before it to distinguish it from an escaped pipe
|
|
250
|
+
var row = tableRow.replace(/\|/g, function (match, offset, str) {
|
|
251
|
+
var escaped = false,
|
|
252
|
+
curr = offset;
|
|
253
|
+
|
|
254
|
+
while (--curr >= 0 && str[curr] === '\\') {
|
|
255
|
+
escaped = !escaped;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (escaped) {
|
|
259
|
+
// odd number of slashes means | is escaped
|
|
260
|
+
// so we leave it alone
|
|
261
|
+
return '|';
|
|
262
|
+
} else {
|
|
263
|
+
// add space before unescaped |
|
|
264
|
+
return ' |';
|
|
265
|
+
}
|
|
266
|
+
}),
|
|
267
|
+
cells = row.split(/ \|/);
|
|
268
|
+
var i = 0; // First/last cell in a row cannot be empty if it has no leading/trailing pipe
|
|
269
|
+
|
|
270
|
+
if (!cells[0].trim()) {
|
|
271
|
+
cells.shift();
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
if (!cells[cells.length - 1].trim()) {
|
|
275
|
+
cells.pop();
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if (cells.length > count) {
|
|
279
|
+
cells.splice(count);
|
|
280
|
+
} else {
|
|
281
|
+
while (cells.length < count) {
|
|
282
|
+
cells.push('');
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
for (; i < cells.length; i++) {
|
|
287
|
+
// leading or trailing whitespace is ignored per the gfm spec
|
|
288
|
+
cells[i] = cells[i].trim().replace(/\\\|/g, '|');
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
return cells;
|
|
292
|
+
} // Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
|
|
293
|
+
// /c*$/ is vulnerable to REDOS.
|
|
294
|
+
// invert: Remove suffix of non-c chars instead. Default falsey.
|
|
295
|
+
|
|
296
|
+
function rtrim(str, c, invert) {
|
|
297
|
+
var l = str.length;
|
|
298
|
+
|
|
299
|
+
if (l === 0) {
|
|
300
|
+
return '';
|
|
301
|
+
} // Length of suffix matching the invert condition.
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
var suffLen = 0; // Step left until we fail to match the invert condition.
|
|
305
|
+
|
|
306
|
+
while (suffLen < l) {
|
|
307
|
+
var currChar = str.charAt(l - suffLen - 1);
|
|
308
|
+
|
|
309
|
+
if (currChar === c && !invert) {
|
|
310
|
+
suffLen++;
|
|
311
|
+
} else if (currChar !== c && invert) {
|
|
312
|
+
suffLen++;
|
|
313
|
+
} else {
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
return str.substr(0, l - suffLen);
|
|
319
|
+
}
|
|
320
|
+
function findClosingBracket(str, b) {
|
|
321
|
+
if (str.indexOf(b[1]) === -1) {
|
|
322
|
+
return -1;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
var l = str.length;
|
|
326
|
+
var level = 0,
|
|
327
|
+
i = 0;
|
|
328
|
+
|
|
329
|
+
for (; i < l; i++) {
|
|
330
|
+
if (str[i] === '\\') {
|
|
331
|
+
i++;
|
|
332
|
+
} else if (str[i] === b[0]) {
|
|
333
|
+
level++;
|
|
334
|
+
} else if (str[i] === b[1]) {
|
|
335
|
+
level--;
|
|
336
|
+
|
|
337
|
+
if (level < 0) {
|
|
338
|
+
return i;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
return -1;
|
|
344
|
+
}
|
|
345
|
+
function checkSanitizeDeprecation(opt) {
|
|
346
|
+
if (opt && opt.sanitize && !opt.silent) {
|
|
347
|
+
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');
|
|
348
|
+
}
|
|
349
|
+
} // copied from https://stackoverflow.com/a/5450113/806777
|
|
350
|
+
|
|
351
|
+
function repeatString(pattern, count) {
|
|
352
|
+
if (count < 1) {
|
|
353
|
+
return '';
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
var result = '';
|
|
357
|
+
|
|
358
|
+
while (count > 1) {
|
|
359
|
+
if (count & 1) {
|
|
360
|
+
result += pattern;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
count >>= 1;
|
|
364
|
+
pattern += pattern;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
return result + pattern;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function outputLink(cap, link, raw, lexer) {
|
|
371
|
+
var href = link.href;
|
|
372
|
+
var title = link.title ? escape(link.title) : null;
|
|
373
|
+
var text = cap[1].replace(/\\([\[\]])/g, '$1');
|
|
374
|
+
|
|
375
|
+
if (cap[0].charAt(0) !== '!') {
|
|
376
|
+
lexer.state.inLink = true;
|
|
377
|
+
var token = {
|
|
378
|
+
type: 'link',
|
|
379
|
+
raw: raw,
|
|
380
|
+
href: href,
|
|
381
|
+
title: title,
|
|
382
|
+
text: text,
|
|
383
|
+
tokens: lexer.inlineTokens(text, [])
|
|
384
|
+
};
|
|
385
|
+
lexer.state.inLink = false;
|
|
386
|
+
return token;
|
|
387
|
+
} else {
|
|
388
|
+
return {
|
|
389
|
+
type: 'image',
|
|
390
|
+
raw: raw,
|
|
391
|
+
href: href,
|
|
392
|
+
title: title,
|
|
393
|
+
text: escape(text)
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
function indentCodeCompensation(raw, text) {
|
|
399
|
+
var matchIndentToCode = raw.match(/^(\s+)(?:```)/);
|
|
400
|
+
|
|
401
|
+
if (matchIndentToCode === null) {
|
|
402
|
+
return text;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
var indentToCode = matchIndentToCode[1];
|
|
406
|
+
return text.split('\n').map(function (node) {
|
|
407
|
+
var matchIndentInNode = node.match(/^\s+/);
|
|
408
|
+
|
|
409
|
+
if (matchIndentInNode === null) {
|
|
410
|
+
return node;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
var indentInNode = matchIndentInNode[0];
|
|
414
|
+
|
|
415
|
+
if (indentInNode.length >= indentToCode.length) {
|
|
416
|
+
return node.slice(indentToCode.length);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
return node;
|
|
420
|
+
}).join('\n');
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Tokenizer
|
|
424
|
+
*/
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
var Tokenizer = /*#__PURE__*/function () {
|
|
428
|
+
function Tokenizer(options) {
|
|
429
|
+
this.options = options || exports.defaults;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
var _proto = Tokenizer.prototype;
|
|
433
|
+
|
|
434
|
+
_proto.space = function space(src) {
|
|
435
|
+
var cap = this.rules.block.newline.exec(src);
|
|
436
|
+
|
|
437
|
+
if (cap) {
|
|
438
|
+
if (cap[0].length > 1) {
|
|
439
|
+
return {
|
|
440
|
+
type: 'space',
|
|
441
|
+
raw: cap[0]
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
return {
|
|
446
|
+
raw: '\n'
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
_proto.code = function code(src) {
|
|
452
|
+
var cap = this.rules.block.code.exec(src);
|
|
453
|
+
|
|
454
|
+
if (cap) {
|
|
455
|
+
var text = cap[0].replace(/^ {1,4}/gm, '');
|
|
456
|
+
return {
|
|
457
|
+
type: 'code',
|
|
458
|
+
raw: cap[0],
|
|
459
|
+
codeBlockStyle: 'indented',
|
|
460
|
+
text: !this.options.pedantic ? rtrim(text, '\n') : text
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
_proto.fences = function fences(src) {
|
|
466
|
+
var cap = this.rules.block.fences.exec(src);
|
|
467
|
+
|
|
468
|
+
if (cap) {
|
|
469
|
+
var raw = cap[0];
|
|
470
|
+
var text = indentCodeCompensation(raw, cap[3] || '');
|
|
471
|
+
return {
|
|
472
|
+
type: 'code',
|
|
473
|
+
raw: raw,
|
|
474
|
+
lang: cap[2] ? cap[2].trim() : cap[2],
|
|
475
|
+
text: text
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
|
|
480
|
+
_proto.heading = function heading(src) {
|
|
481
|
+
var cap = this.rules.block.heading.exec(src);
|
|
482
|
+
|
|
483
|
+
if (cap) {
|
|
484
|
+
var text = cap[2].trim(); // remove trailing #s
|
|
485
|
+
|
|
486
|
+
if (/#$/.test(text)) {
|
|
487
|
+
var trimmed = rtrim(text, '#');
|
|
488
|
+
|
|
489
|
+
if (this.options.pedantic) {
|
|
490
|
+
text = trimmed.trim();
|
|
491
|
+
} else if (!trimmed || / $/.test(trimmed)) {
|
|
492
|
+
// CommonMark requires space before trailing #s
|
|
493
|
+
text = trimmed.trim();
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
var token = {
|
|
498
|
+
type: 'heading',
|
|
499
|
+
raw: cap[0],
|
|
500
|
+
depth: cap[1].length,
|
|
501
|
+
text: text,
|
|
502
|
+
tokens: []
|
|
503
|
+
};
|
|
504
|
+
this.lexer.inline(token.text, token.tokens);
|
|
505
|
+
return token;
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
|
|
509
|
+
_proto.hr = function hr(src) {
|
|
510
|
+
var cap = this.rules.block.hr.exec(src);
|
|
511
|
+
|
|
512
|
+
if (cap) {
|
|
513
|
+
return {
|
|
514
|
+
type: 'hr',
|
|
515
|
+
raw: cap[0]
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
|
|
520
|
+
_proto.blockquote = function blockquote(src) {
|
|
521
|
+
var cap = this.rules.block.blockquote.exec(src);
|
|
522
|
+
|
|
523
|
+
if (cap) {
|
|
524
|
+
var text = cap[0].replace(/^ *> ?/gm, '');
|
|
525
|
+
return {
|
|
526
|
+
type: 'blockquote',
|
|
527
|
+
raw: cap[0],
|
|
528
|
+
tokens: this.lexer.blockTokens(text, []),
|
|
529
|
+
text: text
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
};
|
|
533
|
+
|
|
534
|
+
_proto.list = function list(src) {
|
|
535
|
+
var cap = this.rules.block.list.exec(src);
|
|
536
|
+
|
|
537
|
+
if (cap) {
|
|
538
|
+
var raw, istask, ischecked, indent, i, blankLine, endsWithBlankLine, line, lines, itemContents;
|
|
539
|
+
var bull = cap[1].trim();
|
|
540
|
+
var isordered = bull.length > 1;
|
|
541
|
+
var list = {
|
|
542
|
+
type: 'list',
|
|
543
|
+
raw: '',
|
|
544
|
+
ordered: isordered,
|
|
545
|
+
start: isordered ? +bull.slice(0, -1) : '',
|
|
546
|
+
loose: false,
|
|
547
|
+
items: []
|
|
548
|
+
};
|
|
549
|
+
bull = isordered ? "\\d{1,9}\\" + bull.slice(-1) : "\\" + bull;
|
|
550
|
+
|
|
551
|
+
if (this.options.pedantic) {
|
|
552
|
+
bull = isordered ? bull : '[*+-]';
|
|
553
|
+
} // Get next list item
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
var itemRegex = new RegExp("^( {0,3}" + bull + ")((?: [^\\n]*| *)(?:\\n[^\\n]*)*(?:\\n|$))"); // Get each top-level item
|
|
557
|
+
|
|
558
|
+
while (src) {
|
|
559
|
+
if (this.rules.block.hr.test(src)) {
|
|
560
|
+
// End list if we encounter an HR (possibly move into itemRegex?)
|
|
561
|
+
break;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
if (!(cap = itemRegex.exec(src))) {
|
|
565
|
+
break;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
lines = cap[2].split('\n');
|
|
569
|
+
|
|
570
|
+
if (this.options.pedantic) {
|
|
571
|
+
indent = 2;
|
|
572
|
+
itemContents = lines[0].trimLeft();
|
|
573
|
+
} else {
|
|
574
|
+
indent = cap[2].search(/[^ ]/); // Find first non-space char
|
|
575
|
+
|
|
576
|
+
indent = cap[1].length + (indent > 4 ? 1 : indent); // intented code blocks after 4 spaces; indent is always 1
|
|
577
|
+
|
|
578
|
+
itemContents = lines[0].slice(indent - cap[1].length);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
blankLine = false;
|
|
582
|
+
raw = cap[0];
|
|
583
|
+
|
|
584
|
+
if (!lines[0] && /^ *$/.test(lines[1])) {
|
|
585
|
+
// items begin with at most one blank line
|
|
586
|
+
raw = cap[1] + lines.slice(0, 2).join('\n') + '\n';
|
|
587
|
+
list.loose = true;
|
|
588
|
+
lines = [];
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
var nextBulletRegex = new RegExp("^ {0," + Math.min(3, indent - 1) + "}(?:[*+-]|\\d{1,9}[.)])");
|
|
592
|
+
|
|
593
|
+
for (i = 1; i < lines.length; i++) {
|
|
594
|
+
line = lines[i];
|
|
595
|
+
|
|
596
|
+
if (this.options.pedantic) {
|
|
597
|
+
// Re-align to follow commonmark nesting rules
|
|
598
|
+
line = line.replace(/^ {1,4}(?=( {4})*[^ ])/g, ' ');
|
|
599
|
+
} // End list item if found start of new bullet
|
|
600
|
+
|
|
601
|
+
|
|
602
|
+
if (nextBulletRegex.test(line)) {
|
|
603
|
+
raw = cap[1] + lines.slice(0, i).join('\n') + '\n';
|
|
604
|
+
break;
|
|
605
|
+
} // Until we encounter a blank line, item contents do not need indentation
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
if (!blankLine) {
|
|
609
|
+
if (!line.trim()) {
|
|
610
|
+
// Check if current line is empty
|
|
611
|
+
blankLine = true;
|
|
612
|
+
} // Dedent if possible
|
|
613
|
+
|
|
614
|
+
|
|
615
|
+
if (line.search(/[^ ]/) >= indent) {
|
|
616
|
+
itemContents += '\n' + line.slice(indent);
|
|
617
|
+
} else {
|
|
618
|
+
itemContents += '\n' + line;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
continue;
|
|
622
|
+
} // Dedent this line
|
|
623
|
+
|
|
624
|
+
|
|
625
|
+
if (line.search(/[^ ]/) >= indent || !line.trim()) {
|
|
626
|
+
itemContents += '\n' + line.slice(indent);
|
|
627
|
+
continue;
|
|
628
|
+
} else {
|
|
629
|
+
// Line was not properly indented; end of this item
|
|
630
|
+
raw = cap[1] + lines.slice(0, i).join('\n') + '\n';
|
|
631
|
+
break;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
if (!list.loose) {
|
|
636
|
+
// If the previous item ended with a blank line, the list is loose
|
|
637
|
+
if (endsWithBlankLine) {
|
|
638
|
+
list.loose = true;
|
|
639
|
+
} else if (/\n *\n *$/.test(raw)) {
|
|
640
|
+
endsWithBlankLine = true;
|
|
641
|
+
}
|
|
642
|
+
} // Check for task list items
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
if (this.options.gfm) {
|
|
646
|
+
istask = /^\[[ xX]\] /.exec(itemContents);
|
|
647
|
+
|
|
648
|
+
if (istask) {
|
|
649
|
+
ischecked = istask[0] !== '[ ] ';
|
|
650
|
+
itemContents = itemContents.replace(/^\[[ xX]\] +/, '');
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
list.items.push({
|
|
655
|
+
type: 'list_item',
|
|
656
|
+
raw: raw,
|
|
657
|
+
task: !!istask,
|
|
658
|
+
checked: ischecked,
|
|
659
|
+
loose: false,
|
|
660
|
+
text: itemContents
|
|
661
|
+
});
|
|
662
|
+
list.raw += raw;
|
|
663
|
+
src = src.slice(raw.length);
|
|
664
|
+
} // Do not consume newlines at end of final item. Alternatively, make itemRegex *start* with any newlines to simplify/speed up endsWithBlankLine logic
|
|
665
|
+
|
|
666
|
+
|
|
667
|
+
list.items[list.items.length - 1].raw = raw.trimRight();
|
|
668
|
+
list.items[list.items.length - 1].text = itemContents.trimRight();
|
|
669
|
+
list.raw = list.raw.trimRight();
|
|
670
|
+
var l = list.items.length; // Item child tokens handled here at end because we needed to have the final item to trim it first
|
|
671
|
+
|
|
672
|
+
for (i = 0; i < l; i++) {
|
|
673
|
+
this.lexer.state.top = false;
|
|
674
|
+
list.items[i].tokens = this.lexer.blockTokens(list.items[i].text, []);
|
|
675
|
+
|
|
676
|
+
if (list.items[i].tokens.some(function (t) {
|
|
677
|
+
return t.type === 'space';
|
|
678
|
+
})) {
|
|
679
|
+
list.loose = true;
|
|
680
|
+
list.items[i].loose = true;
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
return list;
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
|
|
688
|
+
_proto.html = function html(src) {
|
|
689
|
+
var cap = this.rules.block.html.exec(src);
|
|
690
|
+
|
|
691
|
+
if (cap) {
|
|
692
|
+
var token = {
|
|
693
|
+
type: 'html',
|
|
694
|
+
raw: cap[0],
|
|
695
|
+
pre: !this.options.sanitizer && (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
|
|
696
|
+
text: cap[0]
|
|
697
|
+
};
|
|
698
|
+
|
|
699
|
+
if (this.options.sanitize) {
|
|
700
|
+
token.type = 'paragraph';
|
|
701
|
+
token.text = this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]);
|
|
702
|
+
token.tokens = [];
|
|
703
|
+
this.lexer.inline(token.text, token.tokens);
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
return token;
|
|
707
|
+
}
|
|
708
|
+
};
|
|
709
|
+
|
|
710
|
+
_proto.def = function def(src) {
|
|
711
|
+
var cap = this.rules.block.def.exec(src);
|
|
712
|
+
|
|
713
|
+
if (cap) {
|
|
714
|
+
if (cap[3]) cap[3] = cap[3].substring(1, cap[3].length - 1);
|
|
715
|
+
var tag = cap[1].toLowerCase().replace(/\s+/g, ' ');
|
|
716
|
+
return {
|
|
717
|
+
type: 'def',
|
|
718
|
+
tag: tag,
|
|
719
|
+
raw: cap[0],
|
|
720
|
+
href: cap[2],
|
|
721
|
+
title: cap[3]
|
|
722
|
+
};
|
|
723
|
+
}
|
|
724
|
+
};
|
|
725
|
+
|
|
726
|
+
_proto.table = function table(src) {
|
|
727
|
+
var cap = this.rules.block.table.exec(src);
|
|
728
|
+
|
|
729
|
+
if (cap) {
|
|
730
|
+
var item = {
|
|
731
|
+
type: 'table',
|
|
732
|
+
header: splitCells(cap[1]).map(function (c) {
|
|
733
|
+
return {
|
|
734
|
+
text: c
|
|
735
|
+
};
|
|
736
|
+
}),
|
|
737
|
+
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
|
|
738
|
+
rows: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : []
|
|
739
|
+
};
|
|
740
|
+
|
|
741
|
+
if (item.header.length === item.align.length) {
|
|
742
|
+
item.raw = cap[0];
|
|
743
|
+
var l = item.align.length;
|
|
744
|
+
var i, j, k, row;
|
|
745
|
+
|
|
746
|
+
for (i = 0; i < l; i++) {
|
|
747
|
+
if (/^ *-+: *$/.test(item.align[i])) {
|
|
748
|
+
item.align[i] = 'right';
|
|
749
|
+
} else if (/^ *:-+: *$/.test(item.align[i])) {
|
|
750
|
+
item.align[i] = 'center';
|
|
751
|
+
} else if (/^ *:-+ *$/.test(item.align[i])) {
|
|
752
|
+
item.align[i] = 'left';
|
|
753
|
+
} else {
|
|
754
|
+
item.align[i] = null;
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
l = item.rows.length;
|
|
759
|
+
|
|
760
|
+
for (i = 0; i < l; i++) {
|
|
761
|
+
item.rows[i] = splitCells(item.rows[i], item.header.length).map(function (c) {
|
|
762
|
+
return {
|
|
763
|
+
text: c
|
|
764
|
+
};
|
|
765
|
+
});
|
|
766
|
+
} // parse child tokens inside headers and cells
|
|
767
|
+
// header child tokens
|
|
768
|
+
|
|
769
|
+
|
|
770
|
+
l = item.header.length;
|
|
771
|
+
|
|
772
|
+
for (j = 0; j < l; j++) {
|
|
773
|
+
item.header[j].tokens = [];
|
|
774
|
+
this.lexer.inlineTokens(item.header[j].text, item.header[j].tokens);
|
|
775
|
+
} // cell child tokens
|
|
776
|
+
|
|
777
|
+
|
|
778
|
+
l = item.rows.length;
|
|
779
|
+
|
|
780
|
+
for (j = 0; j < l; j++) {
|
|
781
|
+
row = item.rows[j];
|
|
782
|
+
|
|
783
|
+
for (k = 0; k < row.length; k++) {
|
|
784
|
+
row[k].tokens = [];
|
|
785
|
+
this.lexer.inlineTokens(row[k].text, row[k].tokens);
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
return item;
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
};
|
|
793
|
+
|
|
794
|
+
_proto.lheading = function lheading(src) {
|
|
795
|
+
var cap = this.rules.block.lheading.exec(src);
|
|
796
|
+
|
|
797
|
+
if (cap) {
|
|
798
|
+
var token = {
|
|
799
|
+
type: 'heading',
|
|
800
|
+
raw: cap[0],
|
|
801
|
+
depth: cap[2].charAt(0) === '=' ? 1 : 2,
|
|
802
|
+
text: cap[1],
|
|
803
|
+
tokens: []
|
|
804
|
+
};
|
|
805
|
+
this.lexer.inline(token.text, token.tokens);
|
|
806
|
+
return token;
|
|
807
|
+
}
|
|
808
|
+
};
|
|
809
|
+
|
|
810
|
+
_proto.paragraph = function paragraph(src) {
|
|
811
|
+
var cap = this.rules.block.paragraph.exec(src);
|
|
812
|
+
|
|
813
|
+
if (cap) {
|
|
814
|
+
var token = {
|
|
815
|
+
type: 'paragraph',
|
|
816
|
+
raw: cap[0],
|
|
817
|
+
text: cap[1].charAt(cap[1].length - 1) === '\n' ? cap[1].slice(0, -1) : cap[1],
|
|
818
|
+
tokens: []
|
|
819
|
+
};
|
|
820
|
+
this.lexer.inline(token.text, token.tokens);
|
|
821
|
+
return token;
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
|
|
825
|
+
_proto.text = function text(src) {
|
|
826
|
+
var cap = this.rules.block.text.exec(src);
|
|
827
|
+
|
|
828
|
+
if (cap) {
|
|
829
|
+
var token = {
|
|
830
|
+
type: 'text',
|
|
831
|
+
raw: cap[0],
|
|
832
|
+
text: cap[0],
|
|
833
|
+
tokens: []
|
|
834
|
+
};
|
|
835
|
+
this.lexer.inline(token.text, token.tokens);
|
|
836
|
+
return token;
|
|
837
|
+
}
|
|
838
|
+
};
|
|
839
|
+
|
|
840
|
+
_proto.escape = function escape$1(src) {
|
|
841
|
+
var cap = this.rules.inline.escape.exec(src);
|
|
842
|
+
|
|
843
|
+
if (cap) {
|
|
844
|
+
return {
|
|
845
|
+
type: 'escape',
|
|
846
|
+
raw: cap[0],
|
|
847
|
+
text: escape(cap[1])
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
};
|
|
851
|
+
|
|
852
|
+
_proto.tag = function tag(src) {
|
|
853
|
+
var cap = this.rules.inline.tag.exec(src);
|
|
854
|
+
|
|
855
|
+
if (cap) {
|
|
856
|
+
if (!this.lexer.state.inLink && /^<a /i.test(cap[0])) {
|
|
857
|
+
this.lexer.state.inLink = true;
|
|
858
|
+
} else if (this.lexer.state.inLink && /^<\/a>/i.test(cap[0])) {
|
|
859
|
+
this.lexer.state.inLink = false;
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
if (!this.lexer.state.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
|
|
863
|
+
this.lexer.state.inRawBlock = true;
|
|
864
|
+
} else if (this.lexer.state.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
|
|
865
|
+
this.lexer.state.inRawBlock = false;
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
return {
|
|
869
|
+
type: this.options.sanitize ? 'text' : 'html',
|
|
870
|
+
raw: cap[0],
|
|
871
|
+
inLink: this.lexer.state.inLink,
|
|
872
|
+
inRawBlock: this.lexer.state.inRawBlock,
|
|
873
|
+
text: this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]) : cap[0]
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
};
|
|
877
|
+
|
|
878
|
+
_proto.link = function link(src) {
|
|
879
|
+
var cap = this.rules.inline.link.exec(src);
|
|
880
|
+
|
|
881
|
+
if (cap) {
|
|
882
|
+
var trimmedUrl = cap[2].trim();
|
|
883
|
+
|
|
884
|
+
if (!this.options.pedantic && /^</.test(trimmedUrl)) {
|
|
885
|
+
// commonmark requires matching angle brackets
|
|
886
|
+
if (!/>$/.test(trimmedUrl)) {
|
|
887
|
+
return;
|
|
888
|
+
} // ending angle bracket cannot be escaped
|
|
889
|
+
|
|
890
|
+
|
|
891
|
+
var rtrimSlash = rtrim(trimmedUrl.slice(0, -1), '\\');
|
|
892
|
+
|
|
893
|
+
if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) {
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
} else {
|
|
897
|
+
// find closing parenthesis
|
|
898
|
+
var lastParenIndex = findClosingBracket(cap[2], '()');
|
|
899
|
+
|
|
900
|
+
if (lastParenIndex > -1) {
|
|
901
|
+
var start = cap[0].indexOf('!') === 0 ? 5 : 4;
|
|
902
|
+
var linkLen = start + cap[1].length + lastParenIndex;
|
|
903
|
+
cap[2] = cap[2].substring(0, lastParenIndex);
|
|
904
|
+
cap[0] = cap[0].substring(0, linkLen).trim();
|
|
905
|
+
cap[3] = '';
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
var href = cap[2];
|
|
910
|
+
var title = '';
|
|
911
|
+
|
|
912
|
+
if (this.options.pedantic) {
|
|
913
|
+
// split pedantic href and title
|
|
914
|
+
var link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
|
|
915
|
+
|
|
916
|
+
if (link) {
|
|
917
|
+
href = link[1];
|
|
918
|
+
title = link[3];
|
|
919
|
+
}
|
|
920
|
+
} else {
|
|
921
|
+
title = cap[3] ? cap[3].slice(1, -1) : '';
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
href = href.trim();
|
|
925
|
+
|
|
926
|
+
if (/^</.test(href)) {
|
|
927
|
+
if (this.options.pedantic && !/>$/.test(trimmedUrl)) {
|
|
928
|
+
// pedantic allows starting angle bracket without ending angle bracket
|
|
929
|
+
href = href.slice(1);
|
|
930
|
+
} else {
|
|
931
|
+
href = href.slice(1, -1);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
return outputLink(cap, {
|
|
936
|
+
href: href ? href.replace(this.rules.inline._escapes, '$1') : href,
|
|
937
|
+
title: title ? title.replace(this.rules.inline._escapes, '$1') : title
|
|
938
|
+
}, cap[0], this.lexer);
|
|
939
|
+
}
|
|
940
|
+
};
|
|
941
|
+
|
|
942
|
+
_proto.reflink = function reflink(src, links) {
|
|
943
|
+
var cap;
|
|
944
|
+
|
|
945
|
+
if ((cap = this.rules.inline.reflink.exec(src)) || (cap = this.rules.inline.nolink.exec(src))) {
|
|
946
|
+
var link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
|
|
947
|
+
link = links[link.toLowerCase()];
|
|
948
|
+
|
|
949
|
+
if (!link || !link.href) {
|
|
950
|
+
var text = cap[0].charAt(0);
|
|
951
|
+
return {
|
|
952
|
+
type: 'text',
|
|
953
|
+
raw: text,
|
|
954
|
+
text: text
|
|
955
|
+
};
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
return outputLink(cap, link, cap[0], this.lexer);
|
|
959
|
+
}
|
|
960
|
+
};
|
|
961
|
+
|
|
962
|
+
_proto.emStrong = function emStrong(src, maskedSrc, prevChar) {
|
|
963
|
+
if (prevChar === void 0) {
|
|
964
|
+
prevChar = '';
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
var match = this.rules.inline.emStrong.lDelim.exec(src);
|
|
968
|
+
if (!match) return; // _ can't be between two alphanumerics. \p{L}\p{N} includes non-english alphabet/numbers as well
|
|
969
|
+
|
|
970
|
+
if (match[3] && prevChar.match(/(?:[0-9A-Za-z\xAA\xB2\xB3\xB5\xB9\xBA\xBC-\xBE\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u0660-\u0669\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07C0-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0966-\u096F\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09E6-\u09F1\u09F4-\u09F9\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A66-\u0A6F\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AE6-\u0AEF\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B66-\u0B6F\u0B71-\u0B77\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0BE6-\u0BF2\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C66-\u0C6F\u0C78-\u0C7E\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CE6-\u0CEF\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D58-\u0D61\u0D66-\u0D78\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DE6-\u0DEF\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F20-\u0F33\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F-\u1049\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u1090-\u1099\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1369-\u137C\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A16\u1A20-\u1A54\u1A80-\u1A89\u1A90-\u1A99\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B50-\u1B59\u1B83-\u1BA0\u1BAE-\u1BE5\u1C00-\u1C23\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2070\u2071\u2074-\u2079\u207F-\u2089\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2150-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2CFD\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u3192-\u3195\u31A0-\u31BF\u31F0-\u31FF\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA830-\uA835\uA840-\uA873\uA882-\uA8B3\uA8D0-\uA8D9\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA900-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF-\uA9D9\uA9E0-\uA9E4\uA9E6-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA50-\uAA59\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDE80-\uDE9C\uDEA0-\uDED0\uDEE1-\uDEFB\uDF00-\uDF23\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC58-\uDC76\uDC79-\uDC9E\uDCA7-\uDCAF\uDCE0-\uDCF2\uDCF4\uDCF5\uDCFB-\uDD1B\uDD20-\uDD39\uDD80-\uDDB7\uDDBC-\uDDCF\uDDD2-\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE40-\uDE48\uDE60-\uDE7E\uDE80-\uDE9F\uDEC0-\uDEC7\uDEC9-\uDEE4\uDEEB-\uDEEF\uDF00-\uDF35\uDF40-\uDF55\uDF58-\uDF72\uDF78-\uDF91\uDFA9-\uDFAF]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDCFA-\uDD23\uDD30-\uDD39\uDE60-\uDE7E\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF27\uDF30-\uDF45\uDF51-\uDF54\uDF70-\uDF81\uDFB0-\uDFCB\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC52-\uDC6F\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD03-\uDD26\uDD36-\uDD3F\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDD0-\uDDDA\uDDDC\uDDE1-\uDDF4\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDEF0-\uDEF9\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC50-\uDC59\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE50-\uDE59\uDE80-\uDEAA\uDEB8\uDEC0-\uDEC9\uDF00-\uDF1A\uDF30-\uDF3B\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCF2\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDD50-\uDD59\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC50-\uDC6C\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD50-\uDD59\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDDA0-\uDDA9\uDEE0-\uDEF2\uDFB0\uDFC0-\uDFD4]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDE70-\uDEBE\uDEC0-\uDEC9\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF50-\uDF59\uDF5B-\uDF61\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE96\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD837[\uDF00-\uDF1E]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD40-\uDD49\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB\uDEF0-\uDEF9]|\uD839[\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDCC7-\uDCCF\uDD00-\uDD43\uDD4B\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF38\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/)) return;
|
|
971
|
+
var nextChar = match[1] || match[2] || '';
|
|
972
|
+
|
|
973
|
+
if (!nextChar || nextChar && (prevChar === '' || this.rules.inline.punctuation.exec(prevChar))) {
|
|
974
|
+
var lLength = match[0].length - 1;
|
|
975
|
+
var rDelim,
|
|
976
|
+
rLength,
|
|
977
|
+
delimTotal = lLength,
|
|
978
|
+
midDelimTotal = 0;
|
|
979
|
+
var endReg = match[0][0] === '*' ? this.rules.inline.emStrong.rDelimAst : this.rules.inline.emStrong.rDelimUnd;
|
|
980
|
+
endReg.lastIndex = 0; // Clip maskedSrc to same section of string as src (move to lexer?)
|
|
981
|
+
|
|
982
|
+
maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
|
|
983
|
+
|
|
984
|
+
while ((match = endReg.exec(maskedSrc)) != null) {
|
|
985
|
+
rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
|
|
986
|
+
if (!rDelim) continue; // skip single * in __abc*abc__
|
|
987
|
+
|
|
988
|
+
rLength = rDelim.length;
|
|
989
|
+
|
|
990
|
+
if (match[3] || match[4]) {
|
|
991
|
+
// found another Left Delim
|
|
992
|
+
delimTotal += rLength;
|
|
993
|
+
continue;
|
|
994
|
+
} else if (match[5] || match[6]) {
|
|
995
|
+
// either Left or Right Delim
|
|
996
|
+
if (lLength % 3 && !((lLength + rLength) % 3)) {
|
|
997
|
+
midDelimTotal += rLength;
|
|
998
|
+
continue; // CommonMark Emphasis Rules 9-10
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
delimTotal -= rLength;
|
|
1003
|
+
if (delimTotal > 0) continue; // Haven't found enough closing delimiters
|
|
1004
|
+
// Remove extra characters. *a*** -> *a*
|
|
1005
|
+
|
|
1006
|
+
rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal); // Create `em` if smallest delimiter has odd char count. *a***
|
|
1007
|
+
|
|
1008
|
+
if (Math.min(lLength, rLength) % 2) {
|
|
1009
|
+
var _text = src.slice(1, lLength + match.index + rLength);
|
|
1010
|
+
|
|
1011
|
+
return {
|
|
1012
|
+
type: 'em',
|
|
1013
|
+
raw: src.slice(0, lLength + match.index + rLength + 1),
|
|
1014
|
+
text: _text,
|
|
1015
|
+
tokens: this.lexer.inlineTokens(_text, [])
|
|
1016
|
+
};
|
|
1017
|
+
} // Create 'strong' if smallest delimiter has even char count. **a***
|
|
1018
|
+
|
|
1019
|
+
|
|
1020
|
+
var text = src.slice(2, lLength + match.index + rLength - 1);
|
|
1021
|
+
return {
|
|
1022
|
+
type: 'strong',
|
|
1023
|
+
raw: src.slice(0, lLength + match.index + rLength + 1),
|
|
1024
|
+
text: text,
|
|
1025
|
+
tokens: this.lexer.inlineTokens(text, [])
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
};
|
|
1030
|
+
|
|
1031
|
+
_proto.codespan = function codespan(src) {
|
|
1032
|
+
var cap = this.rules.inline.code.exec(src);
|
|
1033
|
+
|
|
1034
|
+
if (cap) {
|
|
1035
|
+
var text = cap[2].replace(/\n/g, ' ');
|
|
1036
|
+
var hasNonSpaceChars = /[^ ]/.test(text);
|
|
1037
|
+
var hasSpaceCharsOnBothEnds = /^ /.test(text) && / $/.test(text);
|
|
1038
|
+
|
|
1039
|
+
if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
|
|
1040
|
+
text = text.substring(1, text.length - 1);
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
text = escape(text, true);
|
|
1044
|
+
return {
|
|
1045
|
+
type: 'codespan',
|
|
1046
|
+
raw: cap[0],
|
|
1047
|
+
text: text
|
|
1048
|
+
};
|
|
1049
|
+
}
|
|
1050
|
+
};
|
|
1051
|
+
|
|
1052
|
+
_proto.br = function br(src) {
|
|
1053
|
+
var cap = this.rules.inline.br.exec(src);
|
|
1054
|
+
|
|
1055
|
+
if (cap) {
|
|
1056
|
+
return {
|
|
1057
|
+
type: 'br',
|
|
1058
|
+
raw: cap[0]
|
|
1059
|
+
};
|
|
1060
|
+
}
|
|
1061
|
+
};
|
|
1062
|
+
|
|
1063
|
+
_proto.del = function del(src) {
|
|
1064
|
+
var cap = this.rules.inline.del.exec(src);
|
|
1065
|
+
|
|
1066
|
+
if (cap) {
|
|
1067
|
+
return {
|
|
1068
|
+
type: 'del',
|
|
1069
|
+
raw: cap[0],
|
|
1070
|
+
text: cap[2],
|
|
1071
|
+
tokens: this.lexer.inlineTokens(cap[2], [])
|
|
1072
|
+
};
|
|
1073
|
+
}
|
|
1074
|
+
};
|
|
1075
|
+
|
|
1076
|
+
_proto.autolink = function autolink(src, mangle) {
|
|
1077
|
+
var cap = this.rules.inline.autolink.exec(src);
|
|
1078
|
+
|
|
1079
|
+
if (cap) {
|
|
1080
|
+
var text, href;
|
|
1081
|
+
|
|
1082
|
+
if (cap[2] === '@') {
|
|
1083
|
+
text = escape(this.options.mangle ? mangle(cap[1]) : cap[1]);
|
|
1084
|
+
href = 'mailto:' + text;
|
|
1085
|
+
} else {
|
|
1086
|
+
text = escape(cap[1]);
|
|
1087
|
+
href = text;
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
return {
|
|
1091
|
+
type: 'link',
|
|
1092
|
+
raw: cap[0],
|
|
1093
|
+
text: text,
|
|
1094
|
+
href: href,
|
|
1095
|
+
tokens: [{
|
|
1096
|
+
type: 'text',
|
|
1097
|
+
raw: text,
|
|
1098
|
+
text: text
|
|
1099
|
+
}]
|
|
1100
|
+
};
|
|
1101
|
+
}
|
|
1102
|
+
};
|
|
1103
|
+
|
|
1104
|
+
_proto.url = function url(src, mangle) {
|
|
1105
|
+
var cap;
|
|
1106
|
+
|
|
1107
|
+
if (cap = this.rules.inline.url.exec(src)) {
|
|
1108
|
+
var text, href;
|
|
1109
|
+
|
|
1110
|
+
if (cap[2] === '@') {
|
|
1111
|
+
text = escape(this.options.mangle ? mangle(cap[0]) : cap[0]);
|
|
1112
|
+
href = 'mailto:' + text;
|
|
1113
|
+
} else {
|
|
1114
|
+
// do extended autolink path validation
|
|
1115
|
+
var prevCapZero;
|
|
1116
|
+
|
|
1117
|
+
do {
|
|
1118
|
+
prevCapZero = cap[0];
|
|
1119
|
+
cap[0] = this.rules.inline._backpedal.exec(cap[0])[0];
|
|
1120
|
+
} while (prevCapZero !== cap[0]);
|
|
1121
|
+
|
|
1122
|
+
text = escape(cap[0]);
|
|
1123
|
+
|
|
1124
|
+
if (cap[1] === 'www.') {
|
|
1125
|
+
href = 'http://' + text;
|
|
1126
|
+
} else {
|
|
1127
|
+
href = text;
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
return {
|
|
1132
|
+
type: 'link',
|
|
1133
|
+
raw: cap[0],
|
|
1134
|
+
text: text,
|
|
1135
|
+
href: href,
|
|
1136
|
+
tokens: [{
|
|
1137
|
+
type: 'text',
|
|
1138
|
+
raw: text,
|
|
1139
|
+
text: text
|
|
1140
|
+
}]
|
|
1141
|
+
};
|
|
1142
|
+
}
|
|
1143
|
+
};
|
|
1144
|
+
|
|
1145
|
+
_proto.inlineText = function inlineText(src, smartypants) {
|
|
1146
|
+
var cap = this.rules.inline.text.exec(src);
|
|
1147
|
+
|
|
1148
|
+
if (cap) {
|
|
1149
|
+
var text;
|
|
1150
|
+
|
|
1151
|
+
if (this.lexer.state.inRawBlock) {
|
|
1152
|
+
text = this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]) : cap[0];
|
|
1153
|
+
} else {
|
|
1154
|
+
text = escape(this.options.smartypants ? smartypants(cap[0]) : cap[0]);
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
return {
|
|
1158
|
+
type: 'text',
|
|
1159
|
+
raw: cap[0],
|
|
1160
|
+
text: text
|
|
1161
|
+
};
|
|
1162
|
+
}
|
|
1163
|
+
};
|
|
1164
|
+
|
|
1165
|
+
return Tokenizer;
|
|
1166
|
+
}();
|
|
1167
|
+
|
|
1168
|
+
/**
|
|
1169
|
+
* Block-Level Grammar
|
|
1170
|
+
*/
|
|
1171
|
+
|
|
1172
|
+
var block = {
|
|
1173
|
+
newline: /^(?: *(?:\n|$))+/,
|
|
1174
|
+
code: /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,
|
|
1175
|
+
fences: /^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?=\n|$)|$)/,
|
|
1176
|
+
hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
|
|
1177
|
+
heading: /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,
|
|
1178
|
+
blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
|
|
1179
|
+
list: /^( {0,3}bull)( [^\n]+?)?(?:\n|$)/,
|
|
1180
|
+
html: '^ {0,3}(?:' // optional indentation
|
|
1181
|
+
+ '<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
|
|
1182
|
+
+ '|comment[^\\n]*(\\n+|$)' // (2)
|
|
1183
|
+
+ '|<\\?[\\s\\S]*?(?:\\?>\\n*|$)' // (3)
|
|
1184
|
+
+ '|<![A-Z][\\s\\S]*?(?:>\\n*|$)' // (4)
|
|
1185
|
+
+ '|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)' // (5)
|
|
1186
|
+
+ '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (6)
|
|
1187
|
+
+ '|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) open tag
|
|
1188
|
+
+ '|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) closing tag
|
|
1189
|
+
+ ')',
|
|
1190
|
+
def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
|
|
1191
|
+
table: noopTest,
|
|
1192
|
+
lheading: /^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
1193
|
+
// regex template, placeholders will be replaced according to different paragraph
|
|
1194
|
+
// interruption rules of commonmark and the original markdown spec:
|
|
1195
|
+
_paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html| +\n)[^\n]+)*)/,
|
|
1196
|
+
text: /^[^\n]+/
|
|
1197
|
+
};
|
|
1198
|
+
block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/;
|
|
1199
|
+
block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
|
|
1200
|
+
block.def = edit(block.def).replace('label', block._label).replace('title', block._title).getRegex();
|
|
1201
|
+
block.bullet = /(?:[*+-]|\d{1,9}[.)])/;
|
|
1202
|
+
block.listItemStart = edit(/^( *)(bull) */).replace('bull', block.bullet).getRegex();
|
|
1203
|
+
block.list = edit(block.list).replace(/bull/g, block.bullet).replace('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))').replace('def', '\\n+(?=' + block.def.source + ')').getRegex();
|
|
1204
|
+
block._tag = 'address|article|aside|base|basefont|blockquote|body|caption' + '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption' + '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe' + '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option' + '|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr' + '|track|ul';
|
|
1205
|
+
block._comment = /<!--(?!-?>)[\s\S]*?(?:-->|$)/;
|
|
1206
|
+
block.html = edit(block.html, 'i').replace('comment', block._comment).replace('tag', block._tag).replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
|
|
1207
|
+
block.paragraph = edit(block._paragraph).replace('hr', block.hr).replace('heading', ' {0,3}#{1,6} ').replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
|
|
1208
|
+
.replace('blockquote', ' {0,3}>').replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n').replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
1209
|
+
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)').replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
|
|
1210
|
+
.getRegex();
|
|
1211
|
+
block.blockquote = edit(block.blockquote).replace('paragraph', block.paragraph).getRegex();
|
|
1212
|
+
/**
|
|
1213
|
+
* Normal Block Grammar
|
|
1214
|
+
*/
|
|
1215
|
+
|
|
1216
|
+
block.normal = merge({}, block);
|
|
1217
|
+
/**
|
|
1218
|
+
* GFM Block Grammar
|
|
1219
|
+
*/
|
|
1220
|
+
|
|
1221
|
+
block.gfm = merge({}, block.normal, {
|
|
1222
|
+
table: '^ *([^\\n ].*\\|.*)\\n' // Header
|
|
1223
|
+
+ ' {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?' // Align
|
|
1224
|
+
+ '(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)' // Cells
|
|
1225
|
+
|
|
1226
|
+
});
|
|
1227
|
+
block.gfm.table = edit(block.gfm.table).replace('hr', block.hr).replace('heading', ' {0,3}#{1,6} ').replace('blockquote', ' {0,3}>').replace('code', ' {4}[^\\n]').replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n').replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
1228
|
+
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)').replace('tag', block._tag) // tables can be interrupted by type (6) html blocks
|
|
1229
|
+
.getRegex();
|
|
1230
|
+
/**
|
|
1231
|
+
* Pedantic grammar (original John Gruber's loose markdown specification)
|
|
1232
|
+
*/
|
|
1233
|
+
|
|
1234
|
+
block.pedantic = merge({}, block.normal, {
|
|
1235
|
+
html: edit('^ *(?:comment *(?:\\n|\\s*$)' + '|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' // closed tag
|
|
1236
|
+
+ '|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))').replace('comment', block._comment).replace(/tag/g, '(?!(?:' + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub' + '|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)' + '\\b)\\w+(?!:|[^\\w\\s@]*@)\\b').getRegex(),
|
|
1237
|
+
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
1238
|
+
heading: /^(#{1,6})(.*)(?:\n+|$)/,
|
|
1239
|
+
fences: noopTest,
|
|
1240
|
+
// fences not supported
|
|
1241
|
+
paragraph: edit(block.normal._paragraph).replace('hr', block.hr).replace('heading', ' *#{1,6} *[^\n]').replace('lheading', block.lheading).replace('blockquote', ' {0,3}>').replace('|fences', '').replace('|list', '').replace('|html', '').getRegex()
|
|
1242
|
+
});
|
|
1243
|
+
/**
|
|
1244
|
+
* Inline-Level Grammar
|
|
1245
|
+
*/
|
|
1246
|
+
|
|
1247
|
+
var inline = {
|
|
1248
|
+
escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
|
|
1249
|
+
autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
|
|
1250
|
+
url: noopTest,
|
|
1251
|
+
tag: '^comment' + '|^</[a-zA-Z][\\w:-]*\\s*>' // self-closing tag
|
|
1252
|
+
+ '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag
|
|
1253
|
+
+ '|^<\\?[\\s\\S]*?\\?>' // processing instruction, e.g. <?php ?>
|
|
1254
|
+
+ '|^<![a-zA-Z]+\\s[\\s\\S]*?>' // declaration, e.g. <!DOCTYPE html>
|
|
1255
|
+
+ '|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>',
|
|
1256
|
+
// CDATA section
|
|
1257
|
+
link: /^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,
|
|
1258
|
+
reflink: /^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,
|
|
1259
|
+
nolink: /^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,
|
|
1260
|
+
reflinkSearch: 'reflink|nolink(?!\\()',
|
|
1261
|
+
emStrong: {
|
|
1262
|
+
lDelim: /^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,
|
|
1263
|
+
// (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.
|
|
1264
|
+
// () Skip orphan delim inside strong (1) #*** (2) a***#, a*** (3) #***a, ***a (4) ***# (5) #***# (6) a***a
|
|
1265
|
+
rDelimAst: /^[^_*]*?\_\_[^_*]*?\*[^_*]*?(?=\_\_)|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,
|
|
1266
|
+
rDelimUnd: /^[^_*]*?\*\*[^_*]*?\_[^_*]*?(?=\*\*)|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/ // ^- Not allowed for _
|
|
1267
|
+
|
|
1268
|
+
},
|
|
1269
|
+
code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
|
|
1270
|
+
br: /^( {2,}|\\)\n(?!\s*$)/,
|
|
1271
|
+
del: noopTest,
|
|
1272
|
+
text: /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,
|
|
1273
|
+
punctuation: /^([\spunctuation])/
|
|
1274
|
+
}; // list of punctuation marks from CommonMark spec
|
|
1275
|
+
// without * and _ to handle the different emphasis markers * and _
|
|
1276
|
+
|
|
1277
|
+
inline._punctuation = '!"#$%&\'()+\\-.,/:;<=>?@\\[\\]`^{|}~';
|
|
1278
|
+
inline.punctuation = edit(inline.punctuation).replace(/punctuation/g, inline._punctuation).getRegex(); // sequences em should skip over [title](link), `code`, <html>
|
|
1279
|
+
|
|
1280
|
+
inline.blockSkip = /\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g;
|
|
1281
|
+
inline.escapedEmSt = /\\\*|\\_/g;
|
|
1282
|
+
inline._comment = edit(block._comment).replace('(?:-->|$)', '-->').getRegex();
|
|
1283
|
+
inline.emStrong.lDelim = edit(inline.emStrong.lDelim).replace(/punct/g, inline._punctuation).getRegex();
|
|
1284
|
+
inline.emStrong.rDelimAst = edit(inline.emStrong.rDelimAst, 'g').replace(/punct/g, inline._punctuation).getRegex();
|
|
1285
|
+
inline.emStrong.rDelimUnd = edit(inline.emStrong.rDelimUnd, 'g').replace(/punct/g, inline._punctuation).getRegex();
|
|
1286
|
+
inline._escapes = /\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;
|
|
1287
|
+
inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
|
|
1288
|
+
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])?)+(?![-_])/;
|
|
1289
|
+
inline.autolink = edit(inline.autolink).replace('scheme', inline._scheme).replace('email', inline._email).getRegex();
|
|
1290
|
+
inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
|
|
1291
|
+
inline.tag = edit(inline.tag).replace('comment', inline._comment).replace('attribute', inline._attribute).getRegex();
|
|
1292
|
+
inline._label = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
|
|
1293
|
+
inline._href = /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;
|
|
1294
|
+
inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
|
|
1295
|
+
inline.link = edit(inline.link).replace('label', inline._label).replace('href', inline._href).replace('title', inline._title).getRegex();
|
|
1296
|
+
inline.reflink = edit(inline.reflink).replace('label', inline._label).getRegex();
|
|
1297
|
+
inline.reflinkSearch = edit(inline.reflinkSearch, 'g').replace('reflink', inline.reflink).replace('nolink', inline.nolink).getRegex();
|
|
1298
|
+
/**
|
|
1299
|
+
* Normal Inline Grammar
|
|
1300
|
+
*/
|
|
1301
|
+
|
|
1302
|
+
inline.normal = merge({}, inline);
|
|
1303
|
+
/**
|
|
1304
|
+
* Pedantic Inline Grammar
|
|
1305
|
+
*/
|
|
1306
|
+
|
|
1307
|
+
inline.pedantic = merge({}, inline.normal, {
|
|
1308
|
+
strong: {
|
|
1309
|
+
start: /^__|\*\*/,
|
|
1310
|
+
middle: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
|
|
1311
|
+
endAst: /\*\*(?!\*)/g,
|
|
1312
|
+
endUnd: /__(?!_)/g
|
|
1313
|
+
},
|
|
1314
|
+
em: {
|
|
1315
|
+
start: /^_|\*/,
|
|
1316
|
+
middle: /^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,
|
|
1317
|
+
endAst: /\*(?!\*)/g,
|
|
1318
|
+
endUnd: /_(?!_)/g
|
|
1319
|
+
},
|
|
1320
|
+
link: edit(/^!?\[(label)\]\((.*?)\)/).replace('label', inline._label).getRegex(),
|
|
1321
|
+
reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace('label', inline._label).getRegex()
|
|
1322
|
+
});
|
|
1323
|
+
/**
|
|
1324
|
+
* GFM Inline Grammar
|
|
1325
|
+
*/
|
|
1326
|
+
|
|
1327
|
+
inline.gfm = merge({}, inline.normal, {
|
|
1328
|
+
escape: edit(inline.escape).replace('])', '~|])').getRegex(),
|
|
1329
|
+
_extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
|
|
1330
|
+
url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
|
|
1331
|
+
_backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
|
|
1332
|
+
del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
|
|
1333
|
+
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
|
|
1334
|
+
});
|
|
1335
|
+
inline.gfm.url = edit(inline.gfm.url, 'i').replace('email', inline.gfm._extended_email).getRegex();
|
|
1336
|
+
/**
|
|
1337
|
+
* GFM + Line Breaks Inline Grammar
|
|
1338
|
+
*/
|
|
1339
|
+
|
|
1340
|
+
inline.breaks = merge({}, inline.gfm, {
|
|
1341
|
+
br: edit(inline.br).replace('{2,}', '*').getRegex(),
|
|
1342
|
+
text: edit(inline.gfm.text).replace('\\b_', '\\b_| {2,}\\n').replace(/\{2,\}/g, '*').getRegex()
|
|
1343
|
+
});
|
|
1344
|
+
|
|
1345
|
+
/**
|
|
1346
|
+
* smartypants text replacement
|
|
1347
|
+
*/
|
|
1348
|
+
|
|
1349
|
+
function smartypants(text) {
|
|
1350
|
+
return text // em-dashes
|
|
1351
|
+
.replace(/---/g, "\u2014") // en-dashes
|
|
1352
|
+
.replace(/--/g, "\u2013") // opening singles
|
|
1353
|
+
.replace(/(^|[-\u2014/(\[{"\s])'/g, "$1\u2018") // closing singles & apostrophes
|
|
1354
|
+
.replace(/'/g, "\u2019") // opening doubles
|
|
1355
|
+
.replace(/(^|[-\u2014/(\[{\u2018\s])"/g, "$1\u201C") // closing doubles
|
|
1356
|
+
.replace(/"/g, "\u201D") // ellipses
|
|
1357
|
+
.replace(/\.{3}/g, "\u2026");
|
|
1358
|
+
}
|
|
1359
|
+
/**
|
|
1360
|
+
* mangle email addresses
|
|
1361
|
+
*/
|
|
1362
|
+
|
|
1363
|
+
|
|
1364
|
+
function mangle(text) {
|
|
1365
|
+
var out = '',
|
|
1366
|
+
i,
|
|
1367
|
+
ch;
|
|
1368
|
+
var l = text.length;
|
|
1369
|
+
|
|
1370
|
+
for (i = 0; i < l; i++) {
|
|
1371
|
+
ch = text.charCodeAt(i);
|
|
1372
|
+
|
|
1373
|
+
if (Math.random() > 0.5) {
|
|
1374
|
+
ch = 'x' + ch.toString(16);
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
out += '&#' + ch + ';';
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
return out;
|
|
1381
|
+
}
|
|
1382
|
+
/**
|
|
1383
|
+
* Block Lexer
|
|
1384
|
+
*/
|
|
1385
|
+
|
|
1386
|
+
|
|
1387
|
+
var Lexer = /*#__PURE__*/function () {
|
|
1388
|
+
function Lexer(options) {
|
|
1389
|
+
this.tokens = [];
|
|
1390
|
+
this.tokens.links = Object.create(null);
|
|
1391
|
+
this.options = options || exports.defaults;
|
|
1392
|
+
this.options.tokenizer = this.options.tokenizer || new Tokenizer();
|
|
1393
|
+
this.tokenizer = this.options.tokenizer;
|
|
1394
|
+
this.tokenizer.options = this.options;
|
|
1395
|
+
this.tokenizer.lexer = this;
|
|
1396
|
+
this.inlineQueue = [];
|
|
1397
|
+
this.state = {
|
|
1398
|
+
inLink: false,
|
|
1399
|
+
inRawBlock: false,
|
|
1400
|
+
top: true
|
|
1401
|
+
};
|
|
1402
|
+
var rules = {
|
|
1403
|
+
block: block.normal,
|
|
1404
|
+
inline: inline.normal
|
|
1405
|
+
};
|
|
1406
|
+
|
|
1407
|
+
if (this.options.pedantic) {
|
|
1408
|
+
rules.block = block.pedantic;
|
|
1409
|
+
rules.inline = inline.pedantic;
|
|
1410
|
+
} else if (this.options.gfm) {
|
|
1411
|
+
rules.block = block.gfm;
|
|
1412
|
+
|
|
1413
|
+
if (this.options.breaks) {
|
|
1414
|
+
rules.inline = inline.breaks;
|
|
1415
|
+
} else {
|
|
1416
|
+
rules.inline = inline.gfm;
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
this.tokenizer.rules = rules;
|
|
1421
|
+
}
|
|
1422
|
+
/**
|
|
1423
|
+
* Expose Rules
|
|
1424
|
+
*/
|
|
1425
|
+
|
|
1426
|
+
|
|
1427
|
+
/**
|
|
1428
|
+
* Static Lex Method
|
|
1429
|
+
*/
|
|
1430
|
+
Lexer.lex = function lex(src, options) {
|
|
1431
|
+
var lexer = new Lexer(options);
|
|
1432
|
+
return lexer.lex(src);
|
|
1433
|
+
}
|
|
1434
|
+
/**
|
|
1435
|
+
* Static Lex Inline Method
|
|
1436
|
+
*/
|
|
1437
|
+
;
|
|
1438
|
+
|
|
1439
|
+
Lexer.lexInline = function lexInline(src, options) {
|
|
1440
|
+
var lexer = new Lexer(options);
|
|
1441
|
+
return lexer.inlineTokens(src);
|
|
1442
|
+
}
|
|
1443
|
+
/**
|
|
1444
|
+
* Preprocessing
|
|
1445
|
+
*/
|
|
1446
|
+
;
|
|
1447
|
+
|
|
1448
|
+
var _proto = Lexer.prototype;
|
|
1449
|
+
|
|
1450
|
+
_proto.lex = function lex(src) {
|
|
1451
|
+
src = src.replace(/\r\n|\r/g, '\n').replace(/\t/g, ' ');
|
|
1452
|
+
this.blockTokens(src, this.tokens);
|
|
1453
|
+
var next;
|
|
1454
|
+
|
|
1455
|
+
while (next = this.inlineQueue.shift()) {
|
|
1456
|
+
this.inlineTokens(next.src, next.tokens);
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
return this.tokens;
|
|
1460
|
+
}
|
|
1461
|
+
/**
|
|
1462
|
+
* Lexing
|
|
1463
|
+
*/
|
|
1464
|
+
;
|
|
1465
|
+
|
|
1466
|
+
_proto.blockTokens = function blockTokens(src, tokens) {
|
|
1467
|
+
var _this = this;
|
|
1468
|
+
|
|
1469
|
+
if (tokens === void 0) {
|
|
1470
|
+
tokens = [];
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
if (this.options.pedantic) {
|
|
1474
|
+
src = src.replace(/^ +$/gm, '');
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
var token, lastToken, cutSrc, lastParagraphClipped;
|
|
1478
|
+
|
|
1479
|
+
while (src) {
|
|
1480
|
+
if (this.options.extensions && this.options.extensions.block && this.options.extensions.block.some(function (extTokenizer) {
|
|
1481
|
+
if (token = extTokenizer.call({
|
|
1482
|
+
lexer: _this
|
|
1483
|
+
}, src, tokens)) {
|
|
1484
|
+
src = src.substring(token.raw.length);
|
|
1485
|
+
tokens.push(token);
|
|
1486
|
+
return true;
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
return false;
|
|
1490
|
+
})) {
|
|
1491
|
+
continue;
|
|
1492
|
+
} // newline
|
|
1493
|
+
|
|
1494
|
+
|
|
1495
|
+
if (token = this.tokenizer.space(src)) {
|
|
1496
|
+
src = src.substring(token.raw.length);
|
|
1497
|
+
|
|
1498
|
+
if (token.type) {
|
|
1499
|
+
tokens.push(token);
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
continue;
|
|
1503
|
+
} // code
|
|
1504
|
+
|
|
1505
|
+
|
|
1506
|
+
if (token = this.tokenizer.code(src)) {
|
|
1507
|
+
src = src.substring(token.raw.length);
|
|
1508
|
+
lastToken = tokens[tokens.length - 1]; // An indented code block cannot interrupt a paragraph.
|
|
1509
|
+
|
|
1510
|
+
if (lastToken && (lastToken.type === 'paragraph' || lastToken.type === 'text')) {
|
|
1511
|
+
lastToken.raw += '\n' + token.raw;
|
|
1512
|
+
lastToken.text += '\n' + token.text;
|
|
1513
|
+
this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
|
|
1514
|
+
} else {
|
|
1515
|
+
tokens.push(token);
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
continue;
|
|
1519
|
+
} // fences
|
|
1520
|
+
|
|
1521
|
+
|
|
1522
|
+
if (token = this.tokenizer.fences(src)) {
|
|
1523
|
+
src = src.substring(token.raw.length);
|
|
1524
|
+
tokens.push(token);
|
|
1525
|
+
continue;
|
|
1526
|
+
} // heading
|
|
1527
|
+
|
|
1528
|
+
|
|
1529
|
+
if (token = this.tokenizer.heading(src)) {
|
|
1530
|
+
src = src.substring(token.raw.length);
|
|
1531
|
+
tokens.push(token);
|
|
1532
|
+
continue;
|
|
1533
|
+
} // hr
|
|
1534
|
+
|
|
1535
|
+
|
|
1536
|
+
if (token = this.tokenizer.hr(src)) {
|
|
1537
|
+
src = src.substring(token.raw.length);
|
|
1538
|
+
tokens.push(token);
|
|
1539
|
+
continue;
|
|
1540
|
+
} // blockquote
|
|
1541
|
+
|
|
1542
|
+
|
|
1543
|
+
if (token = this.tokenizer.blockquote(src)) {
|
|
1544
|
+
src = src.substring(token.raw.length);
|
|
1545
|
+
tokens.push(token);
|
|
1546
|
+
continue;
|
|
1547
|
+
} // list
|
|
1548
|
+
|
|
1549
|
+
|
|
1550
|
+
if (token = this.tokenizer.list(src)) {
|
|
1551
|
+
src = src.substring(token.raw.length);
|
|
1552
|
+
tokens.push(token);
|
|
1553
|
+
continue;
|
|
1554
|
+
} // html
|
|
1555
|
+
|
|
1556
|
+
|
|
1557
|
+
if (token = this.tokenizer.html(src)) {
|
|
1558
|
+
src = src.substring(token.raw.length);
|
|
1559
|
+
tokens.push(token);
|
|
1560
|
+
continue;
|
|
1561
|
+
} // def
|
|
1562
|
+
|
|
1563
|
+
|
|
1564
|
+
if (token = this.tokenizer.def(src)) {
|
|
1565
|
+
src = src.substring(token.raw.length);
|
|
1566
|
+
lastToken = tokens[tokens.length - 1];
|
|
1567
|
+
|
|
1568
|
+
if (lastToken && (lastToken.type === 'paragraph' || lastToken.type === 'text')) {
|
|
1569
|
+
lastToken.raw += '\n' + token.raw;
|
|
1570
|
+
lastToken.text += '\n' + token.raw;
|
|
1571
|
+
this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
|
|
1572
|
+
} else if (!this.tokens.links[token.tag]) {
|
|
1573
|
+
this.tokens.links[token.tag] = {
|
|
1574
|
+
href: token.href,
|
|
1575
|
+
title: token.title
|
|
1576
|
+
};
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1579
|
+
continue;
|
|
1580
|
+
} // table (gfm)
|
|
1581
|
+
|
|
1582
|
+
|
|
1583
|
+
if (token = this.tokenizer.table(src)) {
|
|
1584
|
+
src = src.substring(token.raw.length);
|
|
1585
|
+
tokens.push(token);
|
|
1586
|
+
continue;
|
|
1587
|
+
} // lheading
|
|
1588
|
+
|
|
1589
|
+
|
|
1590
|
+
if (token = this.tokenizer.lheading(src)) {
|
|
1591
|
+
src = src.substring(token.raw.length);
|
|
1592
|
+
tokens.push(token);
|
|
1593
|
+
continue;
|
|
1594
|
+
} // top-level paragraph
|
|
1595
|
+
// prevent paragraph consuming extensions by clipping 'src' to extension start
|
|
1596
|
+
|
|
1597
|
+
|
|
1598
|
+
cutSrc = src;
|
|
1599
|
+
|
|
1600
|
+
if (this.options.extensions && this.options.extensions.startBlock) {
|
|
1601
|
+
(function () {
|
|
1602
|
+
var startIndex = Infinity;
|
|
1603
|
+
var tempSrc = src.slice(1);
|
|
1604
|
+
var tempStart = void 0;
|
|
1605
|
+
|
|
1606
|
+
_this.options.extensions.startBlock.forEach(function (getStartIndex) {
|
|
1607
|
+
tempStart = getStartIndex.call({
|
|
1608
|
+
lexer: this
|
|
1609
|
+
}, tempSrc);
|
|
1610
|
+
|
|
1611
|
+
if (typeof tempStart === 'number' && tempStart >= 0) {
|
|
1612
|
+
startIndex = Math.min(startIndex, tempStart);
|
|
1613
|
+
}
|
|
1614
|
+
});
|
|
1615
|
+
|
|
1616
|
+
if (startIndex < Infinity && startIndex >= 0) {
|
|
1617
|
+
cutSrc = src.substring(0, startIndex + 1);
|
|
1618
|
+
}
|
|
1619
|
+
})();
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
|
|
1623
|
+
lastToken = tokens[tokens.length - 1];
|
|
1624
|
+
|
|
1625
|
+
if (lastParagraphClipped && lastToken.type === 'paragraph') {
|
|
1626
|
+
lastToken.raw += '\n' + token.raw;
|
|
1627
|
+
lastToken.text += '\n' + token.text;
|
|
1628
|
+
this.inlineQueue.pop();
|
|
1629
|
+
this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
|
|
1630
|
+
} else {
|
|
1631
|
+
tokens.push(token);
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
lastParagraphClipped = cutSrc.length !== src.length;
|
|
1635
|
+
src = src.substring(token.raw.length);
|
|
1636
|
+
continue;
|
|
1637
|
+
} // text
|
|
1638
|
+
|
|
1639
|
+
|
|
1640
|
+
if (token = this.tokenizer.text(src)) {
|
|
1641
|
+
src = src.substring(token.raw.length);
|
|
1642
|
+
lastToken = tokens[tokens.length - 1];
|
|
1643
|
+
|
|
1644
|
+
if (lastToken && lastToken.type === 'text') {
|
|
1645
|
+
lastToken.raw += '\n' + token.raw;
|
|
1646
|
+
lastToken.text += '\n' + token.text;
|
|
1647
|
+
this.inlineQueue.pop();
|
|
1648
|
+
this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
|
|
1649
|
+
} else {
|
|
1650
|
+
tokens.push(token);
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1653
|
+
continue;
|
|
1654
|
+
}
|
|
1655
|
+
|
|
1656
|
+
if (src) {
|
|
1657
|
+
var errMsg = 'Infinite loop on byte: ' + src.charCodeAt(0);
|
|
1658
|
+
|
|
1659
|
+
if (this.options.silent) {
|
|
1660
|
+
console.error(errMsg);
|
|
1661
|
+
break;
|
|
1662
|
+
} else {
|
|
1663
|
+
throw new Error(errMsg);
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1668
|
+
this.state.top = true;
|
|
1669
|
+
return tokens;
|
|
1670
|
+
};
|
|
1671
|
+
|
|
1672
|
+
_proto.inline = function inline(src, tokens) {
|
|
1673
|
+
this.inlineQueue.push({
|
|
1674
|
+
src: src,
|
|
1675
|
+
tokens: tokens
|
|
1676
|
+
});
|
|
1677
|
+
}
|
|
1678
|
+
/**
|
|
1679
|
+
* Lexing/Compiling
|
|
1680
|
+
*/
|
|
1681
|
+
;
|
|
1682
|
+
|
|
1683
|
+
_proto.inlineTokens = function inlineTokens(src, tokens) {
|
|
1684
|
+
var _this2 = this;
|
|
1685
|
+
|
|
1686
|
+
if (tokens === void 0) {
|
|
1687
|
+
tokens = [];
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1690
|
+
var token, lastToken, cutSrc; // String with links masked to avoid interference with em and strong
|
|
1691
|
+
|
|
1692
|
+
var maskedSrc = src;
|
|
1693
|
+
var match;
|
|
1694
|
+
var keepPrevChar, prevChar; // Mask out reflinks
|
|
1695
|
+
|
|
1696
|
+
if (this.tokens.links) {
|
|
1697
|
+
var links = Object.keys(this.tokens.links);
|
|
1698
|
+
|
|
1699
|
+
if (links.length > 0) {
|
|
1700
|
+
while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
|
|
1701
|
+
if (links.includes(match[0].slice(match[0].lastIndexOf('[') + 1, -1))) {
|
|
1702
|
+
maskedSrc = maskedSrc.slice(0, match.index) + '[' + repeatString('a', match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
} // Mask out other blocks
|
|
1707
|
+
|
|
1708
|
+
|
|
1709
|
+
while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
|
|
1710
|
+
maskedSrc = maskedSrc.slice(0, match.index) + '[' + repeatString('a', match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
|
|
1711
|
+
} // Mask out escaped em & strong delimiters
|
|
1712
|
+
|
|
1713
|
+
|
|
1714
|
+
while ((match = this.tokenizer.rules.inline.escapedEmSt.exec(maskedSrc)) != null) {
|
|
1715
|
+
maskedSrc = maskedSrc.slice(0, match.index) + '++' + maskedSrc.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex);
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
while (src) {
|
|
1719
|
+
if (!keepPrevChar) {
|
|
1720
|
+
prevChar = '';
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
keepPrevChar = false; // extensions
|
|
1724
|
+
|
|
1725
|
+
if (this.options.extensions && this.options.extensions.inline && this.options.extensions.inline.some(function (extTokenizer) {
|
|
1726
|
+
if (token = extTokenizer.call({
|
|
1727
|
+
lexer: _this2
|
|
1728
|
+
}, src, tokens)) {
|
|
1729
|
+
src = src.substring(token.raw.length);
|
|
1730
|
+
tokens.push(token);
|
|
1731
|
+
return true;
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1734
|
+
return false;
|
|
1735
|
+
})) {
|
|
1736
|
+
continue;
|
|
1737
|
+
} // escape
|
|
1738
|
+
|
|
1739
|
+
|
|
1740
|
+
if (token = this.tokenizer.escape(src)) {
|
|
1741
|
+
src = src.substring(token.raw.length);
|
|
1742
|
+
tokens.push(token);
|
|
1743
|
+
continue;
|
|
1744
|
+
} // tag
|
|
1745
|
+
|
|
1746
|
+
|
|
1747
|
+
if (token = this.tokenizer.tag(src)) {
|
|
1748
|
+
src = src.substring(token.raw.length);
|
|
1749
|
+
lastToken = tokens[tokens.length - 1];
|
|
1750
|
+
|
|
1751
|
+
if (lastToken && token.type === 'text' && lastToken.type === 'text') {
|
|
1752
|
+
lastToken.raw += token.raw;
|
|
1753
|
+
lastToken.text += token.text;
|
|
1754
|
+
} else {
|
|
1755
|
+
tokens.push(token);
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1758
|
+
continue;
|
|
1759
|
+
} // link
|
|
1760
|
+
|
|
1761
|
+
|
|
1762
|
+
if (token = this.tokenizer.link(src)) {
|
|
1763
|
+
src = src.substring(token.raw.length);
|
|
1764
|
+
tokens.push(token);
|
|
1765
|
+
continue;
|
|
1766
|
+
} // reflink, nolink
|
|
1767
|
+
|
|
1768
|
+
|
|
1769
|
+
if (token = this.tokenizer.reflink(src, this.tokens.links)) {
|
|
1770
|
+
src = src.substring(token.raw.length);
|
|
1771
|
+
lastToken = tokens[tokens.length - 1];
|
|
1772
|
+
|
|
1773
|
+
if (lastToken && token.type === 'text' && lastToken.type === 'text') {
|
|
1774
|
+
lastToken.raw += token.raw;
|
|
1775
|
+
lastToken.text += token.text;
|
|
1776
|
+
} else {
|
|
1777
|
+
tokens.push(token);
|
|
1778
|
+
}
|
|
1779
|
+
|
|
1780
|
+
continue;
|
|
1781
|
+
} // em & strong
|
|
1782
|
+
|
|
1783
|
+
|
|
1784
|
+
if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) {
|
|
1785
|
+
src = src.substring(token.raw.length);
|
|
1786
|
+
tokens.push(token);
|
|
1787
|
+
continue;
|
|
1788
|
+
} // code
|
|
1789
|
+
|
|
1790
|
+
|
|
1791
|
+
if (token = this.tokenizer.codespan(src)) {
|
|
1792
|
+
src = src.substring(token.raw.length);
|
|
1793
|
+
tokens.push(token);
|
|
1794
|
+
continue;
|
|
1795
|
+
} // br
|
|
1796
|
+
|
|
1797
|
+
|
|
1798
|
+
if (token = this.tokenizer.br(src)) {
|
|
1799
|
+
src = src.substring(token.raw.length);
|
|
1800
|
+
tokens.push(token);
|
|
1801
|
+
continue;
|
|
1802
|
+
} // del (gfm)
|
|
1803
|
+
|
|
1804
|
+
|
|
1805
|
+
if (token = this.tokenizer.del(src)) {
|
|
1806
|
+
src = src.substring(token.raw.length);
|
|
1807
|
+
tokens.push(token);
|
|
1808
|
+
continue;
|
|
1809
|
+
} // autolink
|
|
1810
|
+
|
|
1811
|
+
|
|
1812
|
+
if (token = this.tokenizer.autolink(src, mangle)) {
|
|
1813
|
+
src = src.substring(token.raw.length);
|
|
1814
|
+
tokens.push(token);
|
|
1815
|
+
continue;
|
|
1816
|
+
} // url (gfm)
|
|
1817
|
+
|
|
1818
|
+
|
|
1819
|
+
if (!this.state.inLink && (token = this.tokenizer.url(src, mangle))) {
|
|
1820
|
+
src = src.substring(token.raw.length);
|
|
1821
|
+
tokens.push(token);
|
|
1822
|
+
continue;
|
|
1823
|
+
} // text
|
|
1824
|
+
// prevent inlineText consuming extensions by clipping 'src' to extension start
|
|
1825
|
+
|
|
1826
|
+
|
|
1827
|
+
cutSrc = src;
|
|
1828
|
+
|
|
1829
|
+
if (this.options.extensions && this.options.extensions.startInline) {
|
|
1830
|
+
(function () {
|
|
1831
|
+
var startIndex = Infinity;
|
|
1832
|
+
var tempSrc = src.slice(1);
|
|
1833
|
+
var tempStart = void 0;
|
|
1834
|
+
|
|
1835
|
+
_this2.options.extensions.startInline.forEach(function (getStartIndex) {
|
|
1836
|
+
tempStart = getStartIndex.call({
|
|
1837
|
+
lexer: this
|
|
1838
|
+
}, tempSrc);
|
|
1839
|
+
|
|
1840
|
+
if (typeof tempStart === 'number' && tempStart >= 0) {
|
|
1841
|
+
startIndex = Math.min(startIndex, tempStart);
|
|
1842
|
+
}
|
|
1843
|
+
});
|
|
1844
|
+
|
|
1845
|
+
if (startIndex < Infinity && startIndex >= 0) {
|
|
1846
|
+
cutSrc = src.substring(0, startIndex + 1);
|
|
1847
|
+
}
|
|
1848
|
+
})();
|
|
1849
|
+
}
|
|
1850
|
+
|
|
1851
|
+
if (token = this.tokenizer.inlineText(cutSrc, smartypants)) {
|
|
1852
|
+
src = src.substring(token.raw.length);
|
|
1853
|
+
|
|
1854
|
+
if (token.raw.slice(-1) !== '_') {
|
|
1855
|
+
// Track prevChar before string of ____ started
|
|
1856
|
+
prevChar = token.raw.slice(-1);
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
keepPrevChar = true;
|
|
1860
|
+
lastToken = tokens[tokens.length - 1];
|
|
1861
|
+
|
|
1862
|
+
if (lastToken && lastToken.type === 'text') {
|
|
1863
|
+
lastToken.raw += token.raw;
|
|
1864
|
+
lastToken.text += token.text;
|
|
1865
|
+
} else {
|
|
1866
|
+
tokens.push(token);
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
continue;
|
|
1870
|
+
}
|
|
1871
|
+
|
|
1872
|
+
if (src) {
|
|
1873
|
+
var errMsg = 'Infinite loop on byte: ' + src.charCodeAt(0);
|
|
1874
|
+
|
|
1875
|
+
if (this.options.silent) {
|
|
1876
|
+
console.error(errMsg);
|
|
1877
|
+
break;
|
|
1878
|
+
} else {
|
|
1879
|
+
throw new Error(errMsg);
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
|
|
1884
|
+
return tokens;
|
|
1885
|
+
};
|
|
1886
|
+
|
|
1887
|
+
_createClass(Lexer, null, [{
|
|
1888
|
+
key: "rules",
|
|
1889
|
+
get: function get() {
|
|
1890
|
+
return {
|
|
1891
|
+
block: block,
|
|
1892
|
+
inline: inline
|
|
1893
|
+
};
|
|
1894
|
+
}
|
|
1895
|
+
}]);
|
|
1896
|
+
|
|
1897
|
+
return Lexer;
|
|
1898
|
+
}();
|
|
1899
|
+
|
|
1900
|
+
/**
|
|
1901
|
+
* Renderer
|
|
1902
|
+
*/
|
|
1903
|
+
|
|
1904
|
+
var Renderer = /*#__PURE__*/function () {
|
|
1905
|
+
function Renderer(options) {
|
|
1906
|
+
this.options = options || exports.defaults;
|
|
1907
|
+
}
|
|
1908
|
+
|
|
1909
|
+
var _proto = Renderer.prototype;
|
|
1910
|
+
|
|
1911
|
+
_proto.code = function code(_code, infostring, escaped) {
|
|
1912
|
+
var lang = (infostring || '').match(/\S*/)[0];
|
|
1913
|
+
|
|
1914
|
+
if (this.options.highlight) {
|
|
1915
|
+
var out = this.options.highlight(_code, lang);
|
|
1916
|
+
|
|
1917
|
+
if (out != null && out !== _code) {
|
|
1918
|
+
escaped = true;
|
|
1919
|
+
_code = out;
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
|
|
1923
|
+
_code = _code.replace(/\n$/, '') + '\n';
|
|
1924
|
+
|
|
1925
|
+
if (!lang) {
|
|
1926
|
+
return '<pre><code>' + (escaped ? _code : escape(_code, true)) + '</code></pre>\n';
|
|
1927
|
+
}
|
|
1928
|
+
|
|
1929
|
+
return '<pre><code class="' + this.options.langPrefix + escape(lang, true) + '">' + (escaped ? _code : escape(_code, true)) + '</code></pre>\n';
|
|
1930
|
+
};
|
|
1931
|
+
|
|
1932
|
+
_proto.blockquote = function blockquote(quote) {
|
|
1933
|
+
return '<blockquote>\n' + quote + '</blockquote>\n';
|
|
1934
|
+
};
|
|
1935
|
+
|
|
1936
|
+
_proto.html = function html(_html) {
|
|
1937
|
+
return _html;
|
|
1938
|
+
};
|
|
1939
|
+
|
|
1940
|
+
_proto.heading = function heading(text, level, raw, slugger) {
|
|
1941
|
+
if (this.options.headerIds) {
|
|
1942
|
+
return '<h' + level + ' id="' + this.options.headerPrefix + slugger.slug(raw) + '">' + text + '</h' + level + '>\n';
|
|
1943
|
+
} // ignore IDs
|
|
1944
|
+
|
|
1945
|
+
|
|
1946
|
+
return '<h' + level + '>' + text + '</h' + level + '>\n';
|
|
1947
|
+
};
|
|
1948
|
+
|
|
1949
|
+
_proto.hr = function hr() {
|
|
1950
|
+
return this.options.xhtml ? '<hr/>\n' : '<hr>\n';
|
|
1951
|
+
};
|
|
1952
|
+
|
|
1953
|
+
_proto.list = function list(body, ordered, start) {
|
|
1954
|
+
var type = ordered ? 'ol' : 'ul',
|
|
1955
|
+
startatt = ordered && start !== 1 ? ' start="' + start + '"' : '';
|
|
1956
|
+
return '<' + type + startatt + '>\n' + body + '</' + type + '>\n';
|
|
1957
|
+
};
|
|
1958
|
+
|
|
1959
|
+
_proto.listitem = function listitem(text) {
|
|
1960
|
+
return '<li>' + text + '</li>\n';
|
|
1961
|
+
};
|
|
1962
|
+
|
|
1963
|
+
_proto.checkbox = function checkbox(checked) {
|
|
1964
|
+
return '<input ' + (checked ? 'checked="" ' : '') + 'disabled="" type="checkbox"' + (this.options.xhtml ? ' /' : '') + '> ';
|
|
1965
|
+
};
|
|
1966
|
+
|
|
1967
|
+
_proto.paragraph = function paragraph(text) {
|
|
1968
|
+
return '<p>' + text + '</p>\n';
|
|
1969
|
+
};
|
|
1970
|
+
|
|
1971
|
+
_proto.table = function table(header, body) {
|
|
1972
|
+
if (body) body = '<tbody>' + body + '</tbody>';
|
|
1973
|
+
return '<table>\n' + '<thead>\n' + header + '</thead>\n' + body + '</table>\n';
|
|
1974
|
+
};
|
|
1975
|
+
|
|
1976
|
+
_proto.tablerow = function tablerow(content) {
|
|
1977
|
+
return '<tr>\n' + content + '</tr>\n';
|
|
1978
|
+
};
|
|
1979
|
+
|
|
1980
|
+
_proto.tablecell = function tablecell(content, flags) {
|
|
1981
|
+
var type = flags.header ? 'th' : 'td';
|
|
1982
|
+
var tag = flags.align ? '<' + type + ' align="' + flags.align + '">' : '<' + type + '>';
|
|
1983
|
+
return tag + content + '</' + type + '>\n';
|
|
1984
|
+
} // span level renderer
|
|
1985
|
+
;
|
|
1986
|
+
|
|
1987
|
+
_proto.strong = function strong(text) {
|
|
1988
|
+
return '<strong>' + text + '</strong>';
|
|
1989
|
+
};
|
|
1990
|
+
|
|
1991
|
+
_proto.em = function em(text) {
|
|
1992
|
+
return '<em>' + text + '</em>';
|
|
1993
|
+
};
|
|
1994
|
+
|
|
1995
|
+
_proto.codespan = function codespan(text) {
|
|
1996
|
+
return '<code>' + text + '</code>';
|
|
1997
|
+
};
|
|
1998
|
+
|
|
1999
|
+
_proto.br = function br() {
|
|
2000
|
+
return this.options.xhtml ? '<br/>' : '<br>';
|
|
2001
|
+
};
|
|
2002
|
+
|
|
2003
|
+
_proto.del = function del(text) {
|
|
2004
|
+
return '<del>' + text + '</del>';
|
|
2005
|
+
};
|
|
2006
|
+
|
|
2007
|
+
_proto.link = function link(href, title, text) {
|
|
2008
|
+
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
|
2009
|
+
|
|
2010
|
+
if (href === null) {
|
|
2011
|
+
return text;
|
|
2012
|
+
}
|
|
2013
|
+
|
|
2014
|
+
var out = '<a href="' + escape(href) + '"';
|
|
2015
|
+
|
|
2016
|
+
if (title) {
|
|
2017
|
+
out += ' title="' + title + '"';
|
|
2018
|
+
}
|
|
2019
|
+
|
|
2020
|
+
out += '>' + text + '</a>';
|
|
2021
|
+
return out;
|
|
2022
|
+
};
|
|
2023
|
+
|
|
2024
|
+
_proto.image = function image(href, title, text) {
|
|
2025
|
+
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
|
2026
|
+
|
|
2027
|
+
if (href === null) {
|
|
2028
|
+
return text;
|
|
2029
|
+
}
|
|
2030
|
+
|
|
2031
|
+
var out = '<img src="' + href + '" alt="' + text + '"';
|
|
2032
|
+
|
|
2033
|
+
if (title) {
|
|
2034
|
+
out += ' title="' + title + '"';
|
|
2035
|
+
}
|
|
2036
|
+
|
|
2037
|
+
out += this.options.xhtml ? '/>' : '>';
|
|
2038
|
+
return out;
|
|
2039
|
+
};
|
|
2040
|
+
|
|
2041
|
+
_proto.text = function text(_text) {
|
|
2042
|
+
return _text;
|
|
2043
|
+
};
|
|
2044
|
+
|
|
2045
|
+
return Renderer;
|
|
2046
|
+
}();
|
|
2047
|
+
|
|
2048
|
+
/**
|
|
2049
|
+
* TextRenderer
|
|
2050
|
+
* returns only the textual part of the token
|
|
2051
|
+
*/
|
|
2052
|
+
var TextRenderer = /*#__PURE__*/function () {
|
|
2053
|
+
function TextRenderer() {}
|
|
2054
|
+
|
|
2055
|
+
var _proto = TextRenderer.prototype;
|
|
2056
|
+
|
|
2057
|
+
// no need for block level renderers
|
|
2058
|
+
_proto.strong = function strong(text) {
|
|
2059
|
+
return text;
|
|
2060
|
+
};
|
|
2061
|
+
|
|
2062
|
+
_proto.em = function em(text) {
|
|
2063
|
+
return text;
|
|
2064
|
+
};
|
|
2065
|
+
|
|
2066
|
+
_proto.codespan = function codespan(text) {
|
|
2067
|
+
return text;
|
|
2068
|
+
};
|
|
2069
|
+
|
|
2070
|
+
_proto.del = function del(text) {
|
|
2071
|
+
return text;
|
|
2072
|
+
};
|
|
2073
|
+
|
|
2074
|
+
_proto.html = function html(text) {
|
|
2075
|
+
return text;
|
|
2076
|
+
};
|
|
2077
|
+
|
|
2078
|
+
_proto.text = function text(_text) {
|
|
2079
|
+
return _text;
|
|
2080
|
+
};
|
|
2081
|
+
|
|
2082
|
+
_proto.link = function link(href, title, text) {
|
|
2083
|
+
return '' + text;
|
|
2084
|
+
};
|
|
2085
|
+
|
|
2086
|
+
_proto.image = function image(href, title, text) {
|
|
2087
|
+
return '' + text;
|
|
2088
|
+
};
|
|
2089
|
+
|
|
2090
|
+
_proto.br = function br() {
|
|
2091
|
+
return '';
|
|
2092
|
+
};
|
|
2093
|
+
|
|
2094
|
+
return TextRenderer;
|
|
2095
|
+
}();
|
|
2096
|
+
|
|
2097
|
+
/**
|
|
2098
|
+
* Slugger generates header id
|
|
2099
|
+
*/
|
|
2100
|
+
var Slugger = /*#__PURE__*/function () {
|
|
2101
|
+
function Slugger() {
|
|
2102
|
+
this.seen = {};
|
|
2103
|
+
}
|
|
2104
|
+
|
|
2105
|
+
var _proto = Slugger.prototype;
|
|
2106
|
+
|
|
2107
|
+
_proto.serialize = function serialize(value) {
|
|
2108
|
+
return value.toLowerCase().trim() // remove html tags
|
|
2109
|
+
.replace(/<[!\/a-z].*?>/ig, '') // remove unwanted chars
|
|
2110
|
+
.replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, '').replace(/\s/g, '-');
|
|
2111
|
+
}
|
|
2112
|
+
/**
|
|
2113
|
+
* Finds the next safe (unique) slug to use
|
|
2114
|
+
*/
|
|
2115
|
+
;
|
|
2116
|
+
|
|
2117
|
+
_proto.getNextSafeSlug = function getNextSafeSlug(originalSlug, isDryRun) {
|
|
2118
|
+
var slug = originalSlug;
|
|
2119
|
+
var occurenceAccumulator = 0;
|
|
2120
|
+
|
|
2121
|
+
if (this.seen.hasOwnProperty(slug)) {
|
|
2122
|
+
occurenceAccumulator = this.seen[originalSlug];
|
|
2123
|
+
|
|
2124
|
+
do {
|
|
2125
|
+
occurenceAccumulator++;
|
|
2126
|
+
slug = originalSlug + '-' + occurenceAccumulator;
|
|
2127
|
+
} while (this.seen.hasOwnProperty(slug));
|
|
2128
|
+
}
|
|
2129
|
+
|
|
2130
|
+
if (!isDryRun) {
|
|
2131
|
+
this.seen[originalSlug] = occurenceAccumulator;
|
|
2132
|
+
this.seen[slug] = 0;
|
|
2133
|
+
}
|
|
2134
|
+
|
|
2135
|
+
return slug;
|
|
2136
|
+
}
|
|
2137
|
+
/**
|
|
2138
|
+
* Convert string to unique id
|
|
2139
|
+
* @param {object} options
|
|
2140
|
+
* @param {boolean} options.dryrun Generates the next unique slug without updating the internal accumulator.
|
|
2141
|
+
*/
|
|
2142
|
+
;
|
|
2143
|
+
|
|
2144
|
+
_proto.slug = function slug(value, options) {
|
|
2145
|
+
if (options === void 0) {
|
|
2146
|
+
options = {};
|
|
2147
|
+
}
|
|
2148
|
+
|
|
2149
|
+
var slug = this.serialize(value);
|
|
2150
|
+
return this.getNextSafeSlug(slug, options.dryrun);
|
|
2151
|
+
};
|
|
2152
|
+
|
|
2153
|
+
return Slugger;
|
|
2154
|
+
}();
|
|
2155
|
+
|
|
2156
|
+
/**
|
|
2157
|
+
* Parsing & Compiling
|
|
2158
|
+
*/
|
|
2159
|
+
|
|
2160
|
+
var Parser = /*#__PURE__*/function () {
|
|
2161
|
+
function Parser(options) {
|
|
2162
|
+
this.options = options || exports.defaults;
|
|
2163
|
+
this.options.renderer = this.options.renderer || new Renderer();
|
|
2164
|
+
this.renderer = this.options.renderer;
|
|
2165
|
+
this.renderer.options = this.options;
|
|
2166
|
+
this.textRenderer = new TextRenderer();
|
|
2167
|
+
this.slugger = new Slugger();
|
|
2168
|
+
}
|
|
2169
|
+
/**
|
|
2170
|
+
* Static Parse Method
|
|
2171
|
+
*/
|
|
2172
|
+
|
|
2173
|
+
|
|
2174
|
+
Parser.parse = function parse(tokens, options) {
|
|
2175
|
+
var parser = new Parser(options);
|
|
2176
|
+
return parser.parse(tokens);
|
|
2177
|
+
}
|
|
2178
|
+
/**
|
|
2179
|
+
* Static Parse Inline Method
|
|
2180
|
+
*/
|
|
2181
|
+
;
|
|
2182
|
+
|
|
2183
|
+
Parser.parseInline = function parseInline(tokens, options) {
|
|
2184
|
+
var parser = new Parser(options);
|
|
2185
|
+
return parser.parseInline(tokens);
|
|
2186
|
+
}
|
|
2187
|
+
/**
|
|
2188
|
+
* Parse Loop
|
|
2189
|
+
*/
|
|
2190
|
+
;
|
|
2191
|
+
|
|
2192
|
+
var _proto = Parser.prototype;
|
|
2193
|
+
|
|
2194
|
+
_proto.parse = function parse(tokens, top) {
|
|
2195
|
+
if (top === void 0) {
|
|
2196
|
+
top = true;
|
|
2197
|
+
}
|
|
2198
|
+
|
|
2199
|
+
var out = '',
|
|
2200
|
+
i,
|
|
2201
|
+
j,
|
|
2202
|
+
k,
|
|
2203
|
+
l2,
|
|
2204
|
+
l3,
|
|
2205
|
+
row,
|
|
2206
|
+
cell,
|
|
2207
|
+
header,
|
|
2208
|
+
body,
|
|
2209
|
+
token,
|
|
2210
|
+
ordered,
|
|
2211
|
+
start,
|
|
2212
|
+
loose,
|
|
2213
|
+
itemBody,
|
|
2214
|
+
item,
|
|
2215
|
+
checked,
|
|
2216
|
+
task,
|
|
2217
|
+
checkbox,
|
|
2218
|
+
ret;
|
|
2219
|
+
var l = tokens.length;
|
|
2220
|
+
|
|
2221
|
+
for (i = 0; i < l; i++) {
|
|
2222
|
+
token = tokens[i]; // Run any renderer extensions
|
|
2223
|
+
|
|
2224
|
+
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
|
|
2225
|
+
ret = this.options.extensions.renderers[token.type].call({
|
|
2226
|
+
parser: this
|
|
2227
|
+
}, token);
|
|
2228
|
+
|
|
2229
|
+
if (ret !== false || !['space', 'hr', 'heading', 'code', 'table', 'blockquote', 'list', 'html', 'paragraph', 'text'].includes(token.type)) {
|
|
2230
|
+
out += ret || '';
|
|
2231
|
+
continue;
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
|
|
2235
|
+
switch (token.type) {
|
|
2236
|
+
case 'space':
|
|
2237
|
+
{
|
|
2238
|
+
continue;
|
|
2239
|
+
}
|
|
2240
|
+
|
|
2241
|
+
case 'hr':
|
|
2242
|
+
{
|
|
2243
|
+
out += this.renderer.hr();
|
|
2244
|
+
continue;
|
|
2245
|
+
}
|
|
2246
|
+
|
|
2247
|
+
case 'heading':
|
|
2248
|
+
{
|
|
2249
|
+
out += this.renderer.heading(this.parseInline(token.tokens), token.depth, unescape(this.parseInline(token.tokens, this.textRenderer)), this.slugger);
|
|
2250
|
+
continue;
|
|
2251
|
+
}
|
|
2252
|
+
|
|
2253
|
+
case 'code':
|
|
2254
|
+
{
|
|
2255
|
+
out += this.renderer.code(token.text, token.lang, token.escaped);
|
|
2256
|
+
continue;
|
|
2257
|
+
}
|
|
2258
|
+
|
|
2259
|
+
case 'table':
|
|
2260
|
+
{
|
|
2261
|
+
header = ''; // header
|
|
2262
|
+
|
|
2263
|
+
cell = '';
|
|
2264
|
+
l2 = token.header.length;
|
|
2265
|
+
|
|
2266
|
+
for (j = 0; j < l2; j++) {
|
|
2267
|
+
cell += this.renderer.tablecell(this.parseInline(token.header[j].tokens), {
|
|
2268
|
+
header: true,
|
|
2269
|
+
align: token.align[j]
|
|
2270
|
+
});
|
|
2271
|
+
}
|
|
2272
|
+
|
|
2273
|
+
header += this.renderer.tablerow(cell);
|
|
2274
|
+
body = '';
|
|
2275
|
+
l2 = token.rows.length;
|
|
2276
|
+
|
|
2277
|
+
for (j = 0; j < l2; j++) {
|
|
2278
|
+
row = token.rows[j];
|
|
2279
|
+
cell = '';
|
|
2280
|
+
l3 = row.length;
|
|
2281
|
+
|
|
2282
|
+
for (k = 0; k < l3; k++) {
|
|
2283
|
+
cell += this.renderer.tablecell(this.parseInline(row[k].tokens), {
|
|
2284
|
+
header: false,
|
|
2285
|
+
align: token.align[k]
|
|
2286
|
+
});
|
|
2287
|
+
}
|
|
2288
|
+
|
|
2289
|
+
body += this.renderer.tablerow(cell);
|
|
2290
|
+
}
|
|
2291
|
+
|
|
2292
|
+
out += this.renderer.table(header, body);
|
|
2293
|
+
continue;
|
|
2294
|
+
}
|
|
2295
|
+
|
|
2296
|
+
case 'blockquote':
|
|
2297
|
+
{
|
|
2298
|
+
body = this.parse(token.tokens);
|
|
2299
|
+
out += this.renderer.blockquote(body);
|
|
2300
|
+
continue;
|
|
2301
|
+
}
|
|
2302
|
+
|
|
2303
|
+
case 'list':
|
|
2304
|
+
{
|
|
2305
|
+
ordered = token.ordered;
|
|
2306
|
+
start = token.start;
|
|
2307
|
+
loose = token.loose;
|
|
2308
|
+
l2 = token.items.length;
|
|
2309
|
+
body = '';
|
|
2310
|
+
|
|
2311
|
+
for (j = 0; j < l2; j++) {
|
|
2312
|
+
item = token.items[j];
|
|
2313
|
+
checked = item.checked;
|
|
2314
|
+
task = item.task;
|
|
2315
|
+
itemBody = '';
|
|
2316
|
+
|
|
2317
|
+
if (item.task) {
|
|
2318
|
+
checkbox = this.renderer.checkbox(checked);
|
|
2319
|
+
|
|
2320
|
+
if (loose) {
|
|
2321
|
+
if (item.tokens.length > 0 && item.tokens[0].type === 'paragraph') {
|
|
2322
|
+
item.tokens[0].text = checkbox + ' ' + item.tokens[0].text;
|
|
2323
|
+
|
|
2324
|
+
if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === 'text') {
|
|
2325
|
+
item.tokens[0].tokens[0].text = checkbox + ' ' + item.tokens[0].tokens[0].text;
|
|
2326
|
+
}
|
|
2327
|
+
} else {
|
|
2328
|
+
item.tokens.unshift({
|
|
2329
|
+
type: 'text',
|
|
2330
|
+
text: checkbox
|
|
2331
|
+
});
|
|
2332
|
+
}
|
|
2333
|
+
} else {
|
|
2334
|
+
itemBody += checkbox;
|
|
2335
|
+
}
|
|
2336
|
+
}
|
|
2337
|
+
|
|
2338
|
+
itemBody += this.parse(item.tokens, loose);
|
|
2339
|
+
body += this.renderer.listitem(itemBody, task, checked);
|
|
2340
|
+
}
|
|
2341
|
+
|
|
2342
|
+
out += this.renderer.list(body, ordered, start);
|
|
2343
|
+
continue;
|
|
2344
|
+
}
|
|
2345
|
+
|
|
2346
|
+
case 'html':
|
|
2347
|
+
{
|
|
2348
|
+
// TODO parse inline content if parameter markdown=1
|
|
2349
|
+
out += this.renderer.html(token.text);
|
|
2350
|
+
continue;
|
|
2351
|
+
}
|
|
2352
|
+
|
|
2353
|
+
case 'paragraph':
|
|
2354
|
+
{
|
|
2355
|
+
out += this.renderer.paragraph(this.parseInline(token.tokens));
|
|
2356
|
+
continue;
|
|
2357
|
+
}
|
|
2358
|
+
|
|
2359
|
+
case 'text':
|
|
2360
|
+
{
|
|
2361
|
+
body = token.tokens ? this.parseInline(token.tokens) : token.text;
|
|
2362
|
+
|
|
2363
|
+
while (i + 1 < l && tokens[i + 1].type === 'text') {
|
|
2364
|
+
token = tokens[++i];
|
|
2365
|
+
body += '\n' + (token.tokens ? this.parseInline(token.tokens) : token.text);
|
|
2366
|
+
}
|
|
2367
|
+
|
|
2368
|
+
out += top ? this.renderer.paragraph(body) : body;
|
|
2369
|
+
continue;
|
|
2370
|
+
}
|
|
2371
|
+
|
|
2372
|
+
default:
|
|
2373
|
+
{
|
|
2374
|
+
var errMsg = 'Token with "' + token.type + '" type was not found.';
|
|
2375
|
+
|
|
2376
|
+
if (this.options.silent) {
|
|
2377
|
+
console.error(errMsg);
|
|
2378
|
+
return;
|
|
2379
|
+
} else {
|
|
2380
|
+
throw new Error(errMsg);
|
|
2381
|
+
}
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2384
|
+
}
|
|
2385
|
+
|
|
2386
|
+
return out;
|
|
2387
|
+
}
|
|
2388
|
+
/**
|
|
2389
|
+
* Parse Inline Tokens
|
|
2390
|
+
*/
|
|
2391
|
+
;
|
|
2392
|
+
|
|
2393
|
+
_proto.parseInline = function parseInline(tokens, renderer) {
|
|
2394
|
+
renderer = renderer || this.renderer;
|
|
2395
|
+
var out = '',
|
|
2396
|
+
i,
|
|
2397
|
+
token,
|
|
2398
|
+
ret;
|
|
2399
|
+
var l = tokens.length;
|
|
2400
|
+
|
|
2401
|
+
for (i = 0; i < l; i++) {
|
|
2402
|
+
token = tokens[i]; // Run any renderer extensions
|
|
2403
|
+
|
|
2404
|
+
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
|
|
2405
|
+
ret = this.options.extensions.renderers[token.type].call({
|
|
2406
|
+
parser: this
|
|
2407
|
+
}, token);
|
|
2408
|
+
|
|
2409
|
+
if (ret !== false || !['escape', 'html', 'link', 'image', 'strong', 'em', 'codespan', 'br', 'del', 'text'].includes(token.type)) {
|
|
2410
|
+
out += ret || '';
|
|
2411
|
+
continue;
|
|
2412
|
+
}
|
|
2413
|
+
}
|
|
2414
|
+
|
|
2415
|
+
switch (token.type) {
|
|
2416
|
+
case 'escape':
|
|
2417
|
+
{
|
|
2418
|
+
out += renderer.text(token.text);
|
|
2419
|
+
break;
|
|
2420
|
+
}
|
|
2421
|
+
|
|
2422
|
+
case 'html':
|
|
2423
|
+
{
|
|
2424
|
+
out += renderer.html(token.text);
|
|
2425
|
+
break;
|
|
2426
|
+
}
|
|
2427
|
+
|
|
2428
|
+
case 'link':
|
|
2429
|
+
{
|
|
2430
|
+
out += renderer.link(token.href, token.title, this.parseInline(token.tokens, renderer));
|
|
2431
|
+
break;
|
|
2432
|
+
}
|
|
2433
|
+
|
|
2434
|
+
case 'image':
|
|
2435
|
+
{
|
|
2436
|
+
out += renderer.image(token.href, token.title, token.text);
|
|
2437
|
+
break;
|
|
2438
|
+
}
|
|
2439
|
+
|
|
2440
|
+
case 'strong':
|
|
2441
|
+
{
|
|
2442
|
+
out += renderer.strong(this.parseInline(token.tokens, renderer));
|
|
2443
|
+
break;
|
|
2444
|
+
}
|
|
2445
|
+
|
|
2446
|
+
case 'em':
|
|
2447
|
+
{
|
|
2448
|
+
out += renderer.em(this.parseInline(token.tokens, renderer));
|
|
2449
|
+
break;
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2452
|
+
case 'codespan':
|
|
2453
|
+
{
|
|
2454
|
+
out += renderer.codespan(token.text);
|
|
2455
|
+
break;
|
|
2456
|
+
}
|
|
2457
|
+
|
|
2458
|
+
case 'br':
|
|
2459
|
+
{
|
|
2460
|
+
out += renderer.br();
|
|
2461
|
+
break;
|
|
2462
|
+
}
|
|
2463
|
+
|
|
2464
|
+
case 'del':
|
|
2465
|
+
{
|
|
2466
|
+
out += renderer.del(this.parseInline(token.tokens, renderer));
|
|
2467
|
+
break;
|
|
2468
|
+
}
|
|
2469
|
+
|
|
2470
|
+
case 'text':
|
|
2471
|
+
{
|
|
2472
|
+
out += renderer.text(token.text);
|
|
2473
|
+
break;
|
|
2474
|
+
}
|
|
2475
|
+
|
|
2476
|
+
default:
|
|
2477
|
+
{
|
|
2478
|
+
var errMsg = 'Token with "' + token.type + '" type was not found.';
|
|
2479
|
+
|
|
2480
|
+
if (this.options.silent) {
|
|
2481
|
+
console.error(errMsg);
|
|
2482
|
+
return;
|
|
2483
|
+
} else {
|
|
2484
|
+
throw new Error(errMsg);
|
|
2485
|
+
}
|
|
2486
|
+
}
|
|
2487
|
+
}
|
|
2488
|
+
}
|
|
2489
|
+
|
|
2490
|
+
return out;
|
|
2491
|
+
};
|
|
2492
|
+
|
|
2493
|
+
return Parser;
|
|
2494
|
+
}();
|
|
2495
|
+
|
|
2496
|
+
/**
|
|
2497
|
+
* Marked
|
|
2498
|
+
*/
|
|
2499
|
+
|
|
2500
|
+
function marked(src, opt, callback) {
|
|
2501
|
+
// throw error in case of non string input
|
|
2502
|
+
if (typeof src === 'undefined' || src === null) {
|
|
2503
|
+
throw new Error('marked(): input parameter is undefined or null');
|
|
2504
|
+
}
|
|
2505
|
+
|
|
2506
|
+
if (typeof src !== 'string') {
|
|
2507
|
+
throw new Error('marked(): input parameter is of type ' + Object.prototype.toString.call(src) + ', string expected');
|
|
2508
|
+
}
|
|
2509
|
+
|
|
2510
|
+
if (typeof opt === 'function') {
|
|
2511
|
+
callback = opt;
|
|
2512
|
+
opt = null;
|
|
2513
|
+
}
|
|
2514
|
+
|
|
2515
|
+
opt = merge({}, marked.defaults, opt || {});
|
|
2516
|
+
checkSanitizeDeprecation(opt);
|
|
2517
|
+
|
|
2518
|
+
if (callback) {
|
|
2519
|
+
var highlight = opt.highlight;
|
|
2520
|
+
var tokens;
|
|
2521
|
+
|
|
2522
|
+
try {
|
|
2523
|
+
tokens = Lexer.lex(src, opt);
|
|
2524
|
+
} catch (e) {
|
|
2525
|
+
return callback(e);
|
|
2526
|
+
}
|
|
2527
|
+
|
|
2528
|
+
var done = function done(err) {
|
|
2529
|
+
var out;
|
|
2530
|
+
|
|
2531
|
+
if (!err) {
|
|
2532
|
+
try {
|
|
2533
|
+
if (opt.walkTokens) {
|
|
2534
|
+
marked.walkTokens(tokens, opt.walkTokens);
|
|
2535
|
+
}
|
|
2536
|
+
|
|
2537
|
+
out = Parser.parse(tokens, opt);
|
|
2538
|
+
} catch (e) {
|
|
2539
|
+
err = e;
|
|
2540
|
+
}
|
|
2541
|
+
}
|
|
2542
|
+
|
|
2543
|
+
opt.highlight = highlight;
|
|
2544
|
+
return err ? callback(err) : callback(null, out);
|
|
2545
|
+
};
|
|
2546
|
+
|
|
2547
|
+
if (!highlight || highlight.length < 3) {
|
|
2548
|
+
return done();
|
|
2549
|
+
}
|
|
2550
|
+
|
|
2551
|
+
delete opt.highlight;
|
|
2552
|
+
if (!tokens.length) return done();
|
|
2553
|
+
var pending = 0;
|
|
2554
|
+
marked.walkTokens(tokens, function (token) {
|
|
2555
|
+
if (token.type === 'code') {
|
|
2556
|
+
pending++;
|
|
2557
|
+
setTimeout(function () {
|
|
2558
|
+
highlight(token.text, token.lang, function (err, code) {
|
|
2559
|
+
if (err) {
|
|
2560
|
+
return done(err);
|
|
2561
|
+
}
|
|
2562
|
+
|
|
2563
|
+
if (code != null && code !== token.text) {
|
|
2564
|
+
token.text = code;
|
|
2565
|
+
token.escaped = true;
|
|
2566
|
+
}
|
|
2567
|
+
|
|
2568
|
+
pending--;
|
|
2569
|
+
|
|
2570
|
+
if (pending === 0) {
|
|
2571
|
+
done();
|
|
2572
|
+
}
|
|
2573
|
+
});
|
|
2574
|
+
}, 0);
|
|
2575
|
+
}
|
|
2576
|
+
});
|
|
2577
|
+
|
|
2578
|
+
if (pending === 0) {
|
|
2579
|
+
done();
|
|
2580
|
+
}
|
|
2581
|
+
|
|
2582
|
+
return;
|
|
2583
|
+
}
|
|
2584
|
+
|
|
2585
|
+
try {
|
|
2586
|
+
var _tokens = Lexer.lex(src, opt);
|
|
2587
|
+
|
|
2588
|
+
if (opt.walkTokens) {
|
|
2589
|
+
marked.walkTokens(_tokens, opt.walkTokens);
|
|
2590
|
+
}
|
|
2591
|
+
|
|
2592
|
+
return Parser.parse(_tokens, opt);
|
|
2593
|
+
} catch (e) {
|
|
2594
|
+
e.message += '\nPlease report this to https://github.com/markedjs/marked.';
|
|
2595
|
+
|
|
2596
|
+
if (opt.silent) {
|
|
2597
|
+
return '<p>An error occurred:</p><pre>' + escape(e.message + '', true) + '</pre>';
|
|
2598
|
+
}
|
|
2599
|
+
|
|
2600
|
+
throw e;
|
|
2601
|
+
}
|
|
2602
|
+
}
|
|
2603
|
+
/**
|
|
2604
|
+
* Options
|
|
2605
|
+
*/
|
|
2606
|
+
|
|
2607
|
+
marked.options = marked.setOptions = function (opt) {
|
|
2608
|
+
merge(marked.defaults, opt);
|
|
2609
|
+
changeDefaults(marked.defaults);
|
|
2610
|
+
return marked;
|
|
2611
|
+
};
|
|
2612
|
+
|
|
2613
|
+
marked.getDefaults = getDefaults;
|
|
2614
|
+
marked.defaults = exports.defaults;
|
|
2615
|
+
/**
|
|
2616
|
+
* Use Extension
|
|
2617
|
+
*/
|
|
2618
|
+
|
|
2619
|
+
marked.use = function () {
|
|
2620
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2621
|
+
args[_key] = arguments[_key];
|
|
2622
|
+
}
|
|
2623
|
+
|
|
2624
|
+
var opts = merge.apply(void 0, [{}].concat(args));
|
|
2625
|
+
var extensions = marked.defaults.extensions || {
|
|
2626
|
+
renderers: {},
|
|
2627
|
+
childTokens: {}
|
|
2628
|
+
};
|
|
2629
|
+
var hasExtensions;
|
|
2630
|
+
args.forEach(function (pack) {
|
|
2631
|
+
// ==-- Parse "addon" extensions --== //
|
|
2632
|
+
if (pack.extensions) {
|
|
2633
|
+
hasExtensions = true;
|
|
2634
|
+
pack.extensions.forEach(function (ext) {
|
|
2635
|
+
if (!ext.name) {
|
|
2636
|
+
throw new Error('extension name required');
|
|
2637
|
+
}
|
|
2638
|
+
|
|
2639
|
+
if (ext.renderer) {
|
|
2640
|
+
// Renderer extensions
|
|
2641
|
+
var prevRenderer = extensions.renderers ? extensions.renderers[ext.name] : null;
|
|
2642
|
+
|
|
2643
|
+
if (prevRenderer) {
|
|
2644
|
+
// Replace extension with func to run new extension but fall back if false
|
|
2645
|
+
extensions.renderers[ext.name] = function () {
|
|
2646
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
2647
|
+
args[_key2] = arguments[_key2];
|
|
2648
|
+
}
|
|
2649
|
+
|
|
2650
|
+
var ret = ext.renderer.apply(this, args);
|
|
2651
|
+
|
|
2652
|
+
if (ret === false) {
|
|
2653
|
+
ret = prevRenderer.apply(this, args);
|
|
2654
|
+
}
|
|
2655
|
+
|
|
2656
|
+
return ret;
|
|
2657
|
+
};
|
|
2658
|
+
} else {
|
|
2659
|
+
extensions.renderers[ext.name] = ext.renderer;
|
|
2660
|
+
}
|
|
2661
|
+
}
|
|
2662
|
+
|
|
2663
|
+
if (ext.tokenizer) {
|
|
2664
|
+
// Tokenizer Extensions
|
|
2665
|
+
if (!ext.level || ext.level !== 'block' && ext.level !== 'inline') {
|
|
2666
|
+
throw new Error("extension level must be 'block' or 'inline'");
|
|
2667
|
+
}
|
|
2668
|
+
|
|
2669
|
+
if (extensions[ext.level]) {
|
|
2670
|
+
extensions[ext.level].unshift(ext.tokenizer);
|
|
2671
|
+
} else {
|
|
2672
|
+
extensions[ext.level] = [ext.tokenizer];
|
|
2673
|
+
}
|
|
2674
|
+
|
|
2675
|
+
if (ext.start) {
|
|
2676
|
+
// Function to check for start of token
|
|
2677
|
+
if (ext.level === 'block') {
|
|
2678
|
+
if (extensions.startBlock) {
|
|
2679
|
+
extensions.startBlock.push(ext.start);
|
|
2680
|
+
} else {
|
|
2681
|
+
extensions.startBlock = [ext.start];
|
|
2682
|
+
}
|
|
2683
|
+
} else if (ext.level === 'inline') {
|
|
2684
|
+
if (extensions.startInline) {
|
|
2685
|
+
extensions.startInline.push(ext.start);
|
|
2686
|
+
} else {
|
|
2687
|
+
extensions.startInline = [ext.start];
|
|
2688
|
+
}
|
|
2689
|
+
}
|
|
2690
|
+
}
|
|
2691
|
+
}
|
|
2692
|
+
|
|
2693
|
+
if (ext.childTokens) {
|
|
2694
|
+
// Child tokens to be visited by walkTokens
|
|
2695
|
+
extensions.childTokens[ext.name] = ext.childTokens;
|
|
2696
|
+
}
|
|
2697
|
+
});
|
|
2698
|
+
} // ==-- Parse "overwrite" extensions --== //
|
|
2699
|
+
|
|
2700
|
+
|
|
2701
|
+
if (pack.renderer) {
|
|
2702
|
+
(function () {
|
|
2703
|
+
var renderer = marked.defaults.renderer || new Renderer();
|
|
2704
|
+
|
|
2705
|
+
var _loop = function _loop(prop) {
|
|
2706
|
+
var prevRenderer = renderer[prop]; // Replace renderer with func to run extension, but fall back if false
|
|
2707
|
+
|
|
2708
|
+
renderer[prop] = function () {
|
|
2709
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
2710
|
+
args[_key3] = arguments[_key3];
|
|
2711
|
+
}
|
|
2712
|
+
|
|
2713
|
+
var ret = pack.renderer[prop].apply(renderer, args);
|
|
2714
|
+
|
|
2715
|
+
if (ret === false) {
|
|
2716
|
+
ret = prevRenderer.apply(renderer, args);
|
|
2717
|
+
}
|
|
2718
|
+
|
|
2719
|
+
return ret;
|
|
2720
|
+
};
|
|
2721
|
+
};
|
|
2722
|
+
|
|
2723
|
+
for (var prop in pack.renderer) {
|
|
2724
|
+
_loop(prop);
|
|
2725
|
+
}
|
|
2726
|
+
|
|
2727
|
+
opts.renderer = renderer;
|
|
2728
|
+
})();
|
|
2729
|
+
}
|
|
2730
|
+
|
|
2731
|
+
if (pack.tokenizer) {
|
|
2732
|
+
(function () {
|
|
2733
|
+
var tokenizer = marked.defaults.tokenizer || new Tokenizer();
|
|
2734
|
+
|
|
2735
|
+
var _loop2 = function _loop2(prop) {
|
|
2736
|
+
var prevTokenizer = tokenizer[prop]; // Replace tokenizer with func to run extension, but fall back if false
|
|
2737
|
+
|
|
2738
|
+
tokenizer[prop] = function () {
|
|
2739
|
+
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
2740
|
+
args[_key4] = arguments[_key4];
|
|
2741
|
+
}
|
|
2742
|
+
|
|
2743
|
+
var ret = pack.tokenizer[prop].apply(tokenizer, args);
|
|
2744
|
+
|
|
2745
|
+
if (ret === false) {
|
|
2746
|
+
ret = prevTokenizer.apply(tokenizer, args);
|
|
2747
|
+
}
|
|
2748
|
+
|
|
2749
|
+
return ret;
|
|
2750
|
+
};
|
|
2751
|
+
};
|
|
2752
|
+
|
|
2753
|
+
for (var prop in pack.tokenizer) {
|
|
2754
|
+
_loop2(prop);
|
|
2755
|
+
}
|
|
2756
|
+
|
|
2757
|
+
opts.tokenizer = tokenizer;
|
|
2758
|
+
})();
|
|
2759
|
+
} // ==-- Parse WalkTokens extensions --== //
|
|
2760
|
+
|
|
2761
|
+
|
|
2762
|
+
if (pack.walkTokens) {
|
|
2763
|
+
var _walkTokens = marked.defaults.walkTokens;
|
|
2764
|
+
|
|
2765
|
+
opts.walkTokens = function (token) {
|
|
2766
|
+
pack.walkTokens.call(this, token);
|
|
2767
|
+
|
|
2768
|
+
if (_walkTokens) {
|
|
2769
|
+
_walkTokens.call(this, token);
|
|
2770
|
+
}
|
|
2771
|
+
};
|
|
2772
|
+
}
|
|
2773
|
+
|
|
2774
|
+
if (hasExtensions) {
|
|
2775
|
+
opts.extensions = extensions;
|
|
2776
|
+
}
|
|
2777
|
+
|
|
2778
|
+
marked.setOptions(opts);
|
|
2779
|
+
});
|
|
2780
|
+
};
|
|
2781
|
+
/**
|
|
2782
|
+
* Run callback for every token
|
|
2783
|
+
*/
|
|
2784
|
+
|
|
2785
|
+
|
|
2786
|
+
marked.walkTokens = function (tokens, callback) {
|
|
2787
|
+
var _loop3 = function _loop3() {
|
|
2788
|
+
var token = _step.value;
|
|
2789
|
+
callback.call(marked, token);
|
|
2790
|
+
|
|
2791
|
+
switch (token.type) {
|
|
2792
|
+
case 'table':
|
|
2793
|
+
{
|
|
2794
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose(token.header), _step2; !(_step2 = _iterator2()).done;) {
|
|
2795
|
+
var cell = _step2.value;
|
|
2796
|
+
marked.walkTokens(cell.tokens, callback);
|
|
2797
|
+
}
|
|
2798
|
+
|
|
2799
|
+
for (var _iterator3 = _createForOfIteratorHelperLoose(token.rows), _step3; !(_step3 = _iterator3()).done;) {
|
|
2800
|
+
var row = _step3.value;
|
|
2801
|
+
|
|
2802
|
+
for (var _iterator4 = _createForOfIteratorHelperLoose(row), _step4; !(_step4 = _iterator4()).done;) {
|
|
2803
|
+
var _cell = _step4.value;
|
|
2804
|
+
marked.walkTokens(_cell.tokens, callback);
|
|
2805
|
+
}
|
|
2806
|
+
}
|
|
2807
|
+
|
|
2808
|
+
break;
|
|
2809
|
+
}
|
|
2810
|
+
|
|
2811
|
+
case 'list':
|
|
2812
|
+
{
|
|
2813
|
+
marked.walkTokens(token.items, callback);
|
|
2814
|
+
break;
|
|
2815
|
+
}
|
|
2816
|
+
|
|
2817
|
+
default:
|
|
2818
|
+
{
|
|
2819
|
+
if (marked.defaults.extensions && marked.defaults.extensions.childTokens && marked.defaults.extensions.childTokens[token.type]) {
|
|
2820
|
+
// Walk any extensions
|
|
2821
|
+
marked.defaults.extensions.childTokens[token.type].forEach(function (childTokens) {
|
|
2822
|
+
marked.walkTokens(token[childTokens], callback);
|
|
2823
|
+
});
|
|
2824
|
+
} else if (token.tokens) {
|
|
2825
|
+
marked.walkTokens(token.tokens, callback);
|
|
2826
|
+
}
|
|
2827
|
+
}
|
|
2828
|
+
}
|
|
2829
|
+
};
|
|
2830
|
+
|
|
2831
|
+
for (var _iterator = _createForOfIteratorHelperLoose(tokens), _step; !(_step = _iterator()).done;) {
|
|
2832
|
+
_loop3();
|
|
2833
|
+
}
|
|
2834
|
+
};
|
|
2835
|
+
/**
|
|
2836
|
+
* Parse Inline
|
|
2837
|
+
*/
|
|
2838
|
+
|
|
2839
|
+
|
|
2840
|
+
marked.parseInline = function (src, opt) {
|
|
2841
|
+
// throw error in case of non string input
|
|
2842
|
+
if (typeof src === 'undefined' || src === null) {
|
|
2843
|
+
throw new Error('marked.parseInline(): input parameter is undefined or null');
|
|
2844
|
+
}
|
|
2845
|
+
|
|
2846
|
+
if (typeof src !== 'string') {
|
|
2847
|
+
throw new Error('marked.parseInline(): input parameter is of type ' + Object.prototype.toString.call(src) + ', string expected');
|
|
2848
|
+
}
|
|
2849
|
+
|
|
2850
|
+
opt = merge({}, marked.defaults, opt || {});
|
|
2851
|
+
checkSanitizeDeprecation(opt);
|
|
2852
|
+
|
|
2853
|
+
try {
|
|
2854
|
+
var tokens = Lexer.lexInline(src, opt);
|
|
2855
|
+
|
|
2856
|
+
if (opt.walkTokens) {
|
|
2857
|
+
marked.walkTokens(tokens, opt.walkTokens);
|
|
2858
|
+
}
|
|
2859
|
+
|
|
2860
|
+
return Parser.parseInline(tokens, opt);
|
|
2861
|
+
} catch (e) {
|
|
2862
|
+
e.message += '\nPlease report this to https://github.com/markedjs/marked.';
|
|
2863
|
+
|
|
2864
|
+
if (opt.silent) {
|
|
2865
|
+
return '<p>An error occurred:</p><pre>' + escape(e.message + '', true) + '</pre>';
|
|
2866
|
+
}
|
|
2867
|
+
|
|
2868
|
+
throw e;
|
|
2869
|
+
}
|
|
2870
|
+
};
|
|
2871
|
+
/**
|
|
2872
|
+
* Expose
|
|
2873
|
+
*/
|
|
2874
|
+
|
|
2875
|
+
|
|
2876
|
+
marked.Parser = Parser;
|
|
2877
|
+
marked.parser = Parser.parse;
|
|
2878
|
+
marked.Renderer = Renderer;
|
|
2879
|
+
marked.TextRenderer = TextRenderer;
|
|
2880
|
+
marked.Lexer = Lexer;
|
|
2881
|
+
marked.lexer = Lexer.lex;
|
|
2882
|
+
marked.Tokenizer = Tokenizer;
|
|
2883
|
+
marked.Slugger = Slugger;
|
|
2884
|
+
marked.parse = marked;
|
|
2885
|
+
var options = marked.options;
|
|
2886
|
+
var setOptions = marked.setOptions;
|
|
2887
|
+
var use = marked.use;
|
|
2888
|
+
var walkTokens = marked.walkTokens;
|
|
2889
|
+
var parseInline = marked.parseInline;
|
|
2890
|
+
var parse = marked;
|
|
2891
|
+
var parser = Parser.parse;
|
|
2892
|
+
var lexer = Lexer.lex;
|
|
2893
|
+
|
|
2894
|
+
exports.Lexer = Lexer;
|
|
2895
|
+
exports.Parser = Parser;
|
|
2896
|
+
exports.Renderer = Renderer;
|
|
2897
|
+
exports.Slugger = Slugger;
|
|
2898
|
+
exports.TextRenderer = TextRenderer;
|
|
2899
|
+
exports.Tokenizer = Tokenizer;
|
|
2900
|
+
exports.getDefaults = getDefaults;
|
|
2901
|
+
exports.lexer = lexer;
|
|
2902
|
+
exports.marked = marked;
|
|
2903
|
+
exports.options = options;
|
|
2904
|
+
exports.parse = parse;
|
|
2905
|
+
exports.parseInline = parseInline;
|
|
2906
|
+
exports.parser = parser;
|
|
2907
|
+
exports.setOptions = setOptions;
|
|
2908
|
+
exports.use = use;
|
|
2909
|
+
exports.walkTokens = walkTokens;
|
|
2910
|
+
|
|
2911
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2912
|
+
|
|
2913
|
+
}));
|