md-editor-v3 1.7.3 → 1.8.0
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/README.md +51 -1
- package/lib/MdEditor/Editor.d.ts +54 -2
- package/lib/md-editor-v3.es.js +2250 -2072
- package/lib/md-editor-v3.umd.js +74 -57
- package/lib/style.css +1 -1
- package/package.json +4 -3
package/lib/md-editor-v3.es.js
CHANGED
|
@@ -22,7 +22,7 @@ var __publicField = (obj, key, value) => {
|
|
|
22
22
|
return value;
|
|
23
23
|
};
|
|
24
24
|
import { onMounted, onBeforeUnmount, provide, computed, defineComponent, createVNode, reactive, ref, watch, cloneVNode, nextTick, inject, mergeProps, Fragment, Teleport } from "vue";
|
|
25
|
-
const iconfontUrl = "
|
|
25
|
+
const iconfontUrl = "//at.alicdn.com/t/font_2605852_ihjkm7wo1y.js";
|
|
26
26
|
const highlightUrl = {
|
|
27
27
|
atom: "https://cdn.jsdelivr.net/npm/highlight.js@11.2.0/styles/atom-one-dark.css",
|
|
28
28
|
github: "https://cdn.jsdelivr.net/npm/highlight.js@11.2.0/styles/github.css",
|
|
@@ -56,6 +56,7 @@ const allToolbar = [
|
|
|
56
56
|
"link",
|
|
57
57
|
"image",
|
|
58
58
|
"table",
|
|
59
|
+
"mermaid",
|
|
59
60
|
"-",
|
|
60
61
|
"revoke",
|
|
61
62
|
"next",
|
|
@@ -87,6 +88,7 @@ const staticTextDefault = {
|
|
|
87
88
|
link: "\u94FE\u63A5",
|
|
88
89
|
image: "\u56FE\u7247",
|
|
89
90
|
table: "\u8868\u683C",
|
|
91
|
+
mermaid: "mermaid\u56FE",
|
|
90
92
|
revoke: "\u540E\u9000",
|
|
91
93
|
next: "\u524D\u8FDB",
|
|
92
94
|
save: "\u4FDD\u5B58",
|
|
@@ -126,6 +128,16 @@ const staticTextDefault = {
|
|
|
126
128
|
copyCode: {
|
|
127
129
|
text: "\u590D\u5236\u4EE3\u7801",
|
|
128
130
|
tips: "\u5DF2\u590D\u5236\uFF01"
|
|
131
|
+
},
|
|
132
|
+
mermaid: {
|
|
133
|
+
flow: "\u6D41\u7A0B\u56FE",
|
|
134
|
+
sequence: "\u65F6\u5E8F\u56FE",
|
|
135
|
+
gantt: "\u7518\u7279\u56FE",
|
|
136
|
+
class: "\u7C7B\u56FE",
|
|
137
|
+
state: "\u72B6\u6001\u56FE",
|
|
138
|
+
pie: "\u997C\u56FE",
|
|
139
|
+
relationship: "\u5173\u7CFB\u56FE",
|
|
140
|
+
journey: "\u65C5\u7A0B\u56FE"
|
|
129
141
|
}
|
|
130
142
|
},
|
|
131
143
|
"en-US": {
|
|
@@ -145,6 +157,7 @@ const staticTextDefault = {
|
|
|
145
157
|
link: "link",
|
|
146
158
|
image: "image",
|
|
147
159
|
table: "table",
|
|
160
|
+
mermaid: "mermaid",
|
|
148
161
|
revoke: "revoke",
|
|
149
162
|
next: "undo revoke",
|
|
150
163
|
save: "save",
|
|
@@ -184,9 +197,20 @@ const staticTextDefault = {
|
|
|
184
197
|
copyCode: {
|
|
185
198
|
text: "Copy",
|
|
186
199
|
tips: "Copied!"
|
|
200
|
+
},
|
|
201
|
+
mermaid: {
|
|
202
|
+
flow: "flow",
|
|
203
|
+
sequence: "sequence",
|
|
204
|
+
gantt: "gantt",
|
|
205
|
+
class: "class",
|
|
206
|
+
state: "state",
|
|
207
|
+
pie: "pie",
|
|
208
|
+
relationship: "relationship",
|
|
209
|
+
journey: "journey"
|
|
187
210
|
}
|
|
188
211
|
}
|
|
189
212
|
};
|
|
213
|
+
const mermaidUrl = "https://cdn.jsdelivr.net/npm/mermaid@8.13.5/dist/mermaid.min.js";
|
|
190
214
|
class Bus {
|
|
191
215
|
constructor() {
|
|
192
216
|
__publicField(this, "pools", {});
|
|
@@ -470,6 +494,7 @@ const useProvide = (props2) => {
|
|
|
470
494
|
const { previewOnly, editorId, tabWidth, showCodeRowNumber, Cropper } = props2;
|
|
471
495
|
provide("editorId", editorId);
|
|
472
496
|
provide("tabWidth", tabWidth);
|
|
497
|
+
provide("theme", computed(() => props2.theme));
|
|
473
498
|
const highlightSet = computed(() => {
|
|
474
499
|
let url = highlightUrl.atom;
|
|
475
500
|
if (props2.highlightCss) {
|
|
@@ -697,11 +722,6 @@ const goto = (url, option = {
|
|
|
697
722
|
document.body.removeChild(aEle);
|
|
698
723
|
};
|
|
699
724
|
const scrollAuto = (pEle, cEle) => {
|
|
700
|
-
const pHeight = pEle.clientHeight;
|
|
701
|
-
const cHeight = cEle.clientHeight;
|
|
702
|
-
const pScrollHeight = pEle.scrollHeight;
|
|
703
|
-
const cScrollHeight = cEle.scrollHeight;
|
|
704
|
-
const scale = (pScrollHeight - pHeight) / (cScrollHeight - cHeight);
|
|
705
725
|
const addEvent = debounce(() => {
|
|
706
726
|
pEle.removeEventListener("scroll", scrollHandler);
|
|
707
727
|
pEle.addEventListener("scroll", scrollHandler);
|
|
@@ -709,6 +729,11 @@ const scrollAuto = (pEle, cEle) => {
|
|
|
709
729
|
cEle.addEventListener("scroll", scrollHandler);
|
|
710
730
|
}, 50);
|
|
711
731
|
const scrollHandler = (e) => {
|
|
732
|
+
const pHeight = pEle.clientHeight;
|
|
733
|
+
const cHeight = cEle.clientHeight;
|
|
734
|
+
const pScrollHeight = pEle.scrollHeight;
|
|
735
|
+
const cScrollHeight = cEle.scrollHeight;
|
|
736
|
+
const scale = (pScrollHeight - pHeight) / (cScrollHeight - cHeight);
|
|
712
737
|
if (e.target === pEle) {
|
|
713
738
|
cEle.removeEventListener("scroll", scrollHandler);
|
|
714
739
|
cEle.scrollTo({
|
|
@@ -802,6 +827,11 @@ const keyMove = (trigger, moveHandler) => {
|
|
|
802
827
|
trigger.removeEventListener("mousedown", triggerMouseDown);
|
|
803
828
|
};
|
|
804
829
|
};
|
|
830
|
+
const appendHandler = (ele) => {
|
|
831
|
+
if (!document.getElementById(ele.id)) {
|
|
832
|
+
document.head.appendChild(ele);
|
|
833
|
+
}
|
|
834
|
+
};
|
|
805
835
|
var style$2 = "";
|
|
806
836
|
var Modal = defineComponent({
|
|
807
837
|
props: {
|
|
@@ -1290,6 +1320,48 @@ const useSreenfull = (props2) => {
|
|
|
1290
1320
|
});
|
|
1291
1321
|
return { fullScreenHandler, screenfullLoad };
|
|
1292
1322
|
};
|
|
1323
|
+
const TableShape = defineComponent({
|
|
1324
|
+
name: "TableShape",
|
|
1325
|
+
props: {
|
|
1326
|
+
tableShape: {
|
|
1327
|
+
type: Array,
|
|
1328
|
+
default: () => [6, 4]
|
|
1329
|
+
},
|
|
1330
|
+
onSelected: {
|
|
1331
|
+
type: Function,
|
|
1332
|
+
default: () => {
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
},
|
|
1336
|
+
setup(props2) {
|
|
1337
|
+
const hoverPosition = reactive({
|
|
1338
|
+
x: -1,
|
|
1339
|
+
y: -1
|
|
1340
|
+
});
|
|
1341
|
+
return () => createVNode("div", {
|
|
1342
|
+
"class": `${prefix}-table-shape`,
|
|
1343
|
+
"onMouseleave": () => {
|
|
1344
|
+
hoverPosition.x = -1;
|
|
1345
|
+
hoverPosition.y = -1;
|
|
1346
|
+
}
|
|
1347
|
+
}, [new Array(props2.tableShape[1]).fill("").map((_, rowIndex) => createVNode("div", {
|
|
1348
|
+
"class": `${prefix}-table-shape-row`,
|
|
1349
|
+
"key": `table-shape-row-${rowIndex}`
|
|
1350
|
+
}, [new Array(props2.tableShape[0]).fill("").map((_2, colIndex) => createVNode("div", {
|
|
1351
|
+
"class": `${prefix}-table-shape-col`,
|
|
1352
|
+
"key": `table-shape-col-${colIndex}`,
|
|
1353
|
+
"onMouseenter": () => {
|
|
1354
|
+
hoverPosition.x = rowIndex;
|
|
1355
|
+
hoverPosition.y = colIndex;
|
|
1356
|
+
},
|
|
1357
|
+
"onClick": () => {
|
|
1358
|
+
props2.onSelected(hoverPosition);
|
|
1359
|
+
}
|
|
1360
|
+
}, [createVNode("div", {
|
|
1361
|
+
"class": [`${prefix}-table-shape-col-default`, rowIndex <= hoverPosition.x && colIndex <= hoverPosition.y && `${prefix}-table-shape-col-include`]
|
|
1362
|
+
}, null)]))]))]);
|
|
1363
|
+
}
|
|
1364
|
+
});
|
|
1293
1365
|
var ToolBar = defineComponent({
|
|
1294
1366
|
name: "MDEditorToolbar",
|
|
1295
1367
|
props: {
|
|
@@ -1320,6 +1392,10 @@ var ToolBar = defineComponent({
|
|
|
1320
1392
|
type: Function,
|
|
1321
1393
|
default: () => () => {
|
|
1322
1394
|
}
|
|
1395
|
+
},
|
|
1396
|
+
tableShape: {
|
|
1397
|
+
type: Array,
|
|
1398
|
+
default: () => [6, 4]
|
|
1323
1399
|
}
|
|
1324
1400
|
},
|
|
1325
1401
|
setup(props2) {
|
|
@@ -1333,7 +1409,9 @@ var ToolBar = defineComponent({
|
|
|
1333
1409
|
const visible = reactive({
|
|
1334
1410
|
title: false,
|
|
1335
1411
|
catalog: false,
|
|
1336
|
-
image: false
|
|
1412
|
+
image: false,
|
|
1413
|
+
table: false,
|
|
1414
|
+
mermaid: false
|
|
1337
1415
|
});
|
|
1338
1416
|
const emitHandler = (direct, params) => {
|
|
1339
1417
|
bus.emit(editorId, "replace", direct, params);
|
|
@@ -1376,7 +1454,7 @@ var ToolBar = defineComponent({
|
|
|
1376
1454
|
uploadRef.value.addEventListener("change", uploadHandler);
|
|
1377
1455
|
});
|
|
1378
1456
|
const barRender = (barItem) => {
|
|
1379
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F;
|
|
1457
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M;
|
|
1380
1458
|
switch (barItem) {
|
|
1381
1459
|
case "-": {
|
|
1382
1460
|
return createVNode(Divider, null, null);
|
|
@@ -1651,23 +1729,39 @@ var ToolBar = defineComponent({
|
|
|
1651
1729
|
});
|
|
1652
1730
|
}
|
|
1653
1731
|
case "table": {
|
|
1654
|
-
return createVNode(
|
|
1655
|
-
"
|
|
1656
|
-
"
|
|
1657
|
-
|
|
1658
|
-
|
|
1732
|
+
return createVNode(Dropdown, {
|
|
1733
|
+
"visible": visible.table,
|
|
1734
|
+
"onChange": (v) => {
|
|
1735
|
+
visible.table = v;
|
|
1736
|
+
},
|
|
1737
|
+
"key": "bar-table",
|
|
1738
|
+
"overlay": createVNode(TableShape, {
|
|
1739
|
+
"tableShape": props2.tableShape,
|
|
1740
|
+
"onSelected": (selectedShape) => {
|
|
1741
|
+
emitHandler("table", {
|
|
1742
|
+
selectedShape
|
|
1743
|
+
});
|
|
1744
|
+
}
|
|
1745
|
+
}, null)
|
|
1746
|
+
}, {
|
|
1747
|
+
default: () => {
|
|
1748
|
+
var _a2;
|
|
1749
|
+
return [createVNode("div", {
|
|
1750
|
+
"class": `${prefix}-toolbar-item`,
|
|
1751
|
+
"title": (_a2 = ult.value.toolbarTips) == null ? void 0 : _a2.table
|
|
1752
|
+
}, [createVNode("svg", {
|
|
1753
|
+
"class": `${prefix}-icon`,
|
|
1754
|
+
"aria-hidden": "true"
|
|
1755
|
+
}, [createVNode("use", {
|
|
1756
|
+
"xlink:href": "#icon-table"
|
|
1757
|
+
}, null)])])];
|
|
1659
1758
|
}
|
|
1660
|
-
}
|
|
1661
|
-
"class": `${prefix}-icon`,
|
|
1662
|
-
"aria-hidden": "true"
|
|
1663
|
-
}, [createVNode("use", {
|
|
1664
|
-
"xlink:href": "#icon-table"
|
|
1665
|
-
}, null)])]);
|
|
1759
|
+
});
|
|
1666
1760
|
}
|
|
1667
1761
|
case "revoke": {
|
|
1668
1762
|
return createVNode("div", {
|
|
1669
1763
|
"class": `${prefix}-toolbar-item`,
|
|
1670
|
-
"title": (
|
|
1764
|
+
"title": (_v = ult.value.toolbarTips) == null ? void 0 : _v.revoke,
|
|
1671
1765
|
"onClick": () => {
|
|
1672
1766
|
bus.emit(editorId, "ctrlZ");
|
|
1673
1767
|
}
|
|
@@ -1681,7 +1775,7 @@ var ToolBar = defineComponent({
|
|
|
1681
1775
|
case "next": {
|
|
1682
1776
|
return createVNode("div", {
|
|
1683
1777
|
"class": `${prefix}-toolbar-item`,
|
|
1684
|
-
"title": (
|
|
1778
|
+
"title": (_w = ult.value.toolbarTips) == null ? void 0 : _w.next,
|
|
1685
1779
|
"onClick": () => {
|
|
1686
1780
|
bus.emit(editorId, "ctrlShiftZ");
|
|
1687
1781
|
}
|
|
@@ -1695,7 +1789,7 @@ var ToolBar = defineComponent({
|
|
|
1695
1789
|
case "save": {
|
|
1696
1790
|
return createVNode("div", {
|
|
1697
1791
|
"class": `${prefix}-toolbar-item`,
|
|
1698
|
-
"title": (
|
|
1792
|
+
"title": (_x = ult.value.toolbarTips) == null ? void 0 : _x.save,
|
|
1699
1793
|
"onClick": () => {
|
|
1700
1794
|
bus.emit(editorId, "onSave");
|
|
1701
1795
|
}
|
|
@@ -1709,7 +1803,7 @@ var ToolBar = defineComponent({
|
|
|
1709
1803
|
case "prettier": {
|
|
1710
1804
|
return props2.prettier ? createVNode("div", {
|
|
1711
1805
|
"class": `${prefix}-toolbar-item`,
|
|
1712
|
-
"title": (
|
|
1806
|
+
"title": (_y = ult.value.toolbarTips) == null ? void 0 : _y.prettier,
|
|
1713
1807
|
"onClick": () => {
|
|
1714
1808
|
emitHandler("prettier");
|
|
1715
1809
|
}
|
|
@@ -1723,7 +1817,7 @@ var ToolBar = defineComponent({
|
|
|
1723
1817
|
case "pageFullscreen": {
|
|
1724
1818
|
return !props2.setting.fullscreen && createVNode("div", {
|
|
1725
1819
|
"class": `${prefix}-toolbar-item`,
|
|
1726
|
-
"title": (
|
|
1820
|
+
"title": (_z = ult.value.toolbarTips) == null ? void 0 : _z.pageFullscreen,
|
|
1727
1821
|
"onClick": () => {
|
|
1728
1822
|
props2.updateSetting(!props2.setting.pageFullScreen, "pageFullScreen");
|
|
1729
1823
|
}
|
|
@@ -1737,7 +1831,7 @@ var ToolBar = defineComponent({
|
|
|
1737
1831
|
case "fullscreen": {
|
|
1738
1832
|
return createVNode("div", {
|
|
1739
1833
|
"class": `${prefix}-toolbar-item`,
|
|
1740
|
-
"title": (
|
|
1834
|
+
"title": (_A = ult.value.toolbarTips) == null ? void 0 : _A.fullscreen,
|
|
1741
1835
|
"onClick": fullScreenHandler
|
|
1742
1836
|
}, [createVNode("svg", {
|
|
1743
1837
|
"class": `${prefix}-icon`,
|
|
@@ -1749,7 +1843,7 @@ var ToolBar = defineComponent({
|
|
|
1749
1843
|
case "preview": {
|
|
1750
1844
|
return createVNode("div", {
|
|
1751
1845
|
"class": `${prefix}-toolbar-item`,
|
|
1752
|
-
"title": (
|
|
1846
|
+
"title": (_B = ult.value.toolbarTips) == null ? void 0 : _B.preview,
|
|
1753
1847
|
"onClick": () => {
|
|
1754
1848
|
props2.updateSetting(!props2.setting.preview, "preview");
|
|
1755
1849
|
}
|
|
@@ -1763,7 +1857,7 @@ var ToolBar = defineComponent({
|
|
|
1763
1857
|
case "htmlPreview": {
|
|
1764
1858
|
return createVNode("div", {
|
|
1765
1859
|
"class": `${prefix}-toolbar-item`,
|
|
1766
|
-
"title": (
|
|
1860
|
+
"title": (_C = ult.value.toolbarTips) == null ? void 0 : _C.htmlPreview,
|
|
1767
1861
|
"onClick": () => {
|
|
1768
1862
|
props2.updateSetting(!props2.setting.htmlPreview, "htmlPreview");
|
|
1769
1863
|
}
|
|
@@ -1777,7 +1871,7 @@ var ToolBar = defineComponent({
|
|
|
1777
1871
|
case "catalog": {
|
|
1778
1872
|
return createVNode("div", {
|
|
1779
1873
|
"class": `${prefix}-toolbar-item`,
|
|
1780
|
-
"title": (
|
|
1874
|
+
"title": (_D = ult.value.toolbarTips) == null ? void 0 : _D.catalog,
|
|
1781
1875
|
"onClick": () => {
|
|
1782
1876
|
bus.emit(editorId, "catalogShow");
|
|
1783
1877
|
},
|
|
@@ -1792,7 +1886,7 @@ var ToolBar = defineComponent({
|
|
|
1792
1886
|
case "github": {
|
|
1793
1887
|
return createVNode("div", {
|
|
1794
1888
|
"class": `${prefix}-toolbar-item`,
|
|
1795
|
-
"title": (
|
|
1889
|
+
"title": (_E = ult.value.toolbarTips) == null ? void 0 : _E.github,
|
|
1796
1890
|
"onClick": () => goto("https://github.com/imzbf/md-editor-v3")
|
|
1797
1891
|
}, [createVNode("svg", {
|
|
1798
1892
|
"class": `${prefix}-icon`,
|
|
@@ -1801,6 +1895,74 @@ var ToolBar = defineComponent({
|
|
|
1801
1895
|
"xlink:href": "#icon-github"
|
|
1802
1896
|
}, null)])]);
|
|
1803
1897
|
}
|
|
1898
|
+
case "mermaid": {
|
|
1899
|
+
return createVNode(Dropdown, {
|
|
1900
|
+
"visible": visible.mermaid,
|
|
1901
|
+
"onChange": (v) => {
|
|
1902
|
+
visible.mermaid = v;
|
|
1903
|
+
},
|
|
1904
|
+
"overlay": createVNode("ul", {
|
|
1905
|
+
"class": `${prefix}-menu`,
|
|
1906
|
+
"onClick": () => {
|
|
1907
|
+
visible.mermaid = false;
|
|
1908
|
+
}
|
|
1909
|
+
}, [createVNode("li", {
|
|
1910
|
+
"class": `${prefix}-menu-item`,
|
|
1911
|
+
"onClick": () => {
|
|
1912
|
+
emitHandler("flow");
|
|
1913
|
+
}
|
|
1914
|
+
}, [(_F = ult.value.mermaid) == null ? void 0 : _F.flow]), createVNode("li", {
|
|
1915
|
+
"class": `${prefix}-menu-item`,
|
|
1916
|
+
"onClick": () => {
|
|
1917
|
+
emitHandler("sequence");
|
|
1918
|
+
}
|
|
1919
|
+
}, [(_G = ult.value.mermaid) == null ? void 0 : _G.sequence]), createVNode("li", {
|
|
1920
|
+
"class": `${prefix}-menu-item`,
|
|
1921
|
+
"onClick": () => {
|
|
1922
|
+
emitHandler("gantt");
|
|
1923
|
+
}
|
|
1924
|
+
}, [(_H = ult.value.mermaid) == null ? void 0 : _H.gantt]), createVNode("li", {
|
|
1925
|
+
"class": `${prefix}-menu-item`,
|
|
1926
|
+
"onClick": () => {
|
|
1927
|
+
emitHandler("class");
|
|
1928
|
+
}
|
|
1929
|
+
}, [(_I = ult.value.mermaid) == null ? void 0 : _I.class]), createVNode("li", {
|
|
1930
|
+
"class": `${prefix}-menu-item`,
|
|
1931
|
+
"onClick": () => {
|
|
1932
|
+
emitHandler("state");
|
|
1933
|
+
}
|
|
1934
|
+
}, [(_J = ult.value.mermaid) == null ? void 0 : _J.state]), createVNode("li", {
|
|
1935
|
+
"class": `${prefix}-menu-item`,
|
|
1936
|
+
"onClick": () => {
|
|
1937
|
+
emitHandler("pie");
|
|
1938
|
+
}
|
|
1939
|
+
}, [(_K = ult.value.mermaid) == null ? void 0 : _K.pie]), createVNode("li", {
|
|
1940
|
+
"class": `${prefix}-menu-item`,
|
|
1941
|
+
"onClick": () => {
|
|
1942
|
+
emitHandler("relationship");
|
|
1943
|
+
}
|
|
1944
|
+
}, [(_L = ult.value.mermaid) == null ? void 0 : _L.relationship]), createVNode("li", {
|
|
1945
|
+
"class": `${prefix}-menu-item`,
|
|
1946
|
+
"onClick": () => {
|
|
1947
|
+
emitHandler("journey");
|
|
1948
|
+
}
|
|
1949
|
+
}, [(_M = ult.value.mermaid) == null ? void 0 : _M.journey])]),
|
|
1950
|
+
"key": "bar-mermaid"
|
|
1951
|
+
}, {
|
|
1952
|
+
default: () => {
|
|
1953
|
+
var _a2;
|
|
1954
|
+
return [createVNode("div", {
|
|
1955
|
+
"class": `${prefix}-toolbar-item`,
|
|
1956
|
+
"title": (_a2 = ult.value.toolbarTips) == null ? void 0 : _a2.mermaid
|
|
1957
|
+
}, [createVNode("svg", {
|
|
1958
|
+
"class": `${prefix}-icon`,
|
|
1959
|
+
"aria-hidden": "true"
|
|
1960
|
+
}, [createVNode("use", {
|
|
1961
|
+
"xlink:href": "#icon-mermaid"
|
|
1962
|
+
}, null)])])];
|
|
1963
|
+
}
|
|
1964
|
+
});
|
|
1965
|
+
}
|
|
1804
1966
|
}
|
|
1805
1967
|
};
|
|
1806
1968
|
return () => {
|
|
@@ -1852,2149 +2014,1944 @@ var ToolBar = defineComponent({
|
|
|
1852
2014
|
};
|
|
1853
2015
|
}
|
|
1854
2016
|
});
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
2017
|
+
function getDefaults() {
|
|
2018
|
+
return {
|
|
2019
|
+
baseUrl: null,
|
|
2020
|
+
breaks: false,
|
|
2021
|
+
extensions: null,
|
|
2022
|
+
gfm: true,
|
|
2023
|
+
headerIds: true,
|
|
2024
|
+
headerPrefix: "",
|
|
2025
|
+
highlight: null,
|
|
2026
|
+
langPrefix: "language-",
|
|
2027
|
+
mangle: true,
|
|
2028
|
+
pedantic: false,
|
|
2029
|
+
renderer: null,
|
|
2030
|
+
sanitize: false,
|
|
2031
|
+
sanitizer: null,
|
|
2032
|
+
silent: false,
|
|
2033
|
+
smartLists: false,
|
|
2034
|
+
smartypants: false,
|
|
2035
|
+
tokenizer: null,
|
|
2036
|
+
walkTokens: null,
|
|
2037
|
+
xhtml: false
|
|
2038
|
+
};
|
|
2039
|
+
}
|
|
2040
|
+
let defaults = getDefaults();
|
|
2041
|
+
function changeDefaults(newDefaults) {
|
|
2042
|
+
defaults = newDefaults;
|
|
2043
|
+
}
|
|
2044
|
+
const escapeTest = /[&<>"']/;
|
|
2045
|
+
const escapeReplace = /[&<>"']/g;
|
|
2046
|
+
const escapeTestNoEncode = /[<>"']|&(?!#?\w+;)/;
|
|
2047
|
+
const escapeReplaceNoEncode = /[<>"']|&(?!#?\w+;)/g;
|
|
2048
|
+
const escapeReplacements = {
|
|
2049
|
+
"&": "&",
|
|
2050
|
+
"<": "<",
|
|
2051
|
+
">": ">",
|
|
2052
|
+
'"': """,
|
|
2053
|
+
"'": "'"
|
|
2054
|
+
};
|
|
2055
|
+
const getEscapeReplacement = (ch) => escapeReplacements[ch];
|
|
2056
|
+
function escape(html, encode) {
|
|
2057
|
+
if (encode) {
|
|
2058
|
+
if (escapeTest.test(html)) {
|
|
2059
|
+
return html.replace(escapeReplace, getEscapeReplacement);
|
|
2060
|
+
}
|
|
2061
|
+
} else {
|
|
2062
|
+
if (escapeTestNoEncode.test(html)) {
|
|
2063
|
+
return html.replace(escapeReplaceNoEncode, getEscapeReplacement);
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
2066
|
+
return html;
|
|
2067
|
+
}
|
|
2068
|
+
const unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
|
|
2069
|
+
function unescape(html) {
|
|
2070
|
+
return html.replace(unescapeTest, (_, n) => {
|
|
2071
|
+
n = n.toLowerCase();
|
|
2072
|
+
if (n === "colon")
|
|
2073
|
+
return ":";
|
|
2074
|
+
if (n.charAt(0) === "#") {
|
|
2075
|
+
return n.charAt(1) === "x" ? String.fromCharCode(parseInt(n.substring(2), 16)) : String.fromCharCode(+n.substring(1));
|
|
2076
|
+
}
|
|
2077
|
+
return "";
|
|
2078
|
+
});
|
|
2079
|
+
}
|
|
2080
|
+
const caret = /(^|[^\[])\^/g;
|
|
2081
|
+
function edit(regex, opt) {
|
|
2082
|
+
regex = regex.source || regex;
|
|
2083
|
+
opt = opt || "";
|
|
2084
|
+
const obj = {
|
|
2085
|
+
replace: (name, val) => {
|
|
2086
|
+
val = val.source || val;
|
|
2087
|
+
val = val.replace(caret, "$1");
|
|
2088
|
+
regex = regex.replace(name, val);
|
|
2089
|
+
return obj;
|
|
2090
|
+
},
|
|
2091
|
+
getRegex: () => {
|
|
2092
|
+
return new RegExp(regex, opt);
|
|
2093
|
+
}
|
|
2094
|
+
};
|
|
2095
|
+
return obj;
|
|
2096
|
+
}
|
|
2097
|
+
const nonWordAndColonTest = /[^\w:]/g;
|
|
2098
|
+
const originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
|
|
2099
|
+
function cleanUrl(sanitize, base, href) {
|
|
2100
|
+
if (sanitize) {
|
|
2101
|
+
let prot;
|
|
2102
|
+
try {
|
|
2103
|
+
prot = decodeURIComponent(unescape(href)).replace(nonWordAndColonTest, "").toLowerCase();
|
|
2104
|
+
} catch (e) {
|
|
2105
|
+
return null;
|
|
2106
|
+
}
|
|
2107
|
+
if (prot.indexOf("javascript:") === 0 || prot.indexOf("vbscript:") === 0 || prot.indexOf("data:") === 0) {
|
|
2108
|
+
return null;
|
|
2109
|
+
}
|
|
2110
|
+
}
|
|
2111
|
+
if (base && !originIndependentUrl.test(href)) {
|
|
2112
|
+
href = resolveUrl(base, href);
|
|
2113
|
+
}
|
|
2114
|
+
try {
|
|
2115
|
+
href = encodeURI(href).replace(/%25/g, "%");
|
|
2116
|
+
} catch (e) {
|
|
2117
|
+
return null;
|
|
2118
|
+
}
|
|
2119
|
+
return href;
|
|
2120
|
+
}
|
|
2121
|
+
const baseUrls = {};
|
|
2122
|
+
const justDomain = /^[^:]+:\/*[^/]*$/;
|
|
2123
|
+
const protocol = /^([^:]+:)[\s\S]*$/;
|
|
2124
|
+
const domain = /^([^:]+:\/*[^/]*)[\s\S]*$/;
|
|
2125
|
+
function resolveUrl(base, href) {
|
|
2126
|
+
if (!baseUrls[" " + base]) {
|
|
2127
|
+
if (justDomain.test(base)) {
|
|
2128
|
+
baseUrls[" " + base] = base + "/";
|
|
2129
|
+
} else {
|
|
2130
|
+
baseUrls[" " + base] = rtrim(base, "/", true);
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
base = baseUrls[" " + base];
|
|
2134
|
+
const relativeBase = base.indexOf(":") === -1;
|
|
2135
|
+
if (href.substring(0, 2) === "//") {
|
|
2136
|
+
if (relativeBase) {
|
|
2137
|
+
return href;
|
|
2138
|
+
}
|
|
2139
|
+
return base.replace(protocol, "$1") + href;
|
|
2140
|
+
} else if (href.charAt(0) === "/") {
|
|
2141
|
+
if (relativeBase) {
|
|
2142
|
+
return href;
|
|
2143
|
+
}
|
|
2144
|
+
return base.replace(domain, "$1") + href;
|
|
2145
|
+
} else {
|
|
2146
|
+
return base + href;
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2149
|
+
const noopTest = { exec: function noopTest2() {
|
|
2150
|
+
} };
|
|
2151
|
+
function merge(obj) {
|
|
2152
|
+
let i = 1, target, key;
|
|
2153
|
+
for (; i < arguments.length; i++) {
|
|
2154
|
+
target = arguments[i];
|
|
2155
|
+
for (key in target) {
|
|
2156
|
+
if (Object.prototype.hasOwnProperty.call(target, key)) {
|
|
2157
|
+
obj[key] = target[key];
|
|
2158
|
+
}
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2161
|
+
return obj;
|
|
2162
|
+
}
|
|
2163
|
+
function splitCells(tableRow, count) {
|
|
2164
|
+
const row = tableRow.replace(/\|/g, (match, offset, str) => {
|
|
2165
|
+
let escaped = false, curr = offset;
|
|
2166
|
+
while (--curr >= 0 && str[curr] === "\\")
|
|
2167
|
+
escaped = !escaped;
|
|
2168
|
+
if (escaped) {
|
|
2169
|
+
return "|";
|
|
2170
|
+
} else {
|
|
2171
|
+
return " |";
|
|
2172
|
+
}
|
|
2173
|
+
}), cells = row.split(/ \|/);
|
|
2174
|
+
let i = 0;
|
|
2175
|
+
if (!cells[0].trim()) {
|
|
2176
|
+
cells.shift();
|
|
2177
|
+
}
|
|
2178
|
+
if (!cells[cells.length - 1].trim()) {
|
|
2179
|
+
cells.pop();
|
|
2180
|
+
}
|
|
2181
|
+
if (cells.length > count) {
|
|
2182
|
+
cells.splice(count);
|
|
2183
|
+
} else {
|
|
2184
|
+
while (cells.length < count)
|
|
2185
|
+
cells.push("");
|
|
2186
|
+
}
|
|
2187
|
+
for (; i < cells.length; i++) {
|
|
2188
|
+
cells[i] = cells[i].trim().replace(/\\\|/g, "|");
|
|
2189
|
+
}
|
|
2190
|
+
return cells;
|
|
2191
|
+
}
|
|
2192
|
+
function rtrim(str, c, invert) {
|
|
2193
|
+
const l = str.length;
|
|
2194
|
+
if (l === 0) {
|
|
2195
|
+
return "";
|
|
2196
|
+
}
|
|
2197
|
+
let suffLen = 0;
|
|
2198
|
+
while (suffLen < l) {
|
|
2199
|
+
const currChar = str.charAt(l - suffLen - 1);
|
|
2200
|
+
if (currChar === c && !invert) {
|
|
2201
|
+
suffLen++;
|
|
2202
|
+
} else if (currChar !== c && invert) {
|
|
2203
|
+
suffLen++;
|
|
2204
|
+
} else {
|
|
2205
|
+
break;
|
|
2206
|
+
}
|
|
2207
|
+
}
|
|
2208
|
+
return str.substr(0, l - suffLen);
|
|
2209
|
+
}
|
|
2210
|
+
function findClosingBracket(str, b) {
|
|
2211
|
+
if (str.indexOf(b[1]) === -1) {
|
|
2212
|
+
return -1;
|
|
2213
|
+
}
|
|
2214
|
+
const l = str.length;
|
|
2215
|
+
let level = 0, i = 0;
|
|
2216
|
+
for (; i < l; i++) {
|
|
2217
|
+
if (str[i] === "\\") {
|
|
2218
|
+
i++;
|
|
2219
|
+
} else if (str[i] === b[0]) {
|
|
2220
|
+
level++;
|
|
2221
|
+
} else if (str[i] === b[1]) {
|
|
2222
|
+
level--;
|
|
2223
|
+
if (level < 0) {
|
|
2224
|
+
return i;
|
|
1869
2225
|
}
|
|
1870
2226
|
}
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
2227
|
+
}
|
|
2228
|
+
return -1;
|
|
2229
|
+
}
|
|
2230
|
+
function checkSanitizeDeprecation(opt) {
|
|
2231
|
+
if (opt && opt.sanitize && !opt.silent) {
|
|
2232
|
+
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");
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
function repeatString(pattern, count) {
|
|
2236
|
+
if (count < 1) {
|
|
2237
|
+
return "";
|
|
2238
|
+
}
|
|
2239
|
+
let result = "";
|
|
2240
|
+
while (count > 1) {
|
|
2241
|
+
if (count & 1) {
|
|
2242
|
+
result += pattern;
|
|
1877
2243
|
}
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
2244
|
+
count >>= 1;
|
|
2245
|
+
pattern += pattern;
|
|
2246
|
+
}
|
|
2247
|
+
return result + pattern;
|
|
2248
|
+
}
|
|
2249
|
+
function outputLink(cap, link, raw, lexer) {
|
|
2250
|
+
const href = link.href;
|
|
2251
|
+
const title = link.title ? escape(link.title) : null;
|
|
2252
|
+
const text = cap[1].replace(/\\([\[\]])/g, "$1");
|
|
2253
|
+
if (cap[0].charAt(0) !== "!") {
|
|
2254
|
+
lexer.state.inLink = true;
|
|
2255
|
+
const token = {
|
|
2256
|
+
type: "link",
|
|
2257
|
+
raw,
|
|
2258
|
+
href,
|
|
2259
|
+
title,
|
|
2260
|
+
text,
|
|
2261
|
+
tokens: lexer.inlineTokens(text, [])
|
|
2262
|
+
};
|
|
2263
|
+
lexer.state.inLink = false;
|
|
2264
|
+
return token;
|
|
2265
|
+
} else {
|
|
2266
|
+
return {
|
|
2267
|
+
type: "image",
|
|
2268
|
+
raw,
|
|
2269
|
+
href,
|
|
2270
|
+
title,
|
|
2271
|
+
text: escape(text)
|
|
2272
|
+
};
|
|
2273
|
+
}
|
|
2274
|
+
}
|
|
2275
|
+
function indentCodeCompensation(raw, text) {
|
|
2276
|
+
const matchIndentToCode = raw.match(/^(\s+)(?:```)/);
|
|
2277
|
+
if (matchIndentToCode === null) {
|
|
2278
|
+
return text;
|
|
2279
|
+
}
|
|
2280
|
+
const indentToCode = matchIndentToCode[1];
|
|
2281
|
+
return text.split("\n").map((node) => {
|
|
2282
|
+
const matchIndentInNode = node.match(/^\s+/);
|
|
2283
|
+
if (matchIndentInNode === null) {
|
|
2284
|
+
return node;
|
|
1890
2285
|
}
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
1895
|
-
arr2[i] = arr[i];
|
|
1896
|
-
return arr2;
|
|
2286
|
+
const [indentInNode] = matchIndentInNode;
|
|
2287
|
+
if (indentInNode.length >= indentToCode.length) {
|
|
2288
|
+
return node.slice(indentToCode.length);
|
|
1897
2289
|
}
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
done: false,
|
|
1913
|
-
value: o[i++]
|
|
1914
|
-
};
|
|
2290
|
+
return node;
|
|
2291
|
+
}).join("\n");
|
|
2292
|
+
}
|
|
2293
|
+
class Tokenizer {
|
|
2294
|
+
constructor(options) {
|
|
2295
|
+
this.options = options || defaults;
|
|
2296
|
+
}
|
|
2297
|
+
space(src) {
|
|
2298
|
+
const cap = this.rules.block.newline.exec(src);
|
|
2299
|
+
if (cap) {
|
|
2300
|
+
if (cap[0].length > 1) {
|
|
2301
|
+
return {
|
|
2302
|
+
type: "space",
|
|
2303
|
+
raw: cap[0]
|
|
1915
2304
|
};
|
|
1916
2305
|
}
|
|
1917
|
-
|
|
2306
|
+
return { raw: "\n" };
|
|
1918
2307
|
}
|
|
1919
|
-
|
|
1920
|
-
|
|
2308
|
+
}
|
|
2309
|
+
code(src) {
|
|
2310
|
+
const cap = this.rules.block.code.exec(src);
|
|
2311
|
+
if (cap) {
|
|
2312
|
+
const text = cap[0].replace(/^ {1,4}/gm, "");
|
|
1921
2313
|
return {
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
headerIds: true,
|
|
1927
|
-
headerPrefix: "",
|
|
1928
|
-
highlight: null,
|
|
1929
|
-
langPrefix: "language-",
|
|
1930
|
-
mangle: true,
|
|
1931
|
-
pedantic: false,
|
|
1932
|
-
renderer: null,
|
|
1933
|
-
sanitize: false,
|
|
1934
|
-
sanitizer: null,
|
|
1935
|
-
silent: false,
|
|
1936
|
-
smartLists: false,
|
|
1937
|
-
smartypants: false,
|
|
1938
|
-
tokenizer: null,
|
|
1939
|
-
walkTokens: null,
|
|
1940
|
-
xhtml: false
|
|
2314
|
+
type: "code",
|
|
2315
|
+
raw: cap[0],
|
|
2316
|
+
codeBlockStyle: "indented",
|
|
2317
|
+
text: !this.options.pedantic ? rtrim(text, "\n") : text
|
|
1941
2318
|
};
|
|
1942
2319
|
}
|
|
1943
|
-
|
|
1944
|
-
|
|
2320
|
+
}
|
|
2321
|
+
fences(src) {
|
|
2322
|
+
const cap = this.rules.block.fences.exec(src);
|
|
2323
|
+
if (cap) {
|
|
2324
|
+
const raw = cap[0];
|
|
2325
|
+
const text = indentCodeCompensation(raw, cap[3] || "");
|
|
2326
|
+
return {
|
|
2327
|
+
type: "code",
|
|
2328
|
+
raw,
|
|
2329
|
+
lang: cap[2] ? cap[2].trim() : cap[2],
|
|
2330
|
+
text
|
|
2331
|
+
};
|
|
1945
2332
|
}
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
"<": "<",
|
|
1958
|
-
">": ">",
|
|
1959
|
-
'"': """,
|
|
1960
|
-
"'": "'"
|
|
1961
|
-
};
|
|
1962
|
-
var getEscapeReplacement = function getEscapeReplacement2(ch) {
|
|
1963
|
-
return escapeReplacements[ch];
|
|
1964
|
-
};
|
|
1965
|
-
function escape$2(html, encode) {
|
|
1966
|
-
if (encode) {
|
|
1967
|
-
if (escapeTest.test(html)) {
|
|
1968
|
-
return html.replace(escapeReplace, getEscapeReplacement);
|
|
1969
|
-
}
|
|
1970
|
-
} else {
|
|
1971
|
-
if (escapeTestNoEncode.test(html)) {
|
|
1972
|
-
return html.replace(escapeReplaceNoEncode, getEscapeReplacement);
|
|
2333
|
+
}
|
|
2334
|
+
heading(src) {
|
|
2335
|
+
const cap = this.rules.block.heading.exec(src);
|
|
2336
|
+
if (cap) {
|
|
2337
|
+
let text = cap[2].trim();
|
|
2338
|
+
if (/#$/.test(text)) {
|
|
2339
|
+
const trimmed = rtrim(text, "#");
|
|
2340
|
+
if (this.options.pedantic) {
|
|
2341
|
+
text = trimmed.trim();
|
|
2342
|
+
} else if (!trimmed || / $/.test(trimmed)) {
|
|
2343
|
+
text = trimmed.trim();
|
|
1973
2344
|
}
|
|
1974
2345
|
}
|
|
1975
|
-
|
|
2346
|
+
const token = {
|
|
2347
|
+
type: "heading",
|
|
2348
|
+
raw: cap[0],
|
|
2349
|
+
depth: cap[1].length,
|
|
2350
|
+
text,
|
|
2351
|
+
tokens: []
|
|
2352
|
+
};
|
|
2353
|
+
this.lexer.inline(token.text, token.tokens);
|
|
2354
|
+
return token;
|
|
1976
2355
|
}
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
}
|
|
1986
|
-
return "";
|
|
1987
|
-
});
|
|
2356
|
+
}
|
|
2357
|
+
hr(src) {
|
|
2358
|
+
const cap = this.rules.block.hr.exec(src);
|
|
2359
|
+
if (cap) {
|
|
2360
|
+
return {
|
|
2361
|
+
type: "hr",
|
|
2362
|
+
raw: cap[0]
|
|
2363
|
+
};
|
|
1988
2364
|
}
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
},
|
|
2000
|
-
getRegex: function getRegex() {
|
|
2001
|
-
return new RegExp(regex, opt);
|
|
2002
|
-
}
|
|
2365
|
+
}
|
|
2366
|
+
blockquote(src) {
|
|
2367
|
+
const cap = this.rules.block.blockquote.exec(src);
|
|
2368
|
+
if (cap) {
|
|
2369
|
+
const text = cap[0].replace(/^ *> ?/gm, "");
|
|
2370
|
+
return {
|
|
2371
|
+
type: "blockquote",
|
|
2372
|
+
raw: cap[0],
|
|
2373
|
+
tokens: this.lexer.blockTokens(text, []),
|
|
2374
|
+
text
|
|
2003
2375
|
};
|
|
2004
|
-
return obj;
|
|
2005
2376
|
}
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2377
|
+
}
|
|
2378
|
+
list(src) {
|
|
2379
|
+
let cap = this.rules.block.list.exec(src);
|
|
2380
|
+
if (cap) {
|
|
2381
|
+
let raw, istask, ischecked, indent, i, blankLine, endsWithBlankLine, line, nextLine, rawLine, itemContents, endEarly;
|
|
2382
|
+
let bull = cap[1].trim();
|
|
2383
|
+
const isordered = bull.length > 1;
|
|
2384
|
+
const list = {
|
|
2385
|
+
type: "list",
|
|
2386
|
+
raw: "",
|
|
2387
|
+
ordered: isordered,
|
|
2388
|
+
start: isordered ? +bull.slice(0, -1) : "",
|
|
2389
|
+
loose: false,
|
|
2390
|
+
items: []
|
|
2391
|
+
};
|
|
2392
|
+
bull = isordered ? `\\d{1,9}\\${bull.slice(-1)}` : `\\${bull}`;
|
|
2393
|
+
if (this.options.pedantic) {
|
|
2394
|
+
bull = isordered ? bull : "[*+-]";
|
|
2395
|
+
}
|
|
2396
|
+
const itemRegex = new RegExp(`^( {0,3}${bull})((?: [^\\n]*)?(?:\\n|$))`);
|
|
2397
|
+
while (src) {
|
|
2398
|
+
endEarly = false;
|
|
2399
|
+
if (!(cap = itemRegex.exec(src))) {
|
|
2400
|
+
break;
|
|
2015
2401
|
}
|
|
2016
|
-
if (
|
|
2017
|
-
|
|
2402
|
+
if (this.rules.block.hr.test(src)) {
|
|
2403
|
+
break;
|
|
2018
2404
|
}
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
return null;
|
|
2027
|
-
}
|
|
2028
|
-
return href;
|
|
2029
|
-
}
|
|
2030
|
-
var baseUrls = {};
|
|
2031
|
-
var justDomain = /^[^:]+:\/*[^/]*$/;
|
|
2032
|
-
var protocol = /^([^:]+:)[\s\S]*$/;
|
|
2033
|
-
var domain = /^([^:]+:\/*[^/]*)[\s\S]*$/;
|
|
2034
|
-
function resolveUrl(base, href) {
|
|
2035
|
-
if (!baseUrls[" " + base]) {
|
|
2036
|
-
if (justDomain.test(base)) {
|
|
2037
|
-
baseUrls[" " + base] = base + "/";
|
|
2405
|
+
raw = cap[0];
|
|
2406
|
+
src = src.substring(raw.length);
|
|
2407
|
+
line = cap[2].split("\n", 1)[0];
|
|
2408
|
+
nextLine = src.split("\n", 1)[0];
|
|
2409
|
+
if (this.options.pedantic) {
|
|
2410
|
+
indent = 2;
|
|
2411
|
+
itemContents = line.trimLeft();
|
|
2038
2412
|
} else {
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
if (
|
|
2046
|
-
|
|
2413
|
+
indent = cap[2].search(/[^ ]/);
|
|
2414
|
+
indent = indent > 4 ? 1 : indent;
|
|
2415
|
+
itemContents = line.slice(indent);
|
|
2416
|
+
indent += cap[1].length;
|
|
2417
|
+
}
|
|
2418
|
+
blankLine = false;
|
|
2419
|
+
if (!line && /^ *$/.test(nextLine)) {
|
|
2420
|
+
raw += nextLine + "\n";
|
|
2421
|
+
src = src.substring(nextLine.length + 1);
|
|
2422
|
+
endEarly = true;
|
|
2423
|
+
}
|
|
2424
|
+
if (!endEarly) {
|
|
2425
|
+
const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])`);
|
|
2426
|
+
while (src) {
|
|
2427
|
+
rawLine = src.split("\n", 1)[0];
|
|
2428
|
+
line = rawLine;
|
|
2429
|
+
if (this.options.pedantic) {
|
|
2430
|
+
line = line.replace(/^ {1,4}(?=( {4})*[^ ])/g, " ");
|
|
2431
|
+
}
|
|
2432
|
+
if (nextBulletRegex.test(line)) {
|
|
2433
|
+
break;
|
|
2434
|
+
}
|
|
2435
|
+
if (line.search(/[^ ]/) >= indent || !line.trim()) {
|
|
2436
|
+
itemContents += "\n" + line.slice(indent);
|
|
2437
|
+
} else if (!blankLine) {
|
|
2438
|
+
itemContents += "\n" + line;
|
|
2439
|
+
} else {
|
|
2440
|
+
break;
|
|
2441
|
+
}
|
|
2442
|
+
if (!blankLine && !line.trim()) {
|
|
2443
|
+
blankLine = true;
|
|
2444
|
+
}
|
|
2445
|
+
raw += rawLine + "\n";
|
|
2446
|
+
src = src.substring(rawLine.length + 1);
|
|
2447
|
+
}
|
|
2047
2448
|
}
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2449
|
+
if (!list.loose) {
|
|
2450
|
+
if (endsWithBlankLine) {
|
|
2451
|
+
list.loose = true;
|
|
2452
|
+
} else if (/\n *\n *$/.test(raw)) {
|
|
2453
|
+
endsWithBlankLine = true;
|
|
2454
|
+
}
|
|
2052
2455
|
}
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
var noopTest$1 = {
|
|
2059
|
-
exec: function noopTest2() {
|
|
2060
|
-
}
|
|
2061
|
-
};
|
|
2062
|
-
function merge$2(obj) {
|
|
2063
|
-
var i = 1, target, key;
|
|
2064
|
-
for (; i < arguments.length; i++) {
|
|
2065
|
-
target = arguments[i];
|
|
2066
|
-
for (key in target) {
|
|
2067
|
-
if (Object.prototype.hasOwnProperty.call(target, key)) {
|
|
2068
|
-
obj[key] = target[key];
|
|
2456
|
+
if (this.options.gfm) {
|
|
2457
|
+
istask = /^\[[ xX]\] /.exec(itemContents);
|
|
2458
|
+
if (istask) {
|
|
2459
|
+
ischecked = istask[0] !== "[ ] ";
|
|
2460
|
+
itemContents = itemContents.replace(/^\[[ xX]\] +/, "");
|
|
2069
2461
|
}
|
|
2070
2462
|
}
|
|
2463
|
+
list.items.push({
|
|
2464
|
+
type: "list_item",
|
|
2465
|
+
raw,
|
|
2466
|
+
task: !!istask,
|
|
2467
|
+
checked: ischecked,
|
|
2468
|
+
loose: false,
|
|
2469
|
+
text: itemContents
|
|
2470
|
+
});
|
|
2471
|
+
list.raw += raw;
|
|
2071
2472
|
}
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
} else {
|
|
2083
|
-
return " |";
|
|
2084
|
-
}
|
|
2085
|
-
}), cells = row.split(/ \|/);
|
|
2086
|
-
var i = 0;
|
|
2087
|
-
if (cells.length > count) {
|
|
2088
|
-
cells.splice(count);
|
|
2089
|
-
} else {
|
|
2090
|
-
while (cells.length < count) {
|
|
2091
|
-
cells.push("");
|
|
2473
|
+
list.items[list.items.length - 1].raw = raw.trimRight();
|
|
2474
|
+
list.items[list.items.length - 1].text = itemContents.trimRight();
|
|
2475
|
+
list.raw = list.raw.trimRight();
|
|
2476
|
+
const l = list.items.length;
|
|
2477
|
+
for (i = 0; i < l; i++) {
|
|
2478
|
+
this.lexer.state.top = false;
|
|
2479
|
+
list.items[i].tokens = this.lexer.blockTokens(list.items[i].text, []);
|
|
2480
|
+
if (!list.loose && list.items[i].tokens.some((t) => t.type === "space")) {
|
|
2481
|
+
list.loose = true;
|
|
2482
|
+
list.items[i].loose = true;
|
|
2092
2483
|
}
|
|
2093
2484
|
}
|
|
2094
|
-
|
|
2095
|
-
cells[i] = cells[i].trim().replace(/\\\|/g, "|");
|
|
2096
|
-
}
|
|
2097
|
-
return cells;
|
|
2485
|
+
return list;
|
|
2098
2486
|
}
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2487
|
+
}
|
|
2488
|
+
html(src) {
|
|
2489
|
+
const cap = this.rules.block.html.exec(src);
|
|
2490
|
+
if (cap) {
|
|
2491
|
+
const token = {
|
|
2492
|
+
type: "html",
|
|
2493
|
+
raw: cap[0],
|
|
2494
|
+
pre: !this.options.sanitizer && (cap[1] === "pre" || cap[1] === "script" || cap[1] === "style"),
|
|
2495
|
+
text: cap[0]
|
|
2496
|
+
};
|
|
2497
|
+
if (this.options.sanitize) {
|
|
2498
|
+
token.type = "paragraph";
|
|
2499
|
+
token.text = this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]);
|
|
2500
|
+
token.tokens = [];
|
|
2501
|
+
this.lexer.inline(token.text, token.tokens);
|
|
2114
2502
|
}
|
|
2115
|
-
return
|
|
2503
|
+
return token;
|
|
2504
|
+
}
|
|
2505
|
+
}
|
|
2506
|
+
def(src) {
|
|
2507
|
+
const cap = this.rules.block.def.exec(src);
|
|
2508
|
+
if (cap) {
|
|
2509
|
+
if (cap[3])
|
|
2510
|
+
cap[3] = cap[3].substring(1, cap[3].length - 1);
|
|
2511
|
+
const tag = cap[1].toLowerCase().replace(/\s+/g, " ");
|
|
2512
|
+
return {
|
|
2513
|
+
type: "def",
|
|
2514
|
+
tag,
|
|
2515
|
+
raw: cap[0],
|
|
2516
|
+
href: cap[2],
|
|
2517
|
+
title: cap[3]
|
|
2518
|
+
};
|
|
2116
2519
|
}
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2520
|
+
}
|
|
2521
|
+
table(src) {
|
|
2522
|
+
const cap = this.rules.block.table.exec(src);
|
|
2523
|
+
if (cap) {
|
|
2524
|
+
const item = {
|
|
2525
|
+
type: "table",
|
|
2526
|
+
header: splitCells(cap[1]).map((c) => {
|
|
2527
|
+
return { text: c };
|
|
2528
|
+
}),
|
|
2529
|
+
align: cap[2].replace(/^ *|\| *$/g, "").split(/ *\| */),
|
|
2530
|
+
rows: cap[3] ? cap[3].replace(/\n[ \t]*$/, "").split("\n") : []
|
|
2531
|
+
};
|
|
2532
|
+
if (item.header.length === item.align.length) {
|
|
2533
|
+
item.raw = cap[0];
|
|
2534
|
+
let l = item.align.length;
|
|
2535
|
+
let i, j, k, row;
|
|
2536
|
+
for (i = 0; i < l; i++) {
|
|
2537
|
+
if (/^ *-+: *$/.test(item.align[i])) {
|
|
2538
|
+
item.align[i] = "right";
|
|
2539
|
+
} else if (/^ *:-+: *$/.test(item.align[i])) {
|
|
2540
|
+
item.align[i] = "center";
|
|
2541
|
+
} else if (/^ *:-+ *$/.test(item.align[i])) {
|
|
2542
|
+
item.align[i] = "left";
|
|
2543
|
+
} else {
|
|
2544
|
+
item.align[i] = null;
|
|
2545
|
+
}
|
|
2546
|
+
}
|
|
2547
|
+
l = item.rows.length;
|
|
2548
|
+
for (i = 0; i < l; i++) {
|
|
2549
|
+
item.rows[i] = splitCells(item.rows[i], item.header.length).map((c) => {
|
|
2550
|
+
return { text: c };
|
|
2551
|
+
});
|
|
2552
|
+
}
|
|
2553
|
+
l = item.header.length;
|
|
2554
|
+
for (j = 0; j < l; j++) {
|
|
2555
|
+
item.header[j].tokens = [];
|
|
2556
|
+
this.lexer.inlineTokens(item.header[j].text, item.header[j].tokens);
|
|
2557
|
+
}
|
|
2558
|
+
l = item.rows.length;
|
|
2559
|
+
for (j = 0; j < l; j++) {
|
|
2560
|
+
row = item.rows[j];
|
|
2561
|
+
for (k = 0; k < row.length; k++) {
|
|
2562
|
+
row[k].tokens = [];
|
|
2563
|
+
this.lexer.inlineTokens(row[k].text, row[k].tokens);
|
|
2132
2564
|
}
|
|
2133
2565
|
}
|
|
2566
|
+
return item;
|
|
2134
2567
|
}
|
|
2135
|
-
return -1;
|
|
2136
2568
|
}
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2569
|
+
}
|
|
2570
|
+
lheading(src) {
|
|
2571
|
+
const cap = this.rules.block.lheading.exec(src);
|
|
2572
|
+
if (cap) {
|
|
2573
|
+
const token = {
|
|
2574
|
+
type: "heading",
|
|
2575
|
+
raw: cap[0],
|
|
2576
|
+
depth: cap[2].charAt(0) === "=" ? 1 : 2,
|
|
2577
|
+
text: cap[1],
|
|
2578
|
+
tokens: []
|
|
2579
|
+
};
|
|
2580
|
+
this.lexer.inline(token.text, token.tokens);
|
|
2581
|
+
return token;
|
|
2141
2582
|
}
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2583
|
+
}
|
|
2584
|
+
paragraph(src) {
|
|
2585
|
+
const cap = this.rules.block.paragraph.exec(src);
|
|
2586
|
+
if (cap) {
|
|
2587
|
+
const token = {
|
|
2588
|
+
type: "paragraph",
|
|
2589
|
+
raw: cap[0],
|
|
2590
|
+
text: cap[1].charAt(cap[1].length - 1) === "\n" ? cap[1].slice(0, -1) : cap[1],
|
|
2591
|
+
tokens: []
|
|
2592
|
+
};
|
|
2593
|
+
this.lexer.inline(token.text, token.tokens);
|
|
2594
|
+
return token;
|
|
2595
|
+
}
|
|
2596
|
+
}
|
|
2597
|
+
text(src) {
|
|
2598
|
+
const cap = this.rules.block.text.exec(src);
|
|
2599
|
+
if (cap) {
|
|
2600
|
+
const token = {
|
|
2601
|
+
type: "text",
|
|
2602
|
+
raw: cap[0],
|
|
2603
|
+
text: cap[0],
|
|
2604
|
+
tokens: []
|
|
2605
|
+
};
|
|
2606
|
+
this.lexer.inline(token.text, token.tokens);
|
|
2607
|
+
return token;
|
|
2608
|
+
}
|
|
2609
|
+
}
|
|
2610
|
+
escape(src) {
|
|
2611
|
+
const cap = this.rules.inline.escape.exec(src);
|
|
2612
|
+
if (cap) {
|
|
2613
|
+
return {
|
|
2614
|
+
type: "escape",
|
|
2615
|
+
raw: cap[0],
|
|
2616
|
+
text: escape(cap[1])
|
|
2617
|
+
};
|
|
2618
|
+
}
|
|
2619
|
+
}
|
|
2620
|
+
tag(src) {
|
|
2621
|
+
const cap = this.rules.inline.tag.exec(src);
|
|
2622
|
+
if (cap) {
|
|
2623
|
+
if (!this.lexer.state.inLink && /^<a /i.test(cap[0])) {
|
|
2624
|
+
this.lexer.state.inLink = true;
|
|
2625
|
+
} else if (this.lexer.state.inLink && /^<\/a>/i.test(cap[0])) {
|
|
2626
|
+
this.lexer.state.inLink = false;
|
|
2627
|
+
}
|
|
2628
|
+
if (!this.lexer.state.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
|
|
2629
|
+
this.lexer.state.inRawBlock = true;
|
|
2630
|
+
} else if (this.lexer.state.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
|
|
2631
|
+
this.lexer.state.inRawBlock = false;
|
|
2632
|
+
}
|
|
2633
|
+
return {
|
|
2634
|
+
type: this.options.sanitize ? "text" : "html",
|
|
2635
|
+
raw: cap[0],
|
|
2636
|
+
inLink: this.lexer.state.inLink,
|
|
2637
|
+
inRawBlock: this.lexer.state.inRawBlock,
|
|
2638
|
+
text: this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]) : cap[0]
|
|
2639
|
+
};
|
|
2640
|
+
}
|
|
2641
|
+
}
|
|
2642
|
+
link(src) {
|
|
2643
|
+
const cap = this.rules.inline.link.exec(src);
|
|
2644
|
+
if (cap) {
|
|
2645
|
+
const trimmedUrl = cap[2].trim();
|
|
2646
|
+
if (!this.options.pedantic && /^</.test(trimmedUrl)) {
|
|
2647
|
+
if (!/>$/.test(trimmedUrl)) {
|
|
2648
|
+
return;
|
|
2649
|
+
}
|
|
2650
|
+
const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), "\\");
|
|
2651
|
+
if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) {
|
|
2652
|
+
return;
|
|
2653
|
+
}
|
|
2654
|
+
} else {
|
|
2655
|
+
const lastParenIndex = findClosingBracket(cap[2], "()");
|
|
2656
|
+
if (lastParenIndex > -1) {
|
|
2657
|
+
const start = cap[0].indexOf("!") === 0 ? 5 : 4;
|
|
2658
|
+
const linkLen = start + cap[1].length + lastParenIndex;
|
|
2659
|
+
cap[2] = cap[2].substring(0, lastParenIndex);
|
|
2660
|
+
cap[0] = cap[0].substring(0, linkLen).trim();
|
|
2661
|
+
cap[3] = "";
|
|
2662
|
+
}
|
|
2663
|
+
}
|
|
2664
|
+
let href = cap[2];
|
|
2665
|
+
let title = "";
|
|
2666
|
+
if (this.options.pedantic) {
|
|
2667
|
+
const link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
|
|
2668
|
+
if (link) {
|
|
2669
|
+
href = link[1];
|
|
2670
|
+
title = link[3];
|
|
2671
|
+
}
|
|
2672
|
+
} else {
|
|
2673
|
+
title = cap[3] ? cap[3].slice(1, -1) : "";
|
|
2145
2674
|
}
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
if (
|
|
2149
|
-
|
|
2675
|
+
href = href.trim();
|
|
2676
|
+
if (/^</.test(href)) {
|
|
2677
|
+
if (this.options.pedantic && !/>$/.test(trimmedUrl)) {
|
|
2678
|
+
href = href.slice(1);
|
|
2679
|
+
} else {
|
|
2680
|
+
href = href.slice(1, -1);
|
|
2150
2681
|
}
|
|
2151
|
-
count >>= 1;
|
|
2152
|
-
pattern += pattern;
|
|
2153
2682
|
}
|
|
2154
|
-
return
|
|
2683
|
+
return outputLink(cap, {
|
|
2684
|
+
href: href ? href.replace(this.rules.inline._escapes, "$1") : href,
|
|
2685
|
+
title: title ? title.replace(this.rules.inline._escapes, "$1") : title
|
|
2686
|
+
}, cap[0], this.lexer);
|
|
2155
2687
|
}
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
splitCells: splitCells$1,
|
|
2165
|
-
rtrim: rtrim$1,
|
|
2166
|
-
findClosingBracket: findClosingBracket$1,
|
|
2167
|
-
checkSanitizeDeprecation: checkSanitizeDeprecation$1,
|
|
2168
|
-
repeatString: repeatString$1
|
|
2169
|
-
};
|
|
2170
|
-
var defaults$4 = defaults$5.exports.defaults;
|
|
2171
|
-
var rtrim = helpers.rtrim, splitCells = helpers.splitCells, _escape = helpers.escape, findClosingBracket = helpers.findClosingBracket;
|
|
2172
|
-
function outputLink(cap, link, raw) {
|
|
2173
|
-
var href = link.href;
|
|
2174
|
-
var title = link.title ? _escape(link.title) : null;
|
|
2175
|
-
var text = cap[1].replace(/\\([\[\]])/g, "$1");
|
|
2176
|
-
if (cap[0].charAt(0) !== "!") {
|
|
2688
|
+
}
|
|
2689
|
+
reflink(src, links) {
|
|
2690
|
+
let cap;
|
|
2691
|
+
if ((cap = this.rules.inline.reflink.exec(src)) || (cap = this.rules.inline.nolink.exec(src))) {
|
|
2692
|
+
let link = (cap[2] || cap[1]).replace(/\s+/g, " ");
|
|
2693
|
+
link = links[link.toLowerCase()];
|
|
2694
|
+
if (!link || !link.href) {
|
|
2695
|
+
const text = cap[0].charAt(0);
|
|
2177
2696
|
return {
|
|
2178
|
-
type: "
|
|
2179
|
-
raw,
|
|
2180
|
-
href,
|
|
2181
|
-
title,
|
|
2697
|
+
type: "text",
|
|
2698
|
+
raw: text,
|
|
2182
2699
|
text
|
|
2183
2700
|
};
|
|
2184
|
-
} else {
|
|
2185
|
-
return {
|
|
2186
|
-
type: "image",
|
|
2187
|
-
raw,
|
|
2188
|
-
href,
|
|
2189
|
-
title,
|
|
2190
|
-
text: _escape(text)
|
|
2191
|
-
};
|
|
2192
2701
|
}
|
|
2702
|
+
return outputLink(cap, link, cap[0], this.lexer);
|
|
2193
2703
|
}
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
return
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
if (cap[0].length > 1) {
|
|
2221
|
-
return {
|
|
2222
|
-
type: "space",
|
|
2223
|
-
raw: cap[0]
|
|
2224
|
-
};
|
|
2704
|
+
}
|
|
2705
|
+
emStrong(src, maskedSrc, prevChar = "") {
|
|
2706
|
+
let match = this.rules.inline.emStrong.lDelim.exec(src);
|
|
2707
|
+
if (!match)
|
|
2708
|
+
return;
|
|
2709
|
+
if (match[3] && prevChar.match(/[\p{L}\p{N}]/u))
|
|
2710
|
+
return;
|
|
2711
|
+
const nextChar = match[1] || match[2] || "";
|
|
2712
|
+
if (!nextChar || nextChar && (prevChar === "" || this.rules.inline.punctuation.exec(prevChar))) {
|
|
2713
|
+
const lLength = match[0].length - 1;
|
|
2714
|
+
let rDelim, rLength, delimTotal = lLength, midDelimTotal = 0;
|
|
2715
|
+
const endReg = match[0][0] === "*" ? this.rules.inline.emStrong.rDelimAst : this.rules.inline.emStrong.rDelimUnd;
|
|
2716
|
+
endReg.lastIndex = 0;
|
|
2717
|
+
maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
|
|
2718
|
+
while ((match = endReg.exec(maskedSrc)) != null) {
|
|
2719
|
+
rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
|
|
2720
|
+
if (!rDelim)
|
|
2721
|
+
continue;
|
|
2722
|
+
rLength = rDelim.length;
|
|
2723
|
+
if (match[3] || match[4]) {
|
|
2724
|
+
delimTotal += rLength;
|
|
2725
|
+
continue;
|
|
2726
|
+
} else if (match[5] || match[6]) {
|
|
2727
|
+
if (lLength % 3 && !((lLength + rLength) % 3)) {
|
|
2728
|
+
midDelimTotal += rLength;
|
|
2729
|
+
continue;
|
|
2225
2730
|
}
|
|
2226
|
-
return {
|
|
2227
|
-
raw: "\n"
|
|
2228
|
-
};
|
|
2229
2731
|
}
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2732
|
+
delimTotal -= rLength;
|
|
2733
|
+
if (delimTotal > 0)
|
|
2734
|
+
continue;
|
|
2735
|
+
rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
|
|
2736
|
+
if (Math.min(lLength, rLength) % 2) {
|
|
2737
|
+
const text2 = src.slice(1, lLength + match.index + rLength);
|
|
2235
2738
|
return {
|
|
2236
|
-
type: "
|
|
2237
|
-
raw:
|
|
2238
|
-
|
|
2239
|
-
|
|
2739
|
+
type: "em",
|
|
2740
|
+
raw: src.slice(0, lLength + match.index + rLength + 1),
|
|
2741
|
+
text: text2,
|
|
2742
|
+
tokens: this.lexer.inlineTokens(text2, [])
|
|
2240
2743
|
};
|
|
2241
2744
|
}
|
|
2745
|
+
const text = src.slice(2, lLength + match.index + rLength - 1);
|
|
2746
|
+
return {
|
|
2747
|
+
type: "strong",
|
|
2748
|
+
raw: src.slice(0, lLength + match.index + rLength + 1),
|
|
2749
|
+
text,
|
|
2750
|
+
tokens: this.lexer.inlineTokens(text, [])
|
|
2751
|
+
};
|
|
2752
|
+
}
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
2755
|
+
codespan(src) {
|
|
2756
|
+
const cap = this.rules.inline.code.exec(src);
|
|
2757
|
+
if (cap) {
|
|
2758
|
+
let text = cap[2].replace(/\n/g, " ");
|
|
2759
|
+
const hasNonSpaceChars = /[^ ]/.test(text);
|
|
2760
|
+
const hasSpaceCharsOnBothEnds = /^ /.test(text) && / $/.test(text);
|
|
2761
|
+
if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
|
|
2762
|
+
text = text.substring(1, text.length - 1);
|
|
2763
|
+
}
|
|
2764
|
+
text = escape(text, true);
|
|
2765
|
+
return {
|
|
2766
|
+
type: "codespan",
|
|
2767
|
+
raw: cap[0],
|
|
2768
|
+
text
|
|
2242
2769
|
};
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
lang: cap[2] ? cap[2].trim() : cap[2],
|
|
2252
|
-
text
|
|
2253
|
-
};
|
|
2254
|
-
}
|
|
2770
|
+
}
|
|
2771
|
+
}
|
|
2772
|
+
br(src) {
|
|
2773
|
+
const cap = this.rules.inline.br.exec(src);
|
|
2774
|
+
if (cap) {
|
|
2775
|
+
return {
|
|
2776
|
+
type: "br",
|
|
2777
|
+
raw: cap[0]
|
|
2255
2778
|
};
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
}
|
|
2267
|
-
}
|
|
2268
|
-
return {
|
|
2269
|
-
type: "heading",
|
|
2270
|
-
raw: cap[0],
|
|
2271
|
-
depth: cap[1].length,
|
|
2272
|
-
text
|
|
2273
|
-
};
|
|
2274
|
-
}
|
|
2779
|
+
}
|
|
2780
|
+
}
|
|
2781
|
+
del(src) {
|
|
2782
|
+
const cap = this.rules.inline.del.exec(src);
|
|
2783
|
+
if (cap) {
|
|
2784
|
+
return {
|
|
2785
|
+
type: "del",
|
|
2786
|
+
raw: cap[0],
|
|
2787
|
+
text: cap[2],
|
|
2788
|
+
tokens: this.lexer.inlineTokens(cap[2], [])
|
|
2275
2789
|
};
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
}
|
|
2300
|
-
l = item.cells.length;
|
|
2301
|
-
for (i = 0; i < l; i++) {
|
|
2302
|
-
item.cells[i] = splitCells(item.cells[i], item.header.length);
|
|
2303
|
-
}
|
|
2304
|
-
return item;
|
|
2790
|
+
}
|
|
2791
|
+
}
|
|
2792
|
+
autolink(src, mangle2) {
|
|
2793
|
+
const cap = this.rules.inline.autolink.exec(src);
|
|
2794
|
+
if (cap) {
|
|
2795
|
+
let text, href;
|
|
2796
|
+
if (cap[2] === "@") {
|
|
2797
|
+
text = escape(this.options.mangle ? mangle2(cap[1]) : cap[1]);
|
|
2798
|
+
href = "mailto:" + text;
|
|
2799
|
+
} else {
|
|
2800
|
+
text = escape(cap[1]);
|
|
2801
|
+
href = text;
|
|
2802
|
+
}
|
|
2803
|
+
return {
|
|
2804
|
+
type: "link",
|
|
2805
|
+
raw: cap[0],
|
|
2806
|
+
text,
|
|
2807
|
+
href,
|
|
2808
|
+
tokens: [
|
|
2809
|
+
{
|
|
2810
|
+
type: "text",
|
|
2811
|
+
raw: text,
|
|
2812
|
+
text
|
|
2305
2813
|
}
|
|
2306
|
-
|
|
2814
|
+
]
|
|
2307
2815
|
};
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2816
|
+
}
|
|
2817
|
+
}
|
|
2818
|
+
url(src, mangle2) {
|
|
2819
|
+
let cap;
|
|
2820
|
+
if (cap = this.rules.inline.url.exec(src)) {
|
|
2821
|
+
let text, href;
|
|
2822
|
+
if (cap[2] === "@") {
|
|
2823
|
+
text = escape(this.options.mangle ? mangle2(cap[0]) : cap[0]);
|
|
2824
|
+
href = "mailto:" + text;
|
|
2825
|
+
} else {
|
|
2826
|
+
let prevCapZero;
|
|
2827
|
+
do {
|
|
2828
|
+
prevCapZero = cap[0];
|
|
2829
|
+
cap[0] = this.rules.inline._backpedal.exec(cap[0])[0];
|
|
2830
|
+
} while (prevCapZero !== cap[0]);
|
|
2831
|
+
text = escape(cap[0]);
|
|
2832
|
+
if (cap[1] === "www.") {
|
|
2833
|
+
href = "http://" + text;
|
|
2834
|
+
} else {
|
|
2835
|
+
href = text;
|
|
2315
2836
|
}
|
|
2316
|
-
}
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2837
|
+
}
|
|
2838
|
+
return {
|
|
2839
|
+
type: "link",
|
|
2840
|
+
raw: cap[0],
|
|
2841
|
+
text,
|
|
2842
|
+
href,
|
|
2843
|
+
tokens: [
|
|
2844
|
+
{
|
|
2845
|
+
type: "text",
|
|
2846
|
+
raw: text,
|
|
2324
2847
|
text
|
|
2325
|
-
};
|
|
2326
|
-
}
|
|
2327
|
-
};
|
|
2328
|
-
_proto.list = function list(src) {
|
|
2329
|
-
var cap = this.rules.block.list.exec(src);
|
|
2330
|
-
if (cap) {
|
|
2331
|
-
var raw = cap[0];
|
|
2332
|
-
var bull = cap[2];
|
|
2333
|
-
var isordered = bull.length > 1;
|
|
2334
|
-
var list2 = {
|
|
2335
|
-
type: "list",
|
|
2336
|
-
raw,
|
|
2337
|
-
ordered: isordered,
|
|
2338
|
-
start: isordered ? +bull.slice(0, -1) : "",
|
|
2339
|
-
loose: false,
|
|
2340
|
-
items: []
|
|
2341
|
-
};
|
|
2342
|
-
var itemMatch = cap[0].match(this.rules.block.item);
|
|
2343
|
-
var next = false, item, space, bcurr, bnext, addBack, loose, istask, ischecked, endMatch;
|
|
2344
|
-
var l = itemMatch.length;
|
|
2345
|
-
bcurr = this.rules.block.listItemStart.exec(itemMatch[0]);
|
|
2346
|
-
for (var i = 0; i < l; i++) {
|
|
2347
|
-
item = itemMatch[i];
|
|
2348
|
-
raw = item;
|
|
2349
|
-
if (!this.options.pedantic) {
|
|
2350
|
-
endMatch = item.match(new RegExp("\\n\\s*\\n {0," + (bcurr[0].length - 1) + "}\\S"));
|
|
2351
|
-
if (endMatch) {
|
|
2352
|
-
addBack = item.length - endMatch.index + itemMatch.slice(i + 1).join("\n").length;
|
|
2353
|
-
list2.raw = list2.raw.substring(0, list2.raw.length - addBack);
|
|
2354
|
-
item = item.substring(0, endMatch.index);
|
|
2355
|
-
raw = item;
|
|
2356
|
-
l = i + 1;
|
|
2357
|
-
}
|
|
2358
|
-
}
|
|
2359
|
-
if (i !== l - 1) {
|
|
2360
|
-
bnext = this.rules.block.listItemStart.exec(itemMatch[i + 1]);
|
|
2361
|
-
if (!this.options.pedantic ? bnext[1].length >= bcurr[0].length || bnext[1].length > 3 : bnext[1].length > bcurr[1].length) {
|
|
2362
|
-
itemMatch.splice(i, 2, itemMatch[i] + (!this.options.pedantic && bnext[1].length < bcurr[0].length && !itemMatch[i].match(/\n$/) ? "" : "\n") + itemMatch[i + 1]);
|
|
2363
|
-
i--;
|
|
2364
|
-
l--;
|
|
2365
|
-
continue;
|
|
2366
|
-
} else if (!this.options.pedantic || this.options.smartLists ? bnext[2][bnext[2].length - 1] !== bull[bull.length - 1] : isordered === (bnext[2].length === 1)) {
|
|
2367
|
-
addBack = itemMatch.slice(i + 1).join("\n").length;
|
|
2368
|
-
list2.raw = list2.raw.substring(0, list2.raw.length - addBack);
|
|
2369
|
-
i = l - 1;
|
|
2370
|
-
}
|
|
2371
|
-
bcurr = bnext;
|
|
2372
|
-
}
|
|
2373
|
-
space = item.length;
|
|
2374
|
-
item = item.replace(/^ *([*+-]|\d+[.)]) ?/, "");
|
|
2375
|
-
if (~item.indexOf("\n ")) {
|
|
2376
|
-
space -= item.length;
|
|
2377
|
-
item = !this.options.pedantic ? item.replace(new RegExp("^ {1," + space + "}", "gm"), "") : item.replace(/^ {1,4}/gm, "");
|
|
2378
|
-
}
|
|
2379
|
-
item = rtrim(item, "\n");
|
|
2380
|
-
if (i !== l - 1) {
|
|
2381
|
-
raw = raw + "\n";
|
|
2382
|
-
}
|
|
2383
|
-
loose = next || /\n\n(?!\s*$)/.test(raw);
|
|
2384
|
-
if (i !== l - 1) {
|
|
2385
|
-
next = raw.slice(-2) === "\n\n";
|
|
2386
|
-
if (!loose)
|
|
2387
|
-
loose = next;
|
|
2388
|
-
}
|
|
2389
|
-
if (loose) {
|
|
2390
|
-
list2.loose = true;
|
|
2391
|
-
}
|
|
2392
|
-
if (this.options.gfm) {
|
|
2393
|
-
istask = /^\[[ xX]\] /.test(item);
|
|
2394
|
-
ischecked = void 0;
|
|
2395
|
-
if (istask) {
|
|
2396
|
-
ischecked = item[1] !== " ";
|
|
2397
|
-
item = item.replace(/^\[[ xX]\] +/, "");
|
|
2398
|
-
}
|
|
2399
|
-
}
|
|
2400
|
-
list2.items.push({
|
|
2401
|
-
type: "list_item",
|
|
2402
|
-
raw,
|
|
2403
|
-
task: istask,
|
|
2404
|
-
checked: ischecked,
|
|
2405
|
-
loose,
|
|
2406
|
-
text: item
|
|
2407
|
-
});
|
|
2408
2848
|
}
|
|
2409
|
-
|
|
2410
|
-
}
|
|
2849
|
+
]
|
|
2411
2850
|
};
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2851
|
+
}
|
|
2852
|
+
}
|
|
2853
|
+
inlineText(src, smartypants2) {
|
|
2854
|
+
const cap = this.rules.inline.text.exec(src);
|
|
2855
|
+
if (cap) {
|
|
2856
|
+
let text;
|
|
2857
|
+
if (this.lexer.state.inRawBlock) {
|
|
2858
|
+
text = this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]) : cap[0];
|
|
2859
|
+
} else {
|
|
2860
|
+
text = escape(this.options.smartypants ? smartypants2(cap[0]) : cap[0]);
|
|
2861
|
+
}
|
|
2862
|
+
return {
|
|
2863
|
+
type: "text",
|
|
2864
|
+
raw: cap[0],
|
|
2865
|
+
text
|
|
2422
2866
|
};
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2867
|
+
}
|
|
2868
|
+
}
|
|
2869
|
+
}
|
|
2870
|
+
const block = {
|
|
2871
|
+
newline: /^(?: *(?:\n|$))+/,
|
|
2872
|
+
code: /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,
|
|
2873
|
+
fences: /^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?=\n|$)|$)/,
|
|
2874
|
+
hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
|
|
2875
|
+
heading: /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,
|
|
2876
|
+
blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
|
|
2877
|
+
list: /^( {0,3}bull)( [^\n]+?)?(?:\n|$)/,
|
|
2878
|
+
html: "^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",
|
|
2879
|
+
def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
|
|
2880
|
+
table: noopTest,
|
|
2881
|
+
lheading: /^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
2882
|
+
_paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,
|
|
2883
|
+
text: /^[^\n]+/
|
|
2884
|
+
};
|
|
2885
|
+
block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/;
|
|
2886
|
+
block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
|
|
2887
|
+
block.def = edit(block.def).replace("label", block._label).replace("title", block._title).getRegex();
|
|
2888
|
+
block.bullet = /(?:[*+-]|\d{1,9}[.)])/;
|
|
2889
|
+
block.listItemStart = edit(/^( *)(bull) */).replace("bull", block.bullet).getRegex();
|
|
2890
|
+
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();
|
|
2891
|
+
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";
|
|
2892
|
+
block._comment = /<!--(?!-?>)[\s\S]*?(?:-->|$)/;
|
|
2893
|
+
block.html = edit(block.html, "i").replace("comment", block._comment).replace("tag", block._tag).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
|
|
2894
|
+
block.paragraph = edit(block._paragraph).replace("hr", block.hr).replace("heading", " {0,3}#{1,6} ").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", block._tag).getRegex();
|
|
2895
|
+
block.blockquote = edit(block.blockquote).replace("paragraph", block.paragraph).getRegex();
|
|
2896
|
+
block.normal = merge({}, block);
|
|
2897
|
+
block.gfm = merge({}, block.normal, {
|
|
2898
|
+
table: "^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"
|
|
2899
|
+
});
|
|
2900
|
+
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[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", block._tag).getRegex();
|
|
2901
|
+
block.gfm.paragraph = edit(block._paragraph).replace("hr", block.hr).replace("heading", " {0,3}#{1,6} ").replace("|lheading", "").replace("table", block.gfm.table).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", block._tag).getRegex();
|
|
2902
|
+
block.pedantic = merge({}, block.normal, {
|
|
2903
|
+
html: edit(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<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(),
|
|
2904
|
+
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
2905
|
+
heading: /^(#{1,6})(.*)(?:\n+|$)/,
|
|
2906
|
+
fences: noopTest,
|
|
2907
|
+
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()
|
|
2908
|
+
});
|
|
2909
|
+
const inline = {
|
|
2910
|
+
escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
|
|
2911
|
+
autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
|
|
2912
|
+
url: noopTest,
|
|
2913
|
+
tag: "^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",
|
|
2914
|
+
link: /^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,
|
|
2915
|
+
reflink: /^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,
|
|
2916
|
+
nolink: /^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,
|
|
2917
|
+
reflinkSearch: "reflink|nolink(?!\\()",
|
|
2918
|
+
emStrong: {
|
|
2919
|
+
lDelim: /^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,
|
|
2920
|
+
rDelimAst: /^[^_*]*?\_\_[^_*]*?\*[^_*]*?(?=\_\_)|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,
|
|
2921
|
+
rDelimUnd: /^[^_*]*?\*\*[^_*]*?\_[^_*]*?(?=\*\*)|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/
|
|
2922
|
+
},
|
|
2923
|
+
code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
|
|
2924
|
+
br: /^( {2,}|\\)\n(?!\s*$)/,
|
|
2925
|
+
del: noopTest,
|
|
2926
|
+
text: /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,
|
|
2927
|
+
punctuation: /^([\spunctuation])/
|
|
2928
|
+
};
|
|
2929
|
+
inline._punctuation = "!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~";
|
|
2930
|
+
inline.punctuation = edit(inline.punctuation).replace(/punctuation/g, inline._punctuation).getRegex();
|
|
2931
|
+
inline.blockSkip = /\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g;
|
|
2932
|
+
inline.escapedEmSt = /\\\*|\\_/g;
|
|
2933
|
+
inline._comment = edit(block._comment).replace("(?:-->|$)", "-->").getRegex();
|
|
2934
|
+
inline.emStrong.lDelim = edit(inline.emStrong.lDelim).replace(/punct/g, inline._punctuation).getRegex();
|
|
2935
|
+
inline.emStrong.rDelimAst = edit(inline.emStrong.rDelimAst, "g").replace(/punct/g, inline._punctuation).getRegex();
|
|
2936
|
+
inline.emStrong.rDelimUnd = edit(inline.emStrong.rDelimUnd, "g").replace(/punct/g, inline._punctuation).getRegex();
|
|
2937
|
+
inline._escapes = /\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;
|
|
2938
|
+
inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
|
|
2939
|
+
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])?)+(?![-_])/;
|
|
2940
|
+
inline.autolink = edit(inline.autolink).replace("scheme", inline._scheme).replace("email", inline._email).getRegex();
|
|
2941
|
+
inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
|
|
2942
|
+
inline.tag = edit(inline.tag).replace("comment", inline._comment).replace("attribute", inline._attribute).getRegex();
|
|
2943
|
+
inline._label = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
|
|
2944
|
+
inline._href = /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;
|
|
2945
|
+
inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
|
|
2946
|
+
inline.link = edit(inline.link).replace("label", inline._label).replace("href", inline._href).replace("title", inline._title).getRegex();
|
|
2947
|
+
inline.reflink = edit(inline.reflink).replace("label", inline._label).getRegex();
|
|
2948
|
+
inline.reflinkSearch = edit(inline.reflinkSearch, "g").replace("reflink", inline.reflink).replace("nolink", inline.nolink).getRegex();
|
|
2949
|
+
inline.normal = merge({}, inline);
|
|
2950
|
+
inline.pedantic = merge({}, inline.normal, {
|
|
2951
|
+
strong: {
|
|
2952
|
+
start: /^__|\*\*/,
|
|
2953
|
+
middle: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
|
|
2954
|
+
endAst: /\*\*(?!\*)/g,
|
|
2955
|
+
endUnd: /__(?!_)/g
|
|
2956
|
+
},
|
|
2957
|
+
em: {
|
|
2958
|
+
start: /^_|\*/,
|
|
2959
|
+
middle: /^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,
|
|
2960
|
+
endAst: /\*(?!\*)/g,
|
|
2961
|
+
endUnd: /_(?!_)/g
|
|
2962
|
+
},
|
|
2963
|
+
link: edit(/^!?\[(label)\]\((.*?)\)/).replace("label", inline._label).getRegex(),
|
|
2964
|
+
reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", inline._label).getRegex()
|
|
2965
|
+
});
|
|
2966
|
+
inline.gfm = merge({}, inline.normal, {
|
|
2967
|
+
escape: edit(inline.escape).replace("])", "~|])").getRegex(),
|
|
2968
|
+
_extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
|
|
2969
|
+
url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
|
|
2970
|
+
_backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
|
|
2971
|
+
del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
|
|
2972
|
+
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
|
|
2973
|
+
});
|
|
2974
|
+
inline.gfm.url = edit(inline.gfm.url, "i").replace("email", inline.gfm._extended_email).getRegex();
|
|
2975
|
+
inline.breaks = merge({}, inline.gfm, {
|
|
2976
|
+
br: edit(inline.br).replace("{2,}", "*").getRegex(),
|
|
2977
|
+
text: edit(inline.gfm.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
|
|
2978
|
+
});
|
|
2979
|
+
function smartypants(text) {
|
|
2980
|
+
return text.replace(/---/g, "\u2014").replace(/--/g, "\u2013").replace(/(^|[-\u2014/(\[{"\s])'/g, "$1\u2018").replace(/'/g, "\u2019").replace(/(^|[-\u2014/(\[{\u2018\s])"/g, "$1\u201C").replace(/"/g, "\u201D").replace(/\.{3}/g, "\u2026");
|
|
2981
|
+
}
|
|
2982
|
+
function mangle(text) {
|
|
2983
|
+
let out = "", i, ch;
|
|
2984
|
+
const l = text.length;
|
|
2985
|
+
for (i = 0; i < l; i++) {
|
|
2986
|
+
ch = text.charCodeAt(i);
|
|
2987
|
+
if (Math.random() > 0.5) {
|
|
2988
|
+
ch = "x" + ch.toString(16);
|
|
2989
|
+
}
|
|
2990
|
+
out += "&#" + ch + ";";
|
|
2991
|
+
}
|
|
2992
|
+
return out;
|
|
2993
|
+
}
|
|
2994
|
+
class Lexer {
|
|
2995
|
+
constructor(options) {
|
|
2996
|
+
this.tokens = [];
|
|
2997
|
+
this.tokens.links = Object.create(null);
|
|
2998
|
+
this.options = options || defaults;
|
|
2999
|
+
this.options.tokenizer = this.options.tokenizer || new Tokenizer();
|
|
3000
|
+
this.tokenizer = this.options.tokenizer;
|
|
3001
|
+
this.tokenizer.options = this.options;
|
|
3002
|
+
this.tokenizer.lexer = this;
|
|
3003
|
+
this.inlineQueue = [];
|
|
3004
|
+
this.state = {
|
|
3005
|
+
inLink: false,
|
|
3006
|
+
inRawBlock: false,
|
|
3007
|
+
top: true
|
|
3008
|
+
};
|
|
3009
|
+
const rules = {
|
|
3010
|
+
block: block.normal,
|
|
3011
|
+
inline: inline.normal
|
|
3012
|
+
};
|
|
3013
|
+
if (this.options.pedantic) {
|
|
3014
|
+
rules.block = block.pedantic;
|
|
3015
|
+
rules.inline = inline.pedantic;
|
|
3016
|
+
} else if (this.options.gfm) {
|
|
3017
|
+
rules.block = block.gfm;
|
|
3018
|
+
if (this.options.breaks) {
|
|
3019
|
+
rules.inline = inline.breaks;
|
|
3020
|
+
} else {
|
|
3021
|
+
rules.inline = inline.gfm;
|
|
3022
|
+
}
|
|
3023
|
+
}
|
|
3024
|
+
this.tokenizer.rules = rules;
|
|
3025
|
+
}
|
|
3026
|
+
static get rules() {
|
|
3027
|
+
return {
|
|
3028
|
+
block,
|
|
3029
|
+
inline
|
|
3030
|
+
};
|
|
3031
|
+
}
|
|
3032
|
+
static lex(src, options) {
|
|
3033
|
+
const lexer = new Lexer(options);
|
|
3034
|
+
return lexer.lex(src);
|
|
3035
|
+
}
|
|
3036
|
+
static lexInline(src, options) {
|
|
3037
|
+
const lexer = new Lexer(options);
|
|
3038
|
+
return lexer.inlineTokens(src);
|
|
3039
|
+
}
|
|
3040
|
+
lex(src) {
|
|
3041
|
+
src = src.replace(/\r\n|\r/g, "\n").replace(/\t/g, " ");
|
|
3042
|
+
this.blockTokens(src, this.tokens);
|
|
3043
|
+
let next;
|
|
3044
|
+
while (next = this.inlineQueue.shift()) {
|
|
3045
|
+
this.inlineTokens(next.src, next.tokens);
|
|
3046
|
+
}
|
|
3047
|
+
return this.tokens;
|
|
3048
|
+
}
|
|
3049
|
+
blockTokens(src, tokens = []) {
|
|
3050
|
+
if (this.options.pedantic) {
|
|
3051
|
+
src = src.replace(/^ +$/gm, "");
|
|
3052
|
+
}
|
|
3053
|
+
let token, lastToken, cutSrc, lastParagraphClipped;
|
|
3054
|
+
while (src) {
|
|
3055
|
+
if (this.options.extensions && this.options.extensions.block && this.options.extensions.block.some((extTokenizer) => {
|
|
3056
|
+
if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
|
|
3057
|
+
src = src.substring(token.raw.length);
|
|
3058
|
+
tokens.push(token);
|
|
3059
|
+
return true;
|
|
3060
|
+
}
|
|
3061
|
+
return false;
|
|
3062
|
+
})) {
|
|
3063
|
+
continue;
|
|
3064
|
+
}
|
|
3065
|
+
if (token = this.tokenizer.space(src)) {
|
|
3066
|
+
src = src.substring(token.raw.length);
|
|
3067
|
+
if (token.type) {
|
|
3068
|
+
tokens.push(token);
|
|
2436
3069
|
}
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
item.raw = cap[0];
|
|
2449
|
-
var l = item.align.length;
|
|
2450
|
-
var i;
|
|
2451
|
-
for (i = 0; i < l; i++) {
|
|
2452
|
-
if (/^ *-+: *$/.test(item.align[i])) {
|
|
2453
|
-
item.align[i] = "right";
|
|
2454
|
-
} else if (/^ *:-+: *$/.test(item.align[i])) {
|
|
2455
|
-
item.align[i] = "center";
|
|
2456
|
-
} else if (/^ *:-+ *$/.test(item.align[i])) {
|
|
2457
|
-
item.align[i] = "left";
|
|
2458
|
-
} else {
|
|
2459
|
-
item.align[i] = null;
|
|
2460
|
-
}
|
|
2461
|
-
}
|
|
2462
|
-
l = item.cells.length;
|
|
2463
|
-
for (i = 0; i < l; i++) {
|
|
2464
|
-
item.cells[i] = splitCells(item.cells[i].replace(/^ *\| *| *\| *$/g, ""), item.header.length);
|
|
2465
|
-
}
|
|
2466
|
-
return item;
|
|
2467
|
-
}
|
|
3070
|
+
continue;
|
|
3071
|
+
}
|
|
3072
|
+
if (token = this.tokenizer.code(src)) {
|
|
3073
|
+
src = src.substring(token.raw.length);
|
|
3074
|
+
lastToken = tokens[tokens.length - 1];
|
|
3075
|
+
if (lastToken && (lastToken.type === "paragraph" || lastToken.type === "text")) {
|
|
3076
|
+
lastToken.raw += "\n" + token.raw;
|
|
3077
|
+
lastToken.text += "\n" + token.text;
|
|
3078
|
+
this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
|
|
3079
|
+
} else {
|
|
3080
|
+
tokens.push(token);
|
|
2468
3081
|
}
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
3082
|
+
continue;
|
|
3083
|
+
}
|
|
3084
|
+
if (token = this.tokenizer.fences(src)) {
|
|
3085
|
+
src = src.substring(token.raw.length);
|
|
3086
|
+
tokens.push(token);
|
|
3087
|
+
continue;
|
|
3088
|
+
}
|
|
3089
|
+
if (token = this.tokenizer.heading(src)) {
|
|
3090
|
+
src = src.substring(token.raw.length);
|
|
3091
|
+
tokens.push(token);
|
|
3092
|
+
continue;
|
|
3093
|
+
}
|
|
3094
|
+
if (token = this.tokenizer.hr(src)) {
|
|
3095
|
+
src = src.substring(token.raw.length);
|
|
3096
|
+
tokens.push(token);
|
|
3097
|
+
continue;
|
|
3098
|
+
}
|
|
3099
|
+
if (token = this.tokenizer.blockquote(src)) {
|
|
3100
|
+
src = src.substring(token.raw.length);
|
|
3101
|
+
tokens.push(token);
|
|
3102
|
+
continue;
|
|
3103
|
+
}
|
|
3104
|
+
if (token = this.tokenizer.list(src)) {
|
|
3105
|
+
src = src.substring(token.raw.length);
|
|
3106
|
+
tokens.push(token);
|
|
3107
|
+
continue;
|
|
3108
|
+
}
|
|
3109
|
+
if (token = this.tokenizer.html(src)) {
|
|
3110
|
+
src = src.substring(token.raw.length);
|
|
3111
|
+
tokens.push(token);
|
|
3112
|
+
continue;
|
|
3113
|
+
}
|
|
3114
|
+
if (token = this.tokenizer.def(src)) {
|
|
3115
|
+
src = src.substring(token.raw.length);
|
|
3116
|
+
lastToken = tokens[tokens.length - 1];
|
|
3117
|
+
if (lastToken && (lastToken.type === "paragraph" || lastToken.type === "text")) {
|
|
3118
|
+
lastToken.raw += "\n" + token.raw;
|
|
3119
|
+
lastToken.text += "\n" + token.raw;
|
|
3120
|
+
this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
|
|
3121
|
+
} else if (!this.tokens.links[token.tag]) {
|
|
3122
|
+
this.tokens.links[token.tag] = {
|
|
3123
|
+
href: token.href,
|
|
3124
|
+
title: token.title
|
|
2478
3125
|
};
|
|
2479
3126
|
}
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
3127
|
+
continue;
|
|
3128
|
+
}
|
|
3129
|
+
if (token = this.tokenizer.table(src)) {
|
|
3130
|
+
src = src.substring(token.raw.length);
|
|
3131
|
+
tokens.push(token);
|
|
3132
|
+
continue;
|
|
3133
|
+
}
|
|
3134
|
+
if (token = this.tokenizer.lheading(src)) {
|
|
3135
|
+
src = src.substring(token.raw.length);
|
|
3136
|
+
tokens.push(token);
|
|
3137
|
+
continue;
|
|
3138
|
+
}
|
|
3139
|
+
cutSrc = src;
|
|
3140
|
+
if (this.options.extensions && this.options.extensions.startBlock) {
|
|
3141
|
+
let startIndex = Infinity;
|
|
3142
|
+
const tempSrc = src.slice(1);
|
|
3143
|
+
let tempStart;
|
|
3144
|
+
this.options.extensions.startBlock.forEach(function(getStartIndex) {
|
|
3145
|
+
tempStart = getStartIndex.call({ lexer: this }, tempSrc);
|
|
3146
|
+
if (typeof tempStart === "number" && tempStart >= 0) {
|
|
3147
|
+
startIndex = Math.min(startIndex, tempStart);
|
|
3148
|
+
}
|
|
3149
|
+
});
|
|
3150
|
+
if (startIndex < Infinity && startIndex >= 0) {
|
|
3151
|
+
cutSrc = src.substring(0, startIndex + 1);
|
|
2489
3152
|
}
|
|
2490
|
-
}
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
if (
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
3153
|
+
}
|
|
3154
|
+
if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
|
|
3155
|
+
lastToken = tokens[tokens.length - 1];
|
|
3156
|
+
if (lastParagraphClipped && lastToken.type === "paragraph") {
|
|
3157
|
+
lastToken.raw += "\n" + token.raw;
|
|
3158
|
+
lastToken.text += "\n" + token.text;
|
|
3159
|
+
this.inlineQueue.pop();
|
|
3160
|
+
this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
|
|
3161
|
+
} else {
|
|
3162
|
+
tokens.push(token);
|
|
2499
3163
|
}
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
3164
|
+
lastParagraphClipped = cutSrc.length !== src.length;
|
|
3165
|
+
src = src.substring(token.raw.length);
|
|
3166
|
+
continue;
|
|
3167
|
+
}
|
|
3168
|
+
if (token = this.tokenizer.text(src)) {
|
|
3169
|
+
src = src.substring(token.raw.length);
|
|
3170
|
+
lastToken = tokens[tokens.length - 1];
|
|
3171
|
+
if (lastToken && lastToken.type === "text") {
|
|
3172
|
+
lastToken.raw += "\n" + token.raw;
|
|
3173
|
+
lastToken.text += "\n" + token.text;
|
|
3174
|
+
this.inlineQueue.pop();
|
|
3175
|
+
this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
|
|
3176
|
+
} else {
|
|
3177
|
+
tokens.push(token);
|
|
2509
3178
|
}
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
if (!inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
|
|
2520
|
-
inRawBlock = true;
|
|
2521
|
-
} else if (inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
|
|
2522
|
-
inRawBlock = false;
|
|
2523
|
-
}
|
|
2524
|
-
return {
|
|
2525
|
-
type: this.options.sanitize ? "text" : "html",
|
|
2526
|
-
raw: cap[0],
|
|
2527
|
-
inLink,
|
|
2528
|
-
inRawBlock,
|
|
2529
|
-
text: this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : _escape(cap[0]) : cap[0]
|
|
2530
|
-
};
|
|
3179
|
+
continue;
|
|
3180
|
+
}
|
|
3181
|
+
if (src) {
|
|
3182
|
+
const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
|
|
3183
|
+
if (this.options.silent) {
|
|
3184
|
+
console.error(errMsg);
|
|
3185
|
+
break;
|
|
3186
|
+
} else {
|
|
3187
|
+
throw new Error(errMsg);
|
|
2531
3188
|
}
|
|
2532
|
-
}
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
cap[0] = cap[0].substring(0, linkLen).trim();
|
|
2552
|
-
cap[3] = "";
|
|
2553
|
-
}
|
|
2554
|
-
}
|
|
2555
|
-
var href = cap[2];
|
|
2556
|
-
var title = "";
|
|
2557
|
-
if (this.options.pedantic) {
|
|
2558
|
-
var link2 = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
|
|
2559
|
-
if (link2) {
|
|
2560
|
-
href = link2[1];
|
|
2561
|
-
title = link2[3];
|
|
2562
|
-
}
|
|
2563
|
-
} else {
|
|
2564
|
-
title = cap[3] ? cap[3].slice(1, -1) : "";
|
|
2565
|
-
}
|
|
2566
|
-
href = href.trim();
|
|
2567
|
-
if (/^</.test(href)) {
|
|
2568
|
-
if (this.options.pedantic && !/>$/.test(trimmedUrl)) {
|
|
2569
|
-
href = href.slice(1);
|
|
2570
|
-
} else {
|
|
2571
|
-
href = href.slice(1, -1);
|
|
2572
|
-
}
|
|
3189
|
+
}
|
|
3190
|
+
}
|
|
3191
|
+
this.state.top = true;
|
|
3192
|
+
return tokens;
|
|
3193
|
+
}
|
|
3194
|
+
inline(src, tokens) {
|
|
3195
|
+
this.inlineQueue.push({ src, tokens });
|
|
3196
|
+
}
|
|
3197
|
+
inlineTokens(src, tokens = []) {
|
|
3198
|
+
let token, lastToken, cutSrc;
|
|
3199
|
+
let maskedSrc = src;
|
|
3200
|
+
let match;
|
|
3201
|
+
let keepPrevChar, prevChar;
|
|
3202
|
+
if (this.tokens.links) {
|
|
3203
|
+
const links = Object.keys(this.tokens.links);
|
|
3204
|
+
if (links.length > 0) {
|
|
3205
|
+
while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
|
|
3206
|
+
if (links.includes(match[0].slice(match[0].lastIndexOf("[") + 1, -1))) {
|
|
3207
|
+
maskedSrc = maskedSrc.slice(0, match.index) + "[" + repeatString("a", match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
|
|
2573
3208
|
}
|
|
2574
|
-
return outputLink(cap, {
|
|
2575
|
-
href: href ? href.replace(this.rules.inline._escapes, "$1") : href,
|
|
2576
|
-
title: title ? title.replace(this.rules.inline._escapes, "$1") : title
|
|
2577
|
-
}, cap[0]);
|
|
2578
3209
|
}
|
|
2579
|
-
}
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
3210
|
+
}
|
|
3211
|
+
}
|
|
3212
|
+
while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
|
|
3213
|
+
maskedSrc = maskedSrc.slice(0, match.index) + "[" + repeatString("a", match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
|
|
3214
|
+
}
|
|
3215
|
+
while ((match = this.tokenizer.rules.inline.escapedEmSt.exec(maskedSrc)) != null) {
|
|
3216
|
+
maskedSrc = maskedSrc.slice(0, match.index) + "++" + maskedSrc.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex);
|
|
3217
|
+
}
|
|
3218
|
+
while (src) {
|
|
3219
|
+
if (!keepPrevChar) {
|
|
3220
|
+
prevChar = "";
|
|
3221
|
+
}
|
|
3222
|
+
keepPrevChar = false;
|
|
3223
|
+
if (this.options.extensions && this.options.extensions.inline && this.options.extensions.inline.some((extTokenizer) => {
|
|
3224
|
+
if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
|
|
3225
|
+
src = src.substring(token.raw.length);
|
|
3226
|
+
tokens.push(token);
|
|
3227
|
+
return true;
|
|
3228
|
+
}
|
|
3229
|
+
return false;
|
|
3230
|
+
})) {
|
|
3231
|
+
continue;
|
|
3232
|
+
}
|
|
3233
|
+
if (token = this.tokenizer.escape(src)) {
|
|
3234
|
+
src = src.substring(token.raw.length);
|
|
3235
|
+
tokens.push(token);
|
|
3236
|
+
continue;
|
|
3237
|
+
}
|
|
3238
|
+
if (token = this.tokenizer.tag(src)) {
|
|
3239
|
+
src = src.substring(token.raw.length);
|
|
3240
|
+
lastToken = tokens[tokens.length - 1];
|
|
3241
|
+
if (lastToken && token.type === "text" && lastToken.type === "text") {
|
|
3242
|
+
lastToken.raw += token.raw;
|
|
3243
|
+
lastToken.text += token.text;
|
|
3244
|
+
} else {
|
|
3245
|
+
tokens.push(token);
|
|
2594
3246
|
}
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
3247
|
+
continue;
|
|
3248
|
+
}
|
|
3249
|
+
if (token = this.tokenizer.link(src)) {
|
|
3250
|
+
src = src.substring(token.raw.length);
|
|
3251
|
+
tokens.push(token);
|
|
3252
|
+
continue;
|
|
3253
|
+
}
|
|
3254
|
+
if (token = this.tokenizer.reflink(src, this.tokens.links)) {
|
|
3255
|
+
src = src.substring(token.raw.length);
|
|
3256
|
+
lastToken = tokens[tokens.length - 1];
|
|
3257
|
+
if (lastToken && token.type === "text" && lastToken.type === "text") {
|
|
3258
|
+
lastToken.raw += token.raw;
|
|
3259
|
+
lastToken.text += token.text;
|
|
3260
|
+
} else {
|
|
3261
|
+
tokens.push(token);
|
|
2599
3262
|
}
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
};
|
|
3263
|
+
continue;
|
|
3264
|
+
}
|
|
3265
|
+
if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) {
|
|
3266
|
+
src = src.substring(token.raw.length);
|
|
3267
|
+
tokens.push(token);
|
|
3268
|
+
continue;
|
|
3269
|
+
}
|
|
3270
|
+
if (token = this.tokenizer.codespan(src)) {
|
|
3271
|
+
src = src.substring(token.raw.length);
|
|
3272
|
+
tokens.push(token);
|
|
3273
|
+
continue;
|
|
3274
|
+
}
|
|
3275
|
+
if (token = this.tokenizer.br(src)) {
|
|
3276
|
+
src = src.substring(token.raw.length);
|
|
3277
|
+
tokens.push(token);
|
|
3278
|
+
continue;
|
|
3279
|
+
}
|
|
3280
|
+
if (token = this.tokenizer.del(src)) {
|
|
3281
|
+
src = src.substring(token.raw.length);
|
|
3282
|
+
tokens.push(token);
|
|
3283
|
+
continue;
|
|
3284
|
+
}
|
|
3285
|
+
if (token = this.tokenizer.autolink(src, mangle)) {
|
|
3286
|
+
src = src.substring(token.raw.length);
|
|
3287
|
+
tokens.push(token);
|
|
3288
|
+
continue;
|
|
3289
|
+
}
|
|
3290
|
+
if (!this.state.inLink && (token = this.tokenizer.url(src, mangle))) {
|
|
3291
|
+
src = src.substring(token.raw.length);
|
|
3292
|
+
tokens.push(token);
|
|
3293
|
+
continue;
|
|
3294
|
+
}
|
|
3295
|
+
cutSrc = src;
|
|
3296
|
+
if (this.options.extensions && this.options.extensions.startInline) {
|
|
3297
|
+
let startIndex = Infinity;
|
|
3298
|
+
const tempSrc = src.slice(1);
|
|
3299
|
+
let tempStart;
|
|
3300
|
+
this.options.extensions.startInline.forEach(function(getStartIndex) {
|
|
3301
|
+
tempStart = getStartIndex.call({ lexer: this }, tempSrc);
|
|
3302
|
+
if (typeof tempStart === "number" && tempStart >= 0) {
|
|
3303
|
+
startIndex = Math.min(startIndex, tempStart);
|
|
2642
3304
|
}
|
|
3305
|
+
});
|
|
3306
|
+
if (startIndex < Infinity && startIndex >= 0) {
|
|
3307
|
+
cutSrc = src.substring(0, startIndex + 1);
|
|
2643
3308
|
}
|
|
2644
|
-
}
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
if (
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
text
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
raw: cap[0],
|
|
2658
|
-
text
|
|
2659
|
-
};
|
|
3309
|
+
}
|
|
3310
|
+
if (token = this.tokenizer.inlineText(cutSrc, smartypants)) {
|
|
3311
|
+
src = src.substring(token.raw.length);
|
|
3312
|
+
if (token.raw.slice(-1) !== "_") {
|
|
3313
|
+
prevChar = token.raw.slice(-1);
|
|
3314
|
+
}
|
|
3315
|
+
keepPrevChar = true;
|
|
3316
|
+
lastToken = tokens[tokens.length - 1];
|
|
3317
|
+
if (lastToken && lastToken.type === "text") {
|
|
3318
|
+
lastToken.raw += token.raw;
|
|
3319
|
+
lastToken.text += token.text;
|
|
3320
|
+
} else {
|
|
3321
|
+
tokens.push(token);
|
|
2660
3322
|
}
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
3323
|
+
continue;
|
|
3324
|
+
}
|
|
3325
|
+
if (src) {
|
|
3326
|
+
const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
|
|
3327
|
+
if (this.options.silent) {
|
|
3328
|
+
console.error(errMsg);
|
|
3329
|
+
break;
|
|
3330
|
+
} else {
|
|
3331
|
+
throw new Error(errMsg);
|
|
2669
3332
|
}
|
|
2670
|
-
}
|
|
2671
|
-
_proto.del = function del(src) {
|
|
2672
|
-
var cap = this.rules.inline.del.exec(src);
|
|
2673
|
-
if (cap) {
|
|
2674
|
-
return {
|
|
2675
|
-
type: "del",
|
|
2676
|
-
raw: cap[0],
|
|
2677
|
-
text: cap[2]
|
|
2678
|
-
};
|
|
2679
|
-
}
|
|
2680
|
-
};
|
|
2681
|
-
_proto.autolink = function autolink(src, mangle2) {
|
|
2682
|
-
var cap = this.rules.inline.autolink.exec(src);
|
|
2683
|
-
if (cap) {
|
|
2684
|
-
var text, href;
|
|
2685
|
-
if (cap[2] === "@") {
|
|
2686
|
-
text = _escape(this.options.mangle ? mangle2(cap[1]) : cap[1]);
|
|
2687
|
-
href = "mailto:" + text;
|
|
2688
|
-
} else {
|
|
2689
|
-
text = _escape(cap[1]);
|
|
2690
|
-
href = text;
|
|
2691
|
-
}
|
|
2692
|
-
return {
|
|
2693
|
-
type: "link",
|
|
2694
|
-
raw: cap[0],
|
|
2695
|
-
text,
|
|
2696
|
-
href,
|
|
2697
|
-
tokens: [{
|
|
2698
|
-
type: "text",
|
|
2699
|
-
raw: text,
|
|
2700
|
-
text
|
|
2701
|
-
}]
|
|
2702
|
-
};
|
|
2703
|
-
}
|
|
2704
|
-
};
|
|
2705
|
-
_proto.url = function url(src, mangle2) {
|
|
2706
|
-
var cap;
|
|
2707
|
-
if (cap = this.rules.inline.url.exec(src)) {
|
|
2708
|
-
var text, href;
|
|
2709
|
-
if (cap[2] === "@") {
|
|
2710
|
-
text = _escape(this.options.mangle ? mangle2(cap[0]) : cap[0]);
|
|
2711
|
-
href = "mailto:" + text;
|
|
2712
|
-
} else {
|
|
2713
|
-
var prevCapZero;
|
|
2714
|
-
do {
|
|
2715
|
-
prevCapZero = cap[0];
|
|
2716
|
-
cap[0] = this.rules.inline._backpedal.exec(cap[0])[0];
|
|
2717
|
-
} while (prevCapZero !== cap[0]);
|
|
2718
|
-
text = _escape(cap[0]);
|
|
2719
|
-
if (cap[1] === "www.") {
|
|
2720
|
-
href = "http://" + text;
|
|
2721
|
-
} else {
|
|
2722
|
-
href = text;
|
|
2723
|
-
}
|
|
2724
|
-
}
|
|
2725
|
-
return {
|
|
2726
|
-
type: "link",
|
|
2727
|
-
raw: cap[0],
|
|
2728
|
-
text,
|
|
2729
|
-
href,
|
|
2730
|
-
tokens: [{
|
|
2731
|
-
type: "text",
|
|
2732
|
-
raw: text,
|
|
2733
|
-
text
|
|
2734
|
-
}]
|
|
2735
|
-
};
|
|
2736
|
-
}
|
|
2737
|
-
};
|
|
2738
|
-
_proto.inlineText = function inlineText(src, inRawBlock, smartypants2) {
|
|
2739
|
-
var cap = this.rules.inline.text.exec(src);
|
|
2740
|
-
if (cap) {
|
|
2741
|
-
var text;
|
|
2742
|
-
if (inRawBlock) {
|
|
2743
|
-
text = this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : _escape(cap[0]) : cap[0];
|
|
2744
|
-
} else {
|
|
2745
|
-
text = _escape(this.options.smartypants ? smartypants2(cap[0]) : cap[0]);
|
|
2746
|
-
}
|
|
2747
|
-
return {
|
|
2748
|
-
type: "text",
|
|
2749
|
-
raw: cap[0],
|
|
2750
|
-
text
|
|
2751
|
-
};
|
|
2752
|
-
}
|
|
2753
|
-
};
|
|
2754
|
-
return Tokenizer2;
|
|
2755
|
-
}();
|
|
2756
|
-
var noopTest = helpers.noopTest, edit = helpers.edit, merge$1 = helpers.merge;
|
|
2757
|
-
var block$1 = {
|
|
2758
|
-
newline: /^(?: *(?:\n|$))+/,
|
|
2759
|
-
code: /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,
|
|
2760
|
-
fences: /^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,
|
|
2761
|
-
hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
|
|
2762
|
-
heading: /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,
|
|
2763
|
-
blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
|
|
2764
|
-
list: /^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?! {0,3}bull )\n*|\s*$)/,
|
|
2765
|
-
html: "^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",
|
|
2766
|
-
def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
|
|
2767
|
-
nptable: noopTest,
|
|
2768
|
-
table: noopTest,
|
|
2769
|
-
lheading: /^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
2770
|
-
_paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html| +\n)[^\n]+)*)/,
|
|
2771
|
-
text: /^[^\n]+/
|
|
2772
|
-
};
|
|
2773
|
-
block$1._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/;
|
|
2774
|
-
block$1._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
|
|
2775
|
-
block$1.def = edit(block$1.def).replace("label", block$1._label).replace("title", block$1._title).getRegex();
|
|
2776
|
-
block$1.bullet = /(?:[*+-]|\d{1,9}[.)])/;
|
|
2777
|
-
block$1.item = /^( *)(bull) ?[^\n]*(?:\n(?! *bull ?)[^\n]*)*/;
|
|
2778
|
-
block$1.item = edit(block$1.item, "gm").replace(/bull/g, block$1.bullet).getRegex();
|
|
2779
|
-
block$1.listItemStart = edit(/^( *)(bull) */).replace("bull", block$1.bullet).getRegex();
|
|
2780
|
-
block$1.list = edit(block$1.list).replace(/bull/g, block$1.bullet).replace("hr", "\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def", "\\n+(?=" + block$1.def.source + ")").getRegex();
|
|
2781
|
-
block$1._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";
|
|
2782
|
-
block$1._comment = /<!--(?!-?>)[\s\S]*?(?:-->|$)/;
|
|
2783
|
-
block$1.html = edit(block$1.html, "i").replace("comment", block$1._comment).replace("tag", block$1._tag).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
|
|
2784
|
-
block$1.paragraph = edit(block$1._paragraph).replace("hr", block$1.hr).replace("heading", " {0,3}#{1,6} ").replace("|lheading", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", block$1._tag).getRegex();
|
|
2785
|
-
block$1.blockquote = edit(block$1.blockquote).replace("paragraph", block$1.paragraph).getRegex();
|
|
2786
|
-
block$1.normal = merge$1({}, block$1);
|
|
2787
|
-
block$1.gfm = merge$1({}, block$1.normal, {
|
|
2788
|
-
nptable: "^ *([^|\\n ].*\\|.*)\\n {0,3}([-:]+ *\\|[-| :]*)(?:\\n((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)",
|
|
2789
|
-
table: "^ *\\|(.+)\\n {0,3}\\|?( *[-:]+[-| :]*)(?:\\n *((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"
|
|
2790
|
-
});
|
|
2791
|
-
block$1.gfm.nptable = edit(block$1.gfm.nptable).replace("hr", block$1.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[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", block$1._tag).getRegex();
|
|
2792
|
-
block$1.gfm.table = edit(block$1.gfm.table).replace("hr", block$1.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[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", block$1._tag).getRegex();
|
|
2793
|
-
block$1.pedantic = merge$1({}, block$1.normal, {
|
|
2794
|
-
html: edit(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", block$1._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(),
|
|
2795
|
-
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
2796
|
-
heading: /^(#{1,6})(.*)(?:\n+|$)/,
|
|
2797
|
-
fences: noopTest,
|
|
2798
|
-
paragraph: edit(block$1.normal._paragraph).replace("hr", block$1.hr).replace("heading", " *#{1,6} *[^\n]").replace("lheading", block$1.lheading).replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").getRegex()
|
|
2799
|
-
});
|
|
2800
|
-
var inline$1 = {
|
|
2801
|
-
escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
|
|
2802
|
-
autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
|
|
2803
|
-
url: noopTest,
|
|
2804
|
-
tag: "^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",
|
|
2805
|
-
link: /^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,
|
|
2806
|
-
reflink: /^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,
|
|
2807
|
-
nolink: /^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,
|
|
2808
|
-
reflinkSearch: "reflink|nolink(?!\\()",
|
|
2809
|
-
emStrong: {
|
|
2810
|
-
lDelim: /^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,
|
|
2811
|
-
rDelimAst: /\_\_[^_*]*?\*[^_*]*?\_\_|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,
|
|
2812
|
-
rDelimUnd: /\*\*[^_*]*?\_[^_*]*?\*\*|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/
|
|
2813
|
-
},
|
|
2814
|
-
code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
|
|
2815
|
-
br: /^( {2,}|\\)\n(?!\s*$)/,
|
|
2816
|
-
del: noopTest,
|
|
2817
|
-
text: /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,
|
|
2818
|
-
punctuation: /^([\spunctuation])/
|
|
2819
|
-
};
|
|
2820
|
-
inline$1._punctuation = "!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~";
|
|
2821
|
-
inline$1.punctuation = edit(inline$1.punctuation).replace(/punctuation/g, inline$1._punctuation).getRegex();
|
|
2822
|
-
inline$1.blockSkip = /\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g;
|
|
2823
|
-
inline$1.escapedEmSt = /\\\*|\\_/g;
|
|
2824
|
-
inline$1._comment = edit(block$1._comment).replace("(?:-->|$)", "-->").getRegex();
|
|
2825
|
-
inline$1.emStrong.lDelim = edit(inline$1.emStrong.lDelim).replace(/punct/g, inline$1._punctuation).getRegex();
|
|
2826
|
-
inline$1.emStrong.rDelimAst = edit(inline$1.emStrong.rDelimAst, "g").replace(/punct/g, inline$1._punctuation).getRegex();
|
|
2827
|
-
inline$1.emStrong.rDelimUnd = edit(inline$1.emStrong.rDelimUnd, "g").replace(/punct/g, inline$1._punctuation).getRegex();
|
|
2828
|
-
inline$1._escapes = /\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;
|
|
2829
|
-
inline$1._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
|
|
2830
|
-
inline$1._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])?)+(?![-_])/;
|
|
2831
|
-
inline$1.autolink = edit(inline$1.autolink).replace("scheme", inline$1._scheme).replace("email", inline$1._email).getRegex();
|
|
2832
|
-
inline$1._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
|
|
2833
|
-
inline$1.tag = edit(inline$1.tag).replace("comment", inline$1._comment).replace("attribute", inline$1._attribute).getRegex();
|
|
2834
|
-
inline$1._label = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
|
|
2835
|
-
inline$1._href = /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;
|
|
2836
|
-
inline$1._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
|
|
2837
|
-
inline$1.link = edit(inline$1.link).replace("label", inline$1._label).replace("href", inline$1._href).replace("title", inline$1._title).getRegex();
|
|
2838
|
-
inline$1.reflink = edit(inline$1.reflink).replace("label", inline$1._label).getRegex();
|
|
2839
|
-
inline$1.reflinkSearch = edit(inline$1.reflinkSearch, "g").replace("reflink", inline$1.reflink).replace("nolink", inline$1.nolink).getRegex();
|
|
2840
|
-
inline$1.normal = merge$1({}, inline$1);
|
|
2841
|
-
inline$1.pedantic = merge$1({}, inline$1.normal, {
|
|
2842
|
-
strong: {
|
|
2843
|
-
start: /^__|\*\*/,
|
|
2844
|
-
middle: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
|
|
2845
|
-
endAst: /\*\*(?!\*)/g,
|
|
2846
|
-
endUnd: /__(?!_)/g
|
|
2847
|
-
},
|
|
2848
|
-
em: {
|
|
2849
|
-
start: /^_|\*/,
|
|
2850
|
-
middle: /^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,
|
|
2851
|
-
endAst: /\*(?!\*)/g,
|
|
2852
|
-
endUnd: /_(?!_)/g
|
|
2853
|
-
},
|
|
2854
|
-
link: edit(/^!?\[(label)\]\((.*?)\)/).replace("label", inline$1._label).getRegex(),
|
|
2855
|
-
reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", inline$1._label).getRegex()
|
|
2856
|
-
});
|
|
2857
|
-
inline$1.gfm = merge$1({}, inline$1.normal, {
|
|
2858
|
-
escape: edit(inline$1.escape).replace("])", "~|])").getRegex(),
|
|
2859
|
-
_extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
|
|
2860
|
-
url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
|
|
2861
|
-
_backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
|
|
2862
|
-
del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
|
|
2863
|
-
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
|
|
2864
|
-
});
|
|
2865
|
-
inline$1.gfm.url = edit(inline$1.gfm.url, "i").replace("email", inline$1.gfm._extended_email).getRegex();
|
|
2866
|
-
inline$1.breaks = merge$1({}, inline$1.gfm, {
|
|
2867
|
-
br: edit(inline$1.br).replace("{2,}", "*").getRegex(),
|
|
2868
|
-
text: edit(inline$1.gfm.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
|
|
2869
|
-
});
|
|
2870
|
-
var rules = {
|
|
2871
|
-
block: block$1,
|
|
2872
|
-
inline: inline$1
|
|
2873
|
-
};
|
|
2874
|
-
var Tokenizer$1 = Tokenizer_1;
|
|
2875
|
-
var defaults$3 = defaults$5.exports.defaults;
|
|
2876
|
-
var block = rules.block, inline = rules.inline;
|
|
2877
|
-
var repeatString = helpers.repeatString;
|
|
2878
|
-
function smartypants(text) {
|
|
2879
|
-
return text.replace(/---/g, "\u2014").replace(/--/g, "\u2013").replace(/(^|[-\u2014/(\[{"\s])'/g, "$1\u2018").replace(/'/g, "\u2019").replace(/(^|[-\u2014/(\[{\u2018\s])"/g, "$1\u201C").replace(/"/g, "\u201D").replace(/\.{3}/g, "\u2026");
|
|
3333
|
+
}
|
|
2880
3334
|
}
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
3335
|
+
return tokens;
|
|
3336
|
+
}
|
|
3337
|
+
}
|
|
3338
|
+
class Renderer {
|
|
3339
|
+
constructor(options) {
|
|
3340
|
+
this.options = options || defaults;
|
|
3341
|
+
}
|
|
3342
|
+
code(code, infostring, escaped) {
|
|
3343
|
+
const lang = (infostring || "").match(/\S*/)[0];
|
|
3344
|
+
if (this.options.highlight) {
|
|
3345
|
+
const out = this.options.highlight(code, lang);
|
|
3346
|
+
if (out != null && out !== code) {
|
|
3347
|
+
escaped = true;
|
|
3348
|
+
code = out;
|
|
2890
3349
|
}
|
|
2891
|
-
return out;
|
|
2892
3350
|
}
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
3351
|
+
code = code.replace(/\n$/, "") + "\n";
|
|
3352
|
+
if (!lang) {
|
|
3353
|
+
return "<pre><code>" + (escaped ? code : escape(code, true)) + "</code></pre>\n";
|
|
3354
|
+
}
|
|
3355
|
+
return '<pre><code class="' + this.options.langPrefix + escape(lang, true) + '">' + (escaped ? code : escape(code, true)) + "</code></pre>\n";
|
|
3356
|
+
}
|
|
3357
|
+
blockquote(quote) {
|
|
3358
|
+
return "<blockquote>\n" + quote + "</blockquote>\n";
|
|
3359
|
+
}
|
|
3360
|
+
html(html) {
|
|
3361
|
+
return html;
|
|
3362
|
+
}
|
|
3363
|
+
heading(text, level, raw, slugger) {
|
|
3364
|
+
if (this.options.headerIds) {
|
|
3365
|
+
return "<h" + level + ' id="' + this.options.headerPrefix + slugger.slug(raw) + '">' + text + "</h" + level + ">\n";
|
|
3366
|
+
}
|
|
3367
|
+
return "<h" + level + ">" + text + "</h" + level + ">\n";
|
|
3368
|
+
}
|
|
3369
|
+
hr() {
|
|
3370
|
+
return this.options.xhtml ? "<hr/>\n" : "<hr>\n";
|
|
3371
|
+
}
|
|
3372
|
+
list(body, ordered, start) {
|
|
3373
|
+
const type = ordered ? "ol" : "ul", startatt = ordered && start !== 1 ? ' start="' + start + '"' : "";
|
|
3374
|
+
return "<" + type + startatt + ">\n" + body + "</" + type + ">\n";
|
|
3375
|
+
}
|
|
3376
|
+
listitem(text) {
|
|
3377
|
+
return "<li>" + text + "</li>\n";
|
|
3378
|
+
}
|
|
3379
|
+
checkbox(checked) {
|
|
3380
|
+
return "<input " + (checked ? 'checked="" ' : "") + 'disabled="" type="checkbox"' + (this.options.xhtml ? " /" : "") + "> ";
|
|
3381
|
+
}
|
|
3382
|
+
paragraph(text) {
|
|
3383
|
+
return "<p>" + text + "</p>\n";
|
|
3384
|
+
}
|
|
3385
|
+
table(header, body) {
|
|
3386
|
+
if (body)
|
|
3387
|
+
body = "<tbody>" + body + "</tbody>";
|
|
3388
|
+
return "<table>\n<thead>\n" + header + "</thead>\n" + body + "</table>\n";
|
|
3389
|
+
}
|
|
3390
|
+
tablerow(content) {
|
|
3391
|
+
return "<tr>\n" + content + "</tr>\n";
|
|
3392
|
+
}
|
|
3393
|
+
tablecell(content, flags) {
|
|
3394
|
+
const type = flags.header ? "th" : "td";
|
|
3395
|
+
const tag = flags.align ? "<" + type + ' align="' + flags.align + '">' : "<" + type + ">";
|
|
3396
|
+
return tag + content + "</" + type + ">\n";
|
|
3397
|
+
}
|
|
3398
|
+
strong(text) {
|
|
3399
|
+
return "<strong>" + text + "</strong>";
|
|
3400
|
+
}
|
|
3401
|
+
em(text) {
|
|
3402
|
+
return "<em>" + text + "</em>";
|
|
3403
|
+
}
|
|
3404
|
+
codespan(text) {
|
|
3405
|
+
return "<code>" + text + "</code>";
|
|
3406
|
+
}
|
|
3407
|
+
br() {
|
|
3408
|
+
return this.options.xhtml ? "<br/>" : "<br>";
|
|
3409
|
+
}
|
|
3410
|
+
del(text) {
|
|
3411
|
+
return "<del>" + text + "</del>";
|
|
3412
|
+
}
|
|
3413
|
+
link(href, title, text) {
|
|
3414
|
+
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
|
3415
|
+
if (href === null) {
|
|
3416
|
+
return text;
|
|
3417
|
+
}
|
|
3418
|
+
let out = '<a href="' + escape(href) + '"';
|
|
3419
|
+
if (title) {
|
|
3420
|
+
out += ' title="' + title + '"';
|
|
3421
|
+
}
|
|
3422
|
+
out += ">" + text + "</a>";
|
|
3423
|
+
return out;
|
|
3424
|
+
}
|
|
3425
|
+
image(href, title, text) {
|
|
3426
|
+
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
|
3427
|
+
if (href === null) {
|
|
3428
|
+
return text;
|
|
3429
|
+
}
|
|
3430
|
+
let out = '<img src="' + href + '" alt="' + text + '"';
|
|
3431
|
+
if (title) {
|
|
3432
|
+
out += ' title="' + title + '"';
|
|
3433
|
+
}
|
|
3434
|
+
out += this.options.xhtml ? "/>" : ">";
|
|
3435
|
+
return out;
|
|
3436
|
+
}
|
|
3437
|
+
text(text) {
|
|
3438
|
+
return text;
|
|
3439
|
+
}
|
|
3440
|
+
}
|
|
3441
|
+
class TextRenderer {
|
|
3442
|
+
strong(text) {
|
|
3443
|
+
return text;
|
|
3444
|
+
}
|
|
3445
|
+
em(text) {
|
|
3446
|
+
return text;
|
|
3447
|
+
}
|
|
3448
|
+
codespan(text) {
|
|
3449
|
+
return text;
|
|
3450
|
+
}
|
|
3451
|
+
del(text) {
|
|
3452
|
+
return text;
|
|
3453
|
+
}
|
|
3454
|
+
html(text) {
|
|
3455
|
+
return text;
|
|
3456
|
+
}
|
|
3457
|
+
text(text) {
|
|
3458
|
+
return text;
|
|
3459
|
+
}
|
|
3460
|
+
link(href, title, text) {
|
|
3461
|
+
return "" + text;
|
|
3462
|
+
}
|
|
3463
|
+
image(href, title, text) {
|
|
3464
|
+
return "" + text;
|
|
3465
|
+
}
|
|
3466
|
+
br() {
|
|
3467
|
+
return "";
|
|
3468
|
+
}
|
|
3469
|
+
}
|
|
3470
|
+
class Slugger {
|
|
3471
|
+
constructor() {
|
|
3472
|
+
this.seen = {};
|
|
3473
|
+
}
|
|
3474
|
+
serialize(value) {
|
|
3475
|
+
return value.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig, "").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, "").replace(/\s/g, "-");
|
|
3476
|
+
}
|
|
3477
|
+
getNextSafeSlug(originalSlug, isDryRun) {
|
|
3478
|
+
let slug = originalSlug;
|
|
3479
|
+
let occurenceAccumulator = 0;
|
|
3480
|
+
if (this.seen.hasOwnProperty(slug)) {
|
|
3481
|
+
occurenceAccumulator = this.seen[originalSlug];
|
|
3482
|
+
do {
|
|
3483
|
+
occurenceAccumulator++;
|
|
3484
|
+
slug = originalSlug + "-" + occurenceAccumulator;
|
|
3485
|
+
} while (this.seen.hasOwnProperty(slug));
|
|
3486
|
+
}
|
|
3487
|
+
if (!isDryRun) {
|
|
3488
|
+
this.seen[originalSlug] = occurenceAccumulator;
|
|
3489
|
+
this.seen[slug] = 0;
|
|
3490
|
+
}
|
|
3491
|
+
return slug;
|
|
3492
|
+
}
|
|
3493
|
+
slug(value, options = {}) {
|
|
3494
|
+
const slug = this.serialize(value);
|
|
3495
|
+
return this.getNextSafeSlug(slug, options.dryrun);
|
|
3496
|
+
}
|
|
3497
|
+
}
|
|
3498
|
+
class Parser {
|
|
3499
|
+
constructor(options) {
|
|
3500
|
+
this.options = options || defaults;
|
|
3501
|
+
this.options.renderer = this.options.renderer || new Renderer();
|
|
3502
|
+
this.renderer = this.options.renderer;
|
|
3503
|
+
this.renderer.options = this.options;
|
|
3504
|
+
this.textRenderer = new TextRenderer();
|
|
3505
|
+
this.slugger = new Slugger();
|
|
3506
|
+
}
|
|
3507
|
+
static parse(tokens, options) {
|
|
3508
|
+
const parser = new Parser(options);
|
|
3509
|
+
return parser.parse(tokens);
|
|
3510
|
+
}
|
|
3511
|
+
static parseInline(tokens, options) {
|
|
3512
|
+
const parser = new Parser(options);
|
|
3513
|
+
return parser.parseInline(tokens);
|
|
3514
|
+
}
|
|
3515
|
+
parse(tokens, top = true) {
|
|
3516
|
+
let out = "", i, j, k, l2, l3, row, cell, header, body, token, ordered, start, loose, itemBody, item, checked, task, checkbox, ret;
|
|
3517
|
+
const l = tokens.length;
|
|
3518
|
+
for (i = 0; i < l; i++) {
|
|
3519
|
+
token = tokens[i];
|
|
3520
|
+
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
|
|
3521
|
+
ret = this.options.extensions.renderers[token.type].call({ parser: this }, token);
|
|
3522
|
+
if (ret !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(token.type)) {
|
|
3523
|
+
out += ret || "";
|
|
3524
|
+
continue;
|
|
2915
3525
|
}
|
|
2916
|
-
this.tokenizer.rules = rules2;
|
|
2917
3526
|
}
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
};
|
|
2922
|
-
Lexer2.lexInline = function lexInline(src, options) {
|
|
2923
|
-
var lexer = new Lexer2(options);
|
|
2924
|
-
return lexer.inlineTokens(src);
|
|
2925
|
-
};
|
|
2926
|
-
var _proto = Lexer2.prototype;
|
|
2927
|
-
_proto.lex = function lex(src) {
|
|
2928
|
-
src = src.replace(/\r\n|\r/g, "\n").replace(/\t/g, " ");
|
|
2929
|
-
this.blockTokens(src, this.tokens, true);
|
|
2930
|
-
this.inline(this.tokens);
|
|
2931
|
-
return this.tokens;
|
|
2932
|
-
};
|
|
2933
|
-
_proto.blockTokens = function blockTokens(src, tokens, top) {
|
|
2934
|
-
var _this = this;
|
|
2935
|
-
if (tokens === void 0) {
|
|
2936
|
-
tokens = [];
|
|
2937
|
-
}
|
|
2938
|
-
if (top === void 0) {
|
|
2939
|
-
top = true;
|
|
2940
|
-
}
|
|
2941
|
-
if (this.options.pedantic) {
|
|
2942
|
-
src = src.replace(/^ +$/gm, "");
|
|
2943
|
-
}
|
|
2944
|
-
var token, i, l, lastToken, cutSrc, lastParagraphClipped;
|
|
2945
|
-
while (src) {
|
|
2946
|
-
if (this.options.extensions && this.options.extensions.block && this.options.extensions.block.some(function(extTokenizer) {
|
|
2947
|
-
if (token = extTokenizer.call(_this, src, tokens)) {
|
|
2948
|
-
src = src.substring(token.raw.length);
|
|
2949
|
-
tokens.push(token);
|
|
2950
|
-
return true;
|
|
2951
|
-
}
|
|
2952
|
-
return false;
|
|
2953
|
-
})) {
|
|
2954
|
-
continue;
|
|
2955
|
-
}
|
|
2956
|
-
if (token = this.tokenizer.space(src)) {
|
|
2957
|
-
src = src.substring(token.raw.length);
|
|
2958
|
-
if (token.type) {
|
|
2959
|
-
tokens.push(token);
|
|
2960
|
-
}
|
|
2961
|
-
continue;
|
|
2962
|
-
}
|
|
2963
|
-
if (token = this.tokenizer.code(src)) {
|
|
2964
|
-
src = src.substring(token.raw.length);
|
|
2965
|
-
lastToken = tokens[tokens.length - 1];
|
|
2966
|
-
if (lastToken && lastToken.type === "paragraph") {
|
|
2967
|
-
lastToken.raw += "\n" + token.raw;
|
|
2968
|
-
lastToken.text += "\n" + token.text;
|
|
2969
|
-
} else {
|
|
2970
|
-
tokens.push(token);
|
|
2971
|
-
}
|
|
2972
|
-
continue;
|
|
2973
|
-
}
|
|
2974
|
-
if (token = this.tokenizer.fences(src)) {
|
|
2975
|
-
src = src.substring(token.raw.length);
|
|
2976
|
-
tokens.push(token);
|
|
2977
|
-
continue;
|
|
2978
|
-
}
|
|
2979
|
-
if (token = this.tokenizer.heading(src)) {
|
|
2980
|
-
src = src.substring(token.raw.length);
|
|
2981
|
-
tokens.push(token);
|
|
2982
|
-
continue;
|
|
2983
|
-
}
|
|
2984
|
-
if (token = this.tokenizer.nptable(src)) {
|
|
2985
|
-
src = src.substring(token.raw.length);
|
|
2986
|
-
tokens.push(token);
|
|
2987
|
-
continue;
|
|
2988
|
-
}
|
|
2989
|
-
if (token = this.tokenizer.hr(src)) {
|
|
2990
|
-
src = src.substring(token.raw.length);
|
|
2991
|
-
tokens.push(token);
|
|
2992
|
-
continue;
|
|
2993
|
-
}
|
|
2994
|
-
if (token = this.tokenizer.blockquote(src)) {
|
|
2995
|
-
src = src.substring(token.raw.length);
|
|
2996
|
-
token.tokens = this.blockTokens(token.text, [], top);
|
|
2997
|
-
tokens.push(token);
|
|
2998
|
-
continue;
|
|
2999
|
-
}
|
|
3000
|
-
if (token = this.tokenizer.list(src)) {
|
|
3001
|
-
src = src.substring(token.raw.length);
|
|
3002
|
-
l = token.items.length;
|
|
3003
|
-
for (i = 0; i < l; i++) {
|
|
3004
|
-
token.items[i].tokens = this.blockTokens(token.items[i].text, [], false);
|
|
3005
|
-
}
|
|
3006
|
-
tokens.push(token);
|
|
3007
|
-
continue;
|
|
3008
|
-
}
|
|
3009
|
-
if (token = this.tokenizer.html(src)) {
|
|
3010
|
-
src = src.substring(token.raw.length);
|
|
3011
|
-
tokens.push(token);
|
|
3012
|
-
continue;
|
|
3013
|
-
}
|
|
3014
|
-
if (top && (token = this.tokenizer.def(src))) {
|
|
3015
|
-
src = src.substring(token.raw.length);
|
|
3016
|
-
if (!this.tokens.links[token.tag]) {
|
|
3017
|
-
this.tokens.links[token.tag] = {
|
|
3018
|
-
href: token.href,
|
|
3019
|
-
title: token.title
|
|
3020
|
-
};
|
|
3021
|
-
}
|
|
3022
|
-
continue;
|
|
3023
|
-
}
|
|
3024
|
-
if (token = this.tokenizer.table(src)) {
|
|
3025
|
-
src = src.substring(token.raw.length);
|
|
3026
|
-
tokens.push(token);
|
|
3027
|
-
continue;
|
|
3028
|
-
}
|
|
3029
|
-
if (token = this.tokenizer.lheading(src)) {
|
|
3030
|
-
src = src.substring(token.raw.length);
|
|
3031
|
-
tokens.push(token);
|
|
3032
|
-
continue;
|
|
3033
|
-
}
|
|
3034
|
-
cutSrc = src;
|
|
3035
|
-
if (this.options.extensions && this.options.extensions.startBlock) {
|
|
3036
|
-
(function() {
|
|
3037
|
-
var startIndex = Infinity;
|
|
3038
|
-
var tempSrc = src.slice(1);
|
|
3039
|
-
var tempStart = void 0;
|
|
3040
|
-
_this.options.extensions.startBlock.forEach(function(getStartIndex) {
|
|
3041
|
-
tempStart = getStartIndex.call(this, tempSrc);
|
|
3042
|
-
if (typeof tempStart === "number" && tempStart >= 0) {
|
|
3043
|
-
startIndex = Math.min(startIndex, tempStart);
|
|
3044
|
-
}
|
|
3045
|
-
});
|
|
3046
|
-
if (startIndex < Infinity && startIndex >= 0) {
|
|
3047
|
-
cutSrc = src.substring(0, startIndex + 1);
|
|
3048
|
-
}
|
|
3049
|
-
})();
|
|
3050
|
-
}
|
|
3051
|
-
if (top && (token = this.tokenizer.paragraph(cutSrc))) {
|
|
3052
|
-
lastToken = tokens[tokens.length - 1];
|
|
3053
|
-
if (lastParagraphClipped && lastToken.type === "paragraph") {
|
|
3054
|
-
lastToken.raw += "\n" + token.raw;
|
|
3055
|
-
lastToken.text += "\n" + token.text;
|
|
3056
|
-
} else {
|
|
3057
|
-
tokens.push(token);
|
|
3058
|
-
}
|
|
3059
|
-
lastParagraphClipped = cutSrc.length !== src.length;
|
|
3060
|
-
src = src.substring(token.raw.length);
|
|
3061
|
-
continue;
|
|
3062
|
-
}
|
|
3063
|
-
if (token = this.tokenizer.text(src)) {
|
|
3064
|
-
src = src.substring(token.raw.length);
|
|
3065
|
-
lastToken = tokens[tokens.length - 1];
|
|
3066
|
-
if (lastToken && lastToken.type === "text") {
|
|
3067
|
-
lastToken.raw += "\n" + token.raw;
|
|
3068
|
-
lastToken.text += "\n" + token.text;
|
|
3069
|
-
} else {
|
|
3070
|
-
tokens.push(token);
|
|
3071
|
-
}
|
|
3072
|
-
continue;
|
|
3073
|
-
}
|
|
3074
|
-
if (src) {
|
|
3075
|
-
var errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
|
|
3076
|
-
if (this.options.silent) {
|
|
3077
|
-
console.error(errMsg);
|
|
3078
|
-
break;
|
|
3079
|
-
} else {
|
|
3080
|
-
throw new Error(errMsg);
|
|
3081
|
-
}
|
|
3082
|
-
}
|
|
3083
|
-
}
|
|
3084
|
-
return tokens;
|
|
3085
|
-
};
|
|
3086
|
-
_proto.inline = function inline2(tokens) {
|
|
3087
|
-
var i, j, k, l2, row, token;
|
|
3088
|
-
var l = tokens.length;
|
|
3089
|
-
for (i = 0; i < l; i++) {
|
|
3090
|
-
token = tokens[i];
|
|
3091
|
-
switch (token.type) {
|
|
3092
|
-
case "paragraph":
|
|
3093
|
-
case "text":
|
|
3094
|
-
case "heading": {
|
|
3095
|
-
token.tokens = [];
|
|
3096
|
-
this.inlineTokens(token.text, token.tokens);
|
|
3097
|
-
break;
|
|
3098
|
-
}
|
|
3099
|
-
case "table": {
|
|
3100
|
-
token.tokens = {
|
|
3101
|
-
header: [],
|
|
3102
|
-
cells: []
|
|
3103
|
-
};
|
|
3104
|
-
l2 = token.header.length;
|
|
3105
|
-
for (j = 0; j < l2; j++) {
|
|
3106
|
-
token.tokens.header[j] = [];
|
|
3107
|
-
this.inlineTokens(token.header[j], token.tokens.header[j]);
|
|
3108
|
-
}
|
|
3109
|
-
l2 = token.cells.length;
|
|
3110
|
-
for (j = 0; j < l2; j++) {
|
|
3111
|
-
row = token.cells[j];
|
|
3112
|
-
token.tokens.cells[j] = [];
|
|
3113
|
-
for (k = 0; k < row.length; k++) {
|
|
3114
|
-
token.tokens.cells[j][k] = [];
|
|
3115
|
-
this.inlineTokens(row[k], token.tokens.cells[j][k]);
|
|
3116
|
-
}
|
|
3117
|
-
}
|
|
3118
|
-
break;
|
|
3119
|
-
}
|
|
3120
|
-
case "blockquote": {
|
|
3121
|
-
this.inline(token.tokens);
|
|
3122
|
-
break;
|
|
3123
|
-
}
|
|
3124
|
-
case "list": {
|
|
3125
|
-
l2 = token.items.length;
|
|
3126
|
-
for (j = 0; j < l2; j++) {
|
|
3127
|
-
this.inline(token.items[j].tokens);
|
|
3128
|
-
}
|
|
3129
|
-
break;
|
|
3130
|
-
}
|
|
3131
|
-
}
|
|
3132
|
-
}
|
|
3133
|
-
return tokens;
|
|
3134
|
-
};
|
|
3135
|
-
_proto.inlineTokens = function inlineTokens(src, tokens, inLink, inRawBlock) {
|
|
3136
|
-
var _this2 = this;
|
|
3137
|
-
if (tokens === void 0) {
|
|
3138
|
-
tokens = [];
|
|
3139
|
-
}
|
|
3140
|
-
if (inLink === void 0) {
|
|
3141
|
-
inLink = false;
|
|
3142
|
-
}
|
|
3143
|
-
if (inRawBlock === void 0) {
|
|
3144
|
-
inRawBlock = false;
|
|
3145
|
-
}
|
|
3146
|
-
var token, lastToken, cutSrc;
|
|
3147
|
-
var maskedSrc = src;
|
|
3148
|
-
var match;
|
|
3149
|
-
var keepPrevChar, prevChar;
|
|
3150
|
-
if (this.tokens.links) {
|
|
3151
|
-
var links = Object.keys(this.tokens.links);
|
|
3152
|
-
if (links.length > 0) {
|
|
3153
|
-
while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
|
|
3154
|
-
if (links.includes(match[0].slice(match[0].lastIndexOf("[") + 1, -1))) {
|
|
3155
|
-
maskedSrc = maskedSrc.slice(0, match.index) + "[" + repeatString("a", match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
|
|
3156
|
-
}
|
|
3157
|
-
}
|
|
3158
|
-
}
|
|
3159
|
-
}
|
|
3160
|
-
while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
|
|
3161
|
-
maskedSrc = maskedSrc.slice(0, match.index) + "[" + repeatString("a", match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
|
|
3162
|
-
}
|
|
3163
|
-
while ((match = this.tokenizer.rules.inline.escapedEmSt.exec(maskedSrc)) != null) {
|
|
3164
|
-
maskedSrc = maskedSrc.slice(0, match.index) + "++" + maskedSrc.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex);
|
|
3527
|
+
switch (token.type) {
|
|
3528
|
+
case "space": {
|
|
3529
|
+
continue;
|
|
3165
3530
|
}
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
}
|
|
3170
|
-
keepPrevChar = false;
|
|
3171
|
-
if (this.options.extensions && this.options.extensions.inline && this.options.extensions.inline.some(function(extTokenizer) {
|
|
3172
|
-
if (token = extTokenizer.call(_this2, src, tokens)) {
|
|
3173
|
-
src = src.substring(token.raw.length);
|
|
3174
|
-
tokens.push(token);
|
|
3175
|
-
return true;
|
|
3176
|
-
}
|
|
3177
|
-
return false;
|
|
3178
|
-
})) {
|
|
3179
|
-
continue;
|
|
3180
|
-
}
|
|
3181
|
-
if (token = this.tokenizer.escape(src)) {
|
|
3182
|
-
src = src.substring(token.raw.length);
|
|
3183
|
-
tokens.push(token);
|
|
3184
|
-
continue;
|
|
3185
|
-
}
|
|
3186
|
-
if (token = this.tokenizer.tag(src, inLink, inRawBlock)) {
|
|
3187
|
-
src = src.substring(token.raw.length);
|
|
3188
|
-
inLink = token.inLink;
|
|
3189
|
-
inRawBlock = token.inRawBlock;
|
|
3190
|
-
lastToken = tokens[tokens.length - 1];
|
|
3191
|
-
if (lastToken && token.type === "text" && lastToken.type === "text") {
|
|
3192
|
-
lastToken.raw += token.raw;
|
|
3193
|
-
lastToken.text += token.text;
|
|
3194
|
-
} else {
|
|
3195
|
-
tokens.push(token);
|
|
3196
|
-
}
|
|
3197
|
-
continue;
|
|
3198
|
-
}
|
|
3199
|
-
if (token = this.tokenizer.link(src)) {
|
|
3200
|
-
src = src.substring(token.raw.length);
|
|
3201
|
-
if (token.type === "link") {
|
|
3202
|
-
token.tokens = this.inlineTokens(token.text, [], true, inRawBlock);
|
|
3203
|
-
}
|
|
3204
|
-
tokens.push(token);
|
|
3205
|
-
continue;
|
|
3206
|
-
}
|
|
3207
|
-
if (token = this.tokenizer.reflink(src, this.tokens.links)) {
|
|
3208
|
-
src = src.substring(token.raw.length);
|
|
3209
|
-
lastToken = tokens[tokens.length - 1];
|
|
3210
|
-
if (token.type === "link") {
|
|
3211
|
-
token.tokens = this.inlineTokens(token.text, [], true, inRawBlock);
|
|
3212
|
-
tokens.push(token);
|
|
3213
|
-
} else if (lastToken && token.type === "text" && lastToken.type === "text") {
|
|
3214
|
-
lastToken.raw += token.raw;
|
|
3215
|
-
lastToken.text += token.text;
|
|
3216
|
-
} else {
|
|
3217
|
-
tokens.push(token);
|
|
3218
|
-
}
|
|
3219
|
-
continue;
|
|
3220
|
-
}
|
|
3221
|
-
if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) {
|
|
3222
|
-
src = src.substring(token.raw.length);
|
|
3223
|
-
token.tokens = this.inlineTokens(token.text, [], inLink, inRawBlock);
|
|
3224
|
-
tokens.push(token);
|
|
3225
|
-
continue;
|
|
3226
|
-
}
|
|
3227
|
-
if (token = this.tokenizer.codespan(src)) {
|
|
3228
|
-
src = src.substring(token.raw.length);
|
|
3229
|
-
tokens.push(token);
|
|
3230
|
-
continue;
|
|
3231
|
-
}
|
|
3232
|
-
if (token = this.tokenizer.br(src)) {
|
|
3233
|
-
src = src.substring(token.raw.length);
|
|
3234
|
-
tokens.push(token);
|
|
3235
|
-
continue;
|
|
3236
|
-
}
|
|
3237
|
-
if (token = this.tokenizer.del(src)) {
|
|
3238
|
-
src = src.substring(token.raw.length);
|
|
3239
|
-
token.tokens = this.inlineTokens(token.text, [], inLink, inRawBlock);
|
|
3240
|
-
tokens.push(token);
|
|
3241
|
-
continue;
|
|
3242
|
-
}
|
|
3243
|
-
if (token = this.tokenizer.autolink(src, mangle)) {
|
|
3244
|
-
src = src.substring(token.raw.length);
|
|
3245
|
-
tokens.push(token);
|
|
3246
|
-
continue;
|
|
3247
|
-
}
|
|
3248
|
-
if (!inLink && (token = this.tokenizer.url(src, mangle))) {
|
|
3249
|
-
src = src.substring(token.raw.length);
|
|
3250
|
-
tokens.push(token);
|
|
3251
|
-
continue;
|
|
3252
|
-
}
|
|
3253
|
-
cutSrc = src;
|
|
3254
|
-
if (this.options.extensions && this.options.extensions.startInline) {
|
|
3255
|
-
(function() {
|
|
3256
|
-
var startIndex = Infinity;
|
|
3257
|
-
var tempSrc = src.slice(1);
|
|
3258
|
-
var tempStart = void 0;
|
|
3259
|
-
_this2.options.extensions.startInline.forEach(function(getStartIndex) {
|
|
3260
|
-
tempStart = getStartIndex.call(this, tempSrc);
|
|
3261
|
-
if (typeof tempStart === "number" && tempStart >= 0) {
|
|
3262
|
-
startIndex = Math.min(startIndex, tempStart);
|
|
3263
|
-
}
|
|
3264
|
-
});
|
|
3265
|
-
if (startIndex < Infinity && startIndex >= 0) {
|
|
3266
|
-
cutSrc = src.substring(0, startIndex + 1);
|
|
3267
|
-
}
|
|
3268
|
-
})();
|
|
3269
|
-
}
|
|
3270
|
-
if (token = this.tokenizer.inlineText(cutSrc, inRawBlock, smartypants)) {
|
|
3271
|
-
src = src.substring(token.raw.length);
|
|
3272
|
-
if (token.raw.slice(-1) !== "_") {
|
|
3273
|
-
prevChar = token.raw.slice(-1);
|
|
3274
|
-
}
|
|
3275
|
-
keepPrevChar = true;
|
|
3276
|
-
lastToken = tokens[tokens.length - 1];
|
|
3277
|
-
if (lastToken && lastToken.type === "text") {
|
|
3278
|
-
lastToken.raw += token.raw;
|
|
3279
|
-
lastToken.text += token.text;
|
|
3280
|
-
} else {
|
|
3281
|
-
tokens.push(token);
|
|
3282
|
-
}
|
|
3283
|
-
continue;
|
|
3284
|
-
}
|
|
3285
|
-
if (src) {
|
|
3286
|
-
var errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
|
|
3287
|
-
if (this.options.silent) {
|
|
3288
|
-
console.error(errMsg);
|
|
3289
|
-
break;
|
|
3290
|
-
} else {
|
|
3291
|
-
throw new Error(errMsg);
|
|
3292
|
-
}
|
|
3293
|
-
}
|
|
3531
|
+
case "hr": {
|
|
3532
|
+
out += this.renderer.hr();
|
|
3533
|
+
continue;
|
|
3294
3534
|
}
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
key: "rules",
|
|
3299
|
-
get: function get() {
|
|
3300
|
-
return {
|
|
3301
|
-
block,
|
|
3302
|
-
inline
|
|
3303
|
-
};
|
|
3535
|
+
case "heading": {
|
|
3536
|
+
out += this.renderer.heading(this.parseInline(token.tokens), token.depth, unescape(this.parseInline(token.tokens, this.textRenderer)), this.slugger);
|
|
3537
|
+
continue;
|
|
3304
3538
|
}
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
var defaults$2 = defaults$5.exports.defaults;
|
|
3309
|
-
var cleanUrl = helpers.cleanUrl, escape$1 = helpers.escape;
|
|
3310
|
-
var Renderer_1 = /* @__PURE__ */ function() {
|
|
3311
|
-
function Renderer2(options) {
|
|
3312
|
-
this.options = options || defaults$2;
|
|
3313
|
-
}
|
|
3314
|
-
var _proto = Renderer2.prototype;
|
|
3315
|
-
_proto.code = function code(_code, infostring, escaped) {
|
|
3316
|
-
var lang = (infostring || "").match(/\S*/)[0];
|
|
3317
|
-
if (this.options.highlight) {
|
|
3318
|
-
var out = this.options.highlight(_code, lang);
|
|
3319
|
-
if (out != null && out !== _code) {
|
|
3320
|
-
escaped = true;
|
|
3321
|
-
_code = out;
|
|
3322
|
-
}
|
|
3323
|
-
}
|
|
3324
|
-
_code = _code.replace(/\n$/, "") + "\n";
|
|
3325
|
-
if (!lang) {
|
|
3326
|
-
return "<pre><code>" + (escaped ? _code : escape$1(_code, true)) + "</code></pre>\n";
|
|
3327
|
-
}
|
|
3328
|
-
return '<pre><code class="' + this.options.langPrefix + escape$1(lang, true) + '">' + (escaped ? _code : escape$1(_code, true)) + "</code></pre>\n";
|
|
3329
|
-
};
|
|
3330
|
-
_proto.blockquote = function blockquote(quote) {
|
|
3331
|
-
return "<blockquote>\n" + quote + "</blockquote>\n";
|
|
3332
|
-
};
|
|
3333
|
-
_proto.html = function html(_html) {
|
|
3334
|
-
return _html;
|
|
3335
|
-
};
|
|
3336
|
-
_proto.heading = function heading(text, level, raw, slugger) {
|
|
3337
|
-
if (this.options.headerIds) {
|
|
3338
|
-
return "<h" + level + ' id="' + this.options.headerPrefix + slugger.slug(raw) + '">' + text + "</h" + level + ">\n";
|
|
3339
|
-
}
|
|
3340
|
-
return "<h" + level + ">" + text + "</h" + level + ">\n";
|
|
3341
|
-
};
|
|
3342
|
-
_proto.hr = function hr() {
|
|
3343
|
-
return this.options.xhtml ? "<hr/>\n" : "<hr>\n";
|
|
3344
|
-
};
|
|
3345
|
-
_proto.list = function list(body, ordered, start) {
|
|
3346
|
-
var type = ordered ? "ol" : "ul", startatt = ordered && start !== 1 ? ' start="' + start + '"' : "";
|
|
3347
|
-
return "<" + type + startatt + ">\n" + body + "</" + type + ">\n";
|
|
3348
|
-
};
|
|
3349
|
-
_proto.listitem = function listitem(text) {
|
|
3350
|
-
return "<li>" + text + "</li>\n";
|
|
3351
|
-
};
|
|
3352
|
-
_proto.checkbox = function checkbox(checked) {
|
|
3353
|
-
return "<input " + (checked ? 'checked="" ' : "") + 'disabled="" type="checkbox"' + (this.options.xhtml ? " /" : "") + "> ";
|
|
3354
|
-
};
|
|
3355
|
-
_proto.paragraph = function paragraph(text) {
|
|
3356
|
-
return "<p>" + text + "</p>\n";
|
|
3357
|
-
};
|
|
3358
|
-
_proto.table = function table(header, body) {
|
|
3359
|
-
if (body)
|
|
3360
|
-
body = "<tbody>" + body + "</tbody>";
|
|
3361
|
-
return "<table>\n<thead>\n" + header + "</thead>\n" + body + "</table>\n";
|
|
3362
|
-
};
|
|
3363
|
-
_proto.tablerow = function tablerow(content) {
|
|
3364
|
-
return "<tr>\n" + content + "</tr>\n";
|
|
3365
|
-
};
|
|
3366
|
-
_proto.tablecell = function tablecell(content, flags) {
|
|
3367
|
-
var type = flags.header ? "th" : "td";
|
|
3368
|
-
var tag = flags.align ? "<" + type + ' align="' + flags.align + '">' : "<" + type + ">";
|
|
3369
|
-
return tag + content + "</" + type + ">\n";
|
|
3370
|
-
};
|
|
3371
|
-
_proto.strong = function strong(text) {
|
|
3372
|
-
return "<strong>" + text + "</strong>";
|
|
3373
|
-
};
|
|
3374
|
-
_proto.em = function em(text) {
|
|
3375
|
-
return "<em>" + text + "</em>";
|
|
3376
|
-
};
|
|
3377
|
-
_proto.codespan = function codespan(text) {
|
|
3378
|
-
return "<code>" + text + "</code>";
|
|
3379
|
-
};
|
|
3380
|
-
_proto.br = function br() {
|
|
3381
|
-
return this.options.xhtml ? "<br/>" : "<br>";
|
|
3382
|
-
};
|
|
3383
|
-
_proto.del = function del(text) {
|
|
3384
|
-
return "<del>" + text + "</del>";
|
|
3385
|
-
};
|
|
3386
|
-
_proto.link = function link(href, title, text) {
|
|
3387
|
-
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
|
3388
|
-
if (href === null) {
|
|
3389
|
-
return text;
|
|
3390
|
-
}
|
|
3391
|
-
var out = '<a href="' + escape$1(href) + '"';
|
|
3392
|
-
if (title) {
|
|
3393
|
-
out += ' title="' + title + '"';
|
|
3394
|
-
}
|
|
3395
|
-
out += ">" + text + "</a>";
|
|
3396
|
-
return out;
|
|
3397
|
-
};
|
|
3398
|
-
_proto.image = function image(href, title, text) {
|
|
3399
|
-
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
|
3400
|
-
if (href === null) {
|
|
3401
|
-
return text;
|
|
3402
|
-
}
|
|
3403
|
-
var out = '<img src="' + href + '" alt="' + text + '"';
|
|
3404
|
-
if (title) {
|
|
3405
|
-
out += ' title="' + title + '"';
|
|
3406
|
-
}
|
|
3407
|
-
out += this.options.xhtml ? "/>" : ">";
|
|
3408
|
-
return out;
|
|
3409
|
-
};
|
|
3410
|
-
_proto.text = function text(_text) {
|
|
3411
|
-
return _text;
|
|
3412
|
-
};
|
|
3413
|
-
return Renderer2;
|
|
3414
|
-
}();
|
|
3415
|
-
var TextRenderer_1 = /* @__PURE__ */ function() {
|
|
3416
|
-
function TextRenderer2() {
|
|
3417
|
-
}
|
|
3418
|
-
var _proto = TextRenderer2.prototype;
|
|
3419
|
-
_proto.strong = function strong(text) {
|
|
3420
|
-
return text;
|
|
3421
|
-
};
|
|
3422
|
-
_proto.em = function em(text) {
|
|
3423
|
-
return text;
|
|
3424
|
-
};
|
|
3425
|
-
_proto.codespan = function codespan(text) {
|
|
3426
|
-
return text;
|
|
3427
|
-
};
|
|
3428
|
-
_proto.del = function del(text) {
|
|
3429
|
-
return text;
|
|
3430
|
-
};
|
|
3431
|
-
_proto.html = function html(text) {
|
|
3432
|
-
return text;
|
|
3433
|
-
};
|
|
3434
|
-
_proto.text = function text(_text) {
|
|
3435
|
-
return _text;
|
|
3436
|
-
};
|
|
3437
|
-
_proto.link = function link(href, title, text) {
|
|
3438
|
-
return "" + text;
|
|
3439
|
-
};
|
|
3440
|
-
_proto.image = function image(href, title, text) {
|
|
3441
|
-
return "" + text;
|
|
3442
|
-
};
|
|
3443
|
-
_proto.br = function br() {
|
|
3444
|
-
return "";
|
|
3445
|
-
};
|
|
3446
|
-
return TextRenderer2;
|
|
3447
|
-
}();
|
|
3448
|
-
var Slugger_1 = /* @__PURE__ */ function() {
|
|
3449
|
-
function Slugger2() {
|
|
3450
|
-
this.seen = {};
|
|
3451
|
-
}
|
|
3452
|
-
var _proto = Slugger2.prototype;
|
|
3453
|
-
_proto.serialize = function serialize(value) {
|
|
3454
|
-
return value.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig, "").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, "").replace(/\s/g, "-");
|
|
3455
|
-
};
|
|
3456
|
-
_proto.getNextSafeSlug = function getNextSafeSlug(originalSlug, isDryRun) {
|
|
3457
|
-
var slug = originalSlug;
|
|
3458
|
-
var occurenceAccumulator = 0;
|
|
3459
|
-
if (this.seen.hasOwnProperty(slug)) {
|
|
3460
|
-
occurenceAccumulator = this.seen[originalSlug];
|
|
3461
|
-
do {
|
|
3462
|
-
occurenceAccumulator++;
|
|
3463
|
-
slug = originalSlug + "-" + occurenceAccumulator;
|
|
3464
|
-
} while (this.seen.hasOwnProperty(slug));
|
|
3465
|
-
}
|
|
3466
|
-
if (!isDryRun) {
|
|
3467
|
-
this.seen[originalSlug] = occurenceAccumulator;
|
|
3468
|
-
this.seen[slug] = 0;
|
|
3469
|
-
}
|
|
3470
|
-
return slug;
|
|
3471
|
-
};
|
|
3472
|
-
_proto.slug = function slug(value, options) {
|
|
3473
|
-
if (options === void 0) {
|
|
3474
|
-
options = {};
|
|
3475
|
-
}
|
|
3476
|
-
var slug2 = this.serialize(value);
|
|
3477
|
-
return this.getNextSafeSlug(slug2, options.dryrun);
|
|
3478
|
-
};
|
|
3479
|
-
return Slugger2;
|
|
3480
|
-
}();
|
|
3481
|
-
var Renderer$1 = Renderer_1;
|
|
3482
|
-
var TextRenderer$1 = TextRenderer_1;
|
|
3483
|
-
var Slugger$1 = Slugger_1;
|
|
3484
|
-
var defaults$1 = defaults$5.exports.defaults;
|
|
3485
|
-
var unescape = helpers.unescape;
|
|
3486
|
-
var Parser_1 = /* @__PURE__ */ function() {
|
|
3487
|
-
function Parser2(options) {
|
|
3488
|
-
this.options = options || defaults$1;
|
|
3489
|
-
this.options.renderer = this.options.renderer || new Renderer$1();
|
|
3490
|
-
this.renderer = this.options.renderer;
|
|
3491
|
-
this.renderer.options = this.options;
|
|
3492
|
-
this.textRenderer = new TextRenderer$1();
|
|
3493
|
-
this.slugger = new Slugger$1();
|
|
3494
|
-
}
|
|
3495
|
-
Parser2.parse = function parse(tokens, options) {
|
|
3496
|
-
var parser = new Parser2(options);
|
|
3497
|
-
return parser.parse(tokens);
|
|
3498
|
-
};
|
|
3499
|
-
Parser2.parseInline = function parseInline(tokens, options) {
|
|
3500
|
-
var parser = new Parser2(options);
|
|
3501
|
-
return parser.parseInline(tokens);
|
|
3502
|
-
};
|
|
3503
|
-
var _proto = Parser2.prototype;
|
|
3504
|
-
_proto.parse = function parse(tokens, top) {
|
|
3505
|
-
if (top === void 0) {
|
|
3506
|
-
top = true;
|
|
3507
|
-
}
|
|
3508
|
-
var out = "", i, j, k, l2, l3, row, cell, header, body, token, ordered, start, loose, itemBody, item, checked, task, checkbox, ret;
|
|
3509
|
-
var l = tokens.length;
|
|
3510
|
-
for (i = 0; i < l; i++) {
|
|
3511
|
-
token = tokens[i];
|
|
3512
|
-
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
|
|
3513
|
-
ret = this.options.extensions.renderers[token.type].call(this, token);
|
|
3514
|
-
if (ret !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(token.type)) {
|
|
3515
|
-
out += ret || "";
|
|
3516
|
-
continue;
|
|
3517
|
-
}
|
|
3518
|
-
}
|
|
3519
|
-
switch (token.type) {
|
|
3520
|
-
case "space": {
|
|
3521
|
-
continue;
|
|
3522
|
-
}
|
|
3523
|
-
case "hr": {
|
|
3524
|
-
out += this.renderer.hr();
|
|
3525
|
-
continue;
|
|
3526
|
-
}
|
|
3527
|
-
case "heading": {
|
|
3528
|
-
out += this.renderer.heading(this.parseInline(token.tokens), token.depth, unescape(this.parseInline(token.tokens, this.textRenderer)), this.slugger);
|
|
3529
|
-
continue;
|
|
3530
|
-
}
|
|
3531
|
-
case "code": {
|
|
3532
|
-
out += this.renderer.code(token.text, token.lang, token.escaped);
|
|
3533
|
-
continue;
|
|
3534
|
-
}
|
|
3535
|
-
case "table": {
|
|
3536
|
-
header = "";
|
|
3537
|
-
cell = "";
|
|
3538
|
-
l2 = token.header.length;
|
|
3539
|
-
for (j = 0; j < l2; j++) {
|
|
3540
|
-
cell += this.renderer.tablecell(this.parseInline(token.tokens.header[j]), {
|
|
3541
|
-
header: true,
|
|
3542
|
-
align: token.align[j]
|
|
3543
|
-
});
|
|
3544
|
-
}
|
|
3545
|
-
header += this.renderer.tablerow(cell);
|
|
3546
|
-
body = "";
|
|
3547
|
-
l2 = token.cells.length;
|
|
3548
|
-
for (j = 0; j < l2; j++) {
|
|
3549
|
-
row = token.tokens.cells[j];
|
|
3550
|
-
cell = "";
|
|
3551
|
-
l3 = row.length;
|
|
3552
|
-
for (k = 0; k < l3; k++) {
|
|
3553
|
-
cell += this.renderer.tablecell(this.parseInline(row[k]), {
|
|
3554
|
-
header: false,
|
|
3555
|
-
align: token.align[k]
|
|
3556
|
-
});
|
|
3557
|
-
}
|
|
3558
|
-
body += this.renderer.tablerow(cell);
|
|
3559
|
-
}
|
|
3560
|
-
out += this.renderer.table(header, body);
|
|
3561
|
-
continue;
|
|
3562
|
-
}
|
|
3563
|
-
case "blockquote": {
|
|
3564
|
-
body = this.parse(token.tokens);
|
|
3565
|
-
out += this.renderer.blockquote(body);
|
|
3566
|
-
continue;
|
|
3567
|
-
}
|
|
3568
|
-
case "list": {
|
|
3569
|
-
ordered = token.ordered;
|
|
3570
|
-
start = token.start;
|
|
3571
|
-
loose = token.loose;
|
|
3572
|
-
l2 = token.items.length;
|
|
3573
|
-
body = "";
|
|
3574
|
-
for (j = 0; j < l2; j++) {
|
|
3575
|
-
item = token.items[j];
|
|
3576
|
-
checked = item.checked;
|
|
3577
|
-
task = item.task;
|
|
3578
|
-
itemBody = "";
|
|
3579
|
-
if (item.task) {
|
|
3580
|
-
checkbox = this.renderer.checkbox(checked);
|
|
3581
|
-
if (loose) {
|
|
3582
|
-
if (item.tokens.length > 0 && item.tokens[0].type === "text") {
|
|
3583
|
-
item.tokens[0].text = checkbox + " " + item.tokens[0].text;
|
|
3584
|
-
if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === "text") {
|
|
3585
|
-
item.tokens[0].tokens[0].text = checkbox + " " + item.tokens[0].tokens[0].text;
|
|
3586
|
-
}
|
|
3587
|
-
} else {
|
|
3588
|
-
item.tokens.unshift({
|
|
3589
|
-
type: "text",
|
|
3590
|
-
text: checkbox
|
|
3591
|
-
});
|
|
3592
|
-
}
|
|
3593
|
-
} else {
|
|
3594
|
-
itemBody += checkbox;
|
|
3595
|
-
}
|
|
3596
|
-
}
|
|
3597
|
-
itemBody += this.parse(item.tokens, loose);
|
|
3598
|
-
body += this.renderer.listitem(itemBody, task, checked);
|
|
3599
|
-
}
|
|
3600
|
-
out += this.renderer.list(body, ordered, start);
|
|
3601
|
-
continue;
|
|
3602
|
-
}
|
|
3603
|
-
case "html": {
|
|
3604
|
-
out += this.renderer.html(token.text);
|
|
3605
|
-
continue;
|
|
3606
|
-
}
|
|
3607
|
-
case "paragraph": {
|
|
3608
|
-
out += this.renderer.paragraph(this.parseInline(token.tokens));
|
|
3609
|
-
continue;
|
|
3610
|
-
}
|
|
3611
|
-
case "text": {
|
|
3612
|
-
body = token.tokens ? this.parseInline(token.tokens) : token.text;
|
|
3613
|
-
while (i + 1 < l && tokens[i + 1].type === "text") {
|
|
3614
|
-
token = tokens[++i];
|
|
3615
|
-
body += "\n" + (token.tokens ? this.parseInline(token.tokens) : token.text);
|
|
3616
|
-
}
|
|
3617
|
-
out += top ? this.renderer.paragraph(body) : body;
|
|
3618
|
-
continue;
|
|
3619
|
-
}
|
|
3620
|
-
default: {
|
|
3621
|
-
var errMsg = 'Token with "' + token.type + '" type was not found.';
|
|
3622
|
-
if (this.options.silent) {
|
|
3623
|
-
console.error(errMsg);
|
|
3624
|
-
return;
|
|
3625
|
-
} else {
|
|
3626
|
-
throw new Error(errMsg);
|
|
3627
|
-
}
|
|
3628
|
-
}
|
|
3629
|
-
}
|
|
3539
|
+
case "code": {
|
|
3540
|
+
out += this.renderer.code(token.text, token.lang, token.escaped);
|
|
3541
|
+
continue;
|
|
3630
3542
|
}
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
for (i = 0; i < l; i++) {
|
|
3638
|
-
token = tokens[i];
|
|
3639
|
-
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
|
|
3640
|
-
ret = this.options.extensions.renderers[token.type].call(this, token);
|
|
3641
|
-
if (ret !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(token.type)) {
|
|
3642
|
-
out += ret || "";
|
|
3643
|
-
continue;
|
|
3644
|
-
}
|
|
3543
|
+
case "table": {
|
|
3544
|
+
header = "";
|
|
3545
|
+
cell = "";
|
|
3546
|
+
l2 = token.header.length;
|
|
3547
|
+
for (j = 0; j < l2; j++) {
|
|
3548
|
+
cell += this.renderer.tablecell(this.parseInline(token.header[j].tokens), { header: true, align: token.align[j] });
|
|
3645
3549
|
}
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
case "link": {
|
|
3656
|
-
out += renderer.link(token.href, token.title, this.parseInline(token.tokens, renderer));
|
|
3657
|
-
break;
|
|
3658
|
-
}
|
|
3659
|
-
case "image": {
|
|
3660
|
-
out += renderer.image(token.href, token.title, token.text);
|
|
3661
|
-
break;
|
|
3662
|
-
}
|
|
3663
|
-
case "strong": {
|
|
3664
|
-
out += renderer.strong(this.parseInline(token.tokens, renderer));
|
|
3665
|
-
break;
|
|
3666
|
-
}
|
|
3667
|
-
case "em": {
|
|
3668
|
-
out += renderer.em(this.parseInline(token.tokens, renderer));
|
|
3669
|
-
break;
|
|
3550
|
+
header += this.renderer.tablerow(cell);
|
|
3551
|
+
body = "";
|
|
3552
|
+
l2 = token.rows.length;
|
|
3553
|
+
for (j = 0; j < l2; j++) {
|
|
3554
|
+
row = token.rows[j];
|
|
3555
|
+
cell = "";
|
|
3556
|
+
l3 = row.length;
|
|
3557
|
+
for (k = 0; k < l3; k++) {
|
|
3558
|
+
cell += this.renderer.tablecell(this.parseInline(row[k].tokens), { header: false, align: token.align[k] });
|
|
3670
3559
|
}
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3560
|
+
body += this.renderer.tablerow(cell);
|
|
3561
|
+
}
|
|
3562
|
+
out += this.renderer.table(header, body);
|
|
3563
|
+
continue;
|
|
3564
|
+
}
|
|
3565
|
+
case "blockquote": {
|
|
3566
|
+
body = this.parse(token.tokens);
|
|
3567
|
+
out += this.renderer.blockquote(body);
|
|
3568
|
+
continue;
|
|
3569
|
+
}
|
|
3570
|
+
case "list": {
|
|
3571
|
+
ordered = token.ordered;
|
|
3572
|
+
start = token.start;
|
|
3573
|
+
loose = token.loose;
|
|
3574
|
+
l2 = token.items.length;
|
|
3575
|
+
body = "";
|
|
3576
|
+
for (j = 0; j < l2; j++) {
|
|
3577
|
+
item = token.items[j];
|
|
3578
|
+
checked = item.checked;
|
|
3579
|
+
task = item.task;
|
|
3580
|
+
itemBody = "";
|
|
3581
|
+
if (item.task) {
|
|
3582
|
+
checkbox = this.renderer.checkbox(checked);
|
|
3583
|
+
if (loose) {
|
|
3584
|
+
if (item.tokens.length > 0 && item.tokens[0].type === "paragraph") {
|
|
3585
|
+
item.tokens[0].text = checkbox + " " + item.tokens[0].text;
|
|
3586
|
+
if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === "text") {
|
|
3587
|
+
item.tokens[0].tokens[0].text = checkbox + " " + item.tokens[0].tokens[0].text;
|
|
3588
|
+
}
|
|
3589
|
+
} else {
|
|
3590
|
+
item.tokens.unshift({
|
|
3591
|
+
type: "text",
|
|
3592
|
+
text: checkbox
|
|
3593
|
+
});
|
|
3594
|
+
}
|
|
3692
3595
|
} else {
|
|
3693
|
-
|
|
3596
|
+
itemBody += checkbox;
|
|
3694
3597
|
}
|
|
3695
3598
|
}
|
|
3599
|
+
itemBody += this.parse(item.tokens, loose);
|
|
3600
|
+
body += this.renderer.listitem(itemBody, task, checked);
|
|
3696
3601
|
}
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
}
|
|
3714
|
-
if (typeof src !== "string") {
|
|
3715
|
-
throw new Error("marked(): input parameter is of type " + Object.prototype.toString.call(src) + ", string expected");
|
|
3716
|
-
}
|
|
3717
|
-
if (typeof opt === "function") {
|
|
3718
|
-
callback = opt;
|
|
3719
|
-
opt = null;
|
|
3720
|
-
}
|
|
3721
|
-
opt = merge({}, marked2.defaults, opt || {});
|
|
3722
|
-
checkSanitizeDeprecation(opt);
|
|
3723
|
-
if (callback) {
|
|
3724
|
-
var highlight = opt.highlight;
|
|
3725
|
-
var tokens;
|
|
3726
|
-
try {
|
|
3727
|
-
tokens = Lexer.lex(src, opt);
|
|
3728
|
-
} catch (e) {
|
|
3729
|
-
return callback(e);
|
|
3730
|
-
}
|
|
3731
|
-
var done = function done2(err) {
|
|
3732
|
-
var out;
|
|
3733
|
-
if (!err) {
|
|
3734
|
-
try {
|
|
3735
|
-
if (opt.walkTokens) {
|
|
3736
|
-
marked2.walkTokens(tokens, opt.walkTokens);
|
|
3737
|
-
}
|
|
3738
|
-
out = Parser.parse(tokens, opt);
|
|
3739
|
-
} catch (e) {
|
|
3740
|
-
err = e;
|
|
3741
|
-
}
|
|
3602
|
+
out += this.renderer.list(body, ordered, start);
|
|
3603
|
+
continue;
|
|
3604
|
+
}
|
|
3605
|
+
case "html": {
|
|
3606
|
+
out += this.renderer.html(token.text);
|
|
3607
|
+
continue;
|
|
3608
|
+
}
|
|
3609
|
+
case "paragraph": {
|
|
3610
|
+
out += this.renderer.paragraph(this.parseInline(token.tokens));
|
|
3611
|
+
continue;
|
|
3612
|
+
}
|
|
3613
|
+
case "text": {
|
|
3614
|
+
body = token.tokens ? this.parseInline(token.tokens) : token.text;
|
|
3615
|
+
while (i + 1 < l && tokens[i + 1].type === "text") {
|
|
3616
|
+
token = tokens[++i];
|
|
3617
|
+
body += "\n" + (token.tokens ? this.parseInline(token.tokens) : token.text);
|
|
3742
3618
|
}
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
}
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
marked2.walkTokens(tokens, function(token) {
|
|
3754
|
-
if (token.type === "code") {
|
|
3755
|
-
pending++;
|
|
3756
|
-
setTimeout(function() {
|
|
3757
|
-
highlight(token.text, token.lang, function(err, code) {
|
|
3758
|
-
if (err) {
|
|
3759
|
-
return done(err);
|
|
3760
|
-
}
|
|
3761
|
-
if (code != null && code !== token.text) {
|
|
3762
|
-
token.text = code;
|
|
3763
|
-
token.escaped = true;
|
|
3764
|
-
}
|
|
3765
|
-
pending--;
|
|
3766
|
-
if (pending === 0) {
|
|
3767
|
-
done();
|
|
3768
|
-
}
|
|
3769
|
-
});
|
|
3770
|
-
}, 0);
|
|
3619
|
+
out += top ? this.renderer.paragraph(body) : body;
|
|
3620
|
+
continue;
|
|
3621
|
+
}
|
|
3622
|
+
default: {
|
|
3623
|
+
const errMsg = 'Token with "' + token.type + '" type was not found.';
|
|
3624
|
+
if (this.options.silent) {
|
|
3625
|
+
console.error(errMsg);
|
|
3626
|
+
return;
|
|
3627
|
+
} else {
|
|
3628
|
+
throw new Error(errMsg);
|
|
3771
3629
|
}
|
|
3772
|
-
});
|
|
3773
|
-
if (pending === 0) {
|
|
3774
|
-
done();
|
|
3775
3630
|
}
|
|
3776
|
-
return;
|
|
3777
3631
|
}
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3632
|
+
}
|
|
3633
|
+
return out;
|
|
3634
|
+
}
|
|
3635
|
+
parseInline(tokens, renderer) {
|
|
3636
|
+
renderer = renderer || this.renderer;
|
|
3637
|
+
let out = "", i, token, ret;
|
|
3638
|
+
const l = tokens.length;
|
|
3639
|
+
for (i = 0; i < l; i++) {
|
|
3640
|
+
token = tokens[i];
|
|
3641
|
+
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
|
|
3642
|
+
ret = this.options.extensions.renderers[token.type].call({ parser: this }, token);
|
|
3643
|
+
if (ret !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(token.type)) {
|
|
3644
|
+
out += ret || "";
|
|
3645
|
+
continue;
|
|
3646
|
+
}
|
|
3647
|
+
}
|
|
3648
|
+
switch (token.type) {
|
|
3649
|
+
case "escape": {
|
|
3650
|
+
out += renderer.text(token.text);
|
|
3651
|
+
break;
|
|
3652
|
+
}
|
|
3653
|
+
case "html": {
|
|
3654
|
+
out += renderer.html(token.text);
|
|
3655
|
+
break;
|
|
3656
|
+
}
|
|
3657
|
+
case "link": {
|
|
3658
|
+
out += renderer.link(token.href, token.title, this.parseInline(token.tokens, renderer));
|
|
3659
|
+
break;
|
|
3660
|
+
}
|
|
3661
|
+
case "image": {
|
|
3662
|
+
out += renderer.image(token.href, token.title, token.text);
|
|
3663
|
+
break;
|
|
3664
|
+
}
|
|
3665
|
+
case "strong": {
|
|
3666
|
+
out += renderer.strong(this.parseInline(token.tokens, renderer));
|
|
3667
|
+
break;
|
|
3668
|
+
}
|
|
3669
|
+
case "em": {
|
|
3670
|
+
out += renderer.em(this.parseInline(token.tokens, renderer));
|
|
3671
|
+
break;
|
|
3672
|
+
}
|
|
3673
|
+
case "codespan": {
|
|
3674
|
+
out += renderer.codespan(token.text);
|
|
3675
|
+
break;
|
|
3676
|
+
}
|
|
3677
|
+
case "br": {
|
|
3678
|
+
out += renderer.br();
|
|
3679
|
+
break;
|
|
3680
|
+
}
|
|
3681
|
+
case "del": {
|
|
3682
|
+
out += renderer.del(this.parseInline(token.tokens, renderer));
|
|
3683
|
+
break;
|
|
3684
|
+
}
|
|
3685
|
+
case "text": {
|
|
3686
|
+
out += renderer.text(token.text);
|
|
3687
|
+
break;
|
|
3782
3688
|
}
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3689
|
+
default: {
|
|
3690
|
+
const errMsg = 'Token with "' + token.type + '" type was not found.';
|
|
3691
|
+
if (this.options.silent) {
|
|
3692
|
+
console.error(errMsg);
|
|
3693
|
+
return;
|
|
3694
|
+
} else {
|
|
3695
|
+
throw new Error(errMsg);
|
|
3696
|
+
}
|
|
3788
3697
|
}
|
|
3789
|
-
throw e;
|
|
3790
3698
|
}
|
|
3791
3699
|
}
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3700
|
+
return out;
|
|
3701
|
+
}
|
|
3702
|
+
}
|
|
3703
|
+
function marked(src, opt, callback) {
|
|
3704
|
+
if (typeof src === "undefined" || src === null) {
|
|
3705
|
+
throw new Error("marked(): input parameter is undefined or null");
|
|
3706
|
+
}
|
|
3707
|
+
if (typeof src !== "string") {
|
|
3708
|
+
throw new Error("marked(): input parameter is of type " + Object.prototype.toString.call(src) + ", string expected");
|
|
3709
|
+
}
|
|
3710
|
+
if (typeof opt === "function") {
|
|
3711
|
+
callback = opt;
|
|
3712
|
+
opt = null;
|
|
3713
|
+
}
|
|
3714
|
+
opt = merge({}, marked.defaults, opt || {});
|
|
3715
|
+
checkSanitizeDeprecation(opt);
|
|
3716
|
+
if (callback) {
|
|
3717
|
+
const highlight = opt.highlight;
|
|
3718
|
+
let tokens;
|
|
3719
|
+
try {
|
|
3720
|
+
tokens = Lexer.lex(src, opt);
|
|
3721
|
+
} catch (e) {
|
|
3722
|
+
return callback(e);
|
|
3723
|
+
}
|
|
3724
|
+
const done = function(err) {
|
|
3725
|
+
let out;
|
|
3726
|
+
if (!err) {
|
|
3727
|
+
try {
|
|
3728
|
+
if (opt.walkTokens) {
|
|
3729
|
+
marked.walkTokens(tokens, opt.walkTokens);
|
|
3730
|
+
}
|
|
3731
|
+
out = Parser.parse(tokens, opt);
|
|
3732
|
+
} catch (e) {
|
|
3733
|
+
err = e;
|
|
3734
|
+
}
|
|
3735
|
+
}
|
|
3736
|
+
opt.highlight = highlight;
|
|
3737
|
+
return err ? callback(err) : callback(null, out);
|
|
3796
3738
|
};
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
if (pack.extensions) {
|
|
3812
|
-
hasExtensions = true;
|
|
3813
|
-
pack.extensions.forEach(function(ext) {
|
|
3814
|
-
if (!ext.name) {
|
|
3815
|
-
throw new Error("extension name required");
|
|
3739
|
+
if (!highlight || highlight.length < 3) {
|
|
3740
|
+
return done();
|
|
3741
|
+
}
|
|
3742
|
+
delete opt.highlight;
|
|
3743
|
+
if (!tokens.length)
|
|
3744
|
+
return done();
|
|
3745
|
+
let pending = 0;
|
|
3746
|
+
marked.walkTokens(tokens, function(token) {
|
|
3747
|
+
if (token.type === "code") {
|
|
3748
|
+
pending++;
|
|
3749
|
+
setTimeout(() => {
|
|
3750
|
+
highlight(token.text, token.lang, function(err, code) {
|
|
3751
|
+
if (err) {
|
|
3752
|
+
return done(err);
|
|
3816
3753
|
}
|
|
3817
|
-
if (
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
var ret = ext.renderer.apply(this, args2);
|
|
3825
|
-
if (ret === false) {
|
|
3826
|
-
ret = prevRenderer.apply(this, args2);
|
|
3827
|
-
}
|
|
3828
|
-
return ret;
|
|
3829
|
-
};
|
|
3830
|
-
} else {
|
|
3831
|
-
extensions.renderers[ext.name] = ext.renderer;
|
|
3832
|
-
}
|
|
3754
|
+
if (code != null && code !== token.text) {
|
|
3755
|
+
token.text = code;
|
|
3756
|
+
token.escaped = true;
|
|
3757
|
+
}
|
|
3758
|
+
pending--;
|
|
3759
|
+
if (pending === 0) {
|
|
3760
|
+
done();
|
|
3833
3761
|
}
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3762
|
+
});
|
|
3763
|
+
}, 0);
|
|
3764
|
+
}
|
|
3765
|
+
});
|
|
3766
|
+
if (pending === 0) {
|
|
3767
|
+
done();
|
|
3768
|
+
}
|
|
3769
|
+
return;
|
|
3770
|
+
}
|
|
3771
|
+
try {
|
|
3772
|
+
const tokens = Lexer.lex(src, opt);
|
|
3773
|
+
if (opt.walkTokens) {
|
|
3774
|
+
marked.walkTokens(tokens, opt.walkTokens);
|
|
3775
|
+
}
|
|
3776
|
+
return Parser.parse(tokens, opt);
|
|
3777
|
+
} catch (e) {
|
|
3778
|
+
e.message += "\nPlease report this to https://github.com/markedjs/marked.";
|
|
3779
|
+
if (opt.silent) {
|
|
3780
|
+
return "<p>An error occurred:</p><pre>" + escape(e.message + "", true) + "</pre>";
|
|
3781
|
+
}
|
|
3782
|
+
throw e;
|
|
3783
|
+
}
|
|
3784
|
+
}
|
|
3785
|
+
marked.options = marked.setOptions = function(opt) {
|
|
3786
|
+
merge(marked.defaults, opt);
|
|
3787
|
+
changeDefaults(marked.defaults);
|
|
3788
|
+
return marked;
|
|
3789
|
+
};
|
|
3790
|
+
marked.getDefaults = getDefaults;
|
|
3791
|
+
marked.defaults = defaults;
|
|
3792
|
+
marked.use = function(...args) {
|
|
3793
|
+
const opts = merge({}, ...args);
|
|
3794
|
+
const extensions = marked.defaults.extensions || { renderers: {}, childTokens: {} };
|
|
3795
|
+
let hasExtensions;
|
|
3796
|
+
args.forEach((pack) => {
|
|
3797
|
+
if (pack.extensions) {
|
|
3798
|
+
hasExtensions = true;
|
|
3799
|
+
pack.extensions.forEach((ext) => {
|
|
3800
|
+
if (!ext.name) {
|
|
3801
|
+
throw new Error("extension name required");
|
|
3802
|
+
}
|
|
3803
|
+
if (ext.renderer) {
|
|
3804
|
+
const prevRenderer = extensions.renderers ? extensions.renderers[ext.name] : null;
|
|
3805
|
+
if (prevRenderer) {
|
|
3806
|
+
extensions.renderers[ext.name] = function(...args2) {
|
|
3807
|
+
let ret = ext.renderer.apply(this, args2);
|
|
3808
|
+
if (ret === false) {
|
|
3809
|
+
ret = prevRenderer.apply(this, args2);
|
|
3837
3810
|
}
|
|
3838
|
-
|
|
3839
|
-
|
|
3811
|
+
return ret;
|
|
3812
|
+
};
|
|
3813
|
+
} else {
|
|
3814
|
+
extensions.renderers[ext.name] = ext.renderer;
|
|
3815
|
+
}
|
|
3816
|
+
}
|
|
3817
|
+
if (ext.tokenizer) {
|
|
3818
|
+
if (!ext.level || ext.level !== "block" && ext.level !== "inline") {
|
|
3819
|
+
throw new Error("extension level must be 'block' or 'inline'");
|
|
3820
|
+
}
|
|
3821
|
+
if (extensions[ext.level]) {
|
|
3822
|
+
extensions[ext.level].unshift(ext.tokenizer);
|
|
3823
|
+
} else {
|
|
3824
|
+
extensions[ext.level] = [ext.tokenizer];
|
|
3825
|
+
}
|
|
3826
|
+
if (ext.start) {
|
|
3827
|
+
if (ext.level === "block") {
|
|
3828
|
+
if (extensions.startBlock) {
|
|
3829
|
+
extensions.startBlock.push(ext.start);
|
|
3840
3830
|
} else {
|
|
3841
|
-
extensions
|
|
3831
|
+
extensions.startBlock = [ext.start];
|
|
3842
3832
|
}
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
extensions.startBlock = [ext.start];
|
|
3849
|
-
}
|
|
3850
|
-
} else if (ext.level === "inline") {
|
|
3851
|
-
if (extensions.startInline) {
|
|
3852
|
-
extensions.startInline.push(ext.start);
|
|
3853
|
-
} else {
|
|
3854
|
-
extensions.startInline = [ext.start];
|
|
3855
|
-
}
|
|
3856
|
-
}
|
|
3833
|
+
} else if (ext.level === "inline") {
|
|
3834
|
+
if (extensions.startInline) {
|
|
3835
|
+
extensions.startInline.push(ext.start);
|
|
3836
|
+
} else {
|
|
3837
|
+
extensions.startInline = [ext.start];
|
|
3857
3838
|
}
|
|
3858
3839
|
}
|
|
3859
|
-
|
|
3860
|
-
extensions.childTokens[ext.name] = ext.childTokens;
|
|
3861
|
-
}
|
|
3862
|
-
});
|
|
3863
|
-
}
|
|
3864
|
-
if (pack.renderer) {
|
|
3865
|
-
(function() {
|
|
3866
|
-
var renderer = marked2.defaults.renderer || new Renderer();
|
|
3867
|
-
var _loop = function _loop2(prop2) {
|
|
3868
|
-
var prevRenderer = renderer[prop2];
|
|
3869
|
-
renderer[prop2] = function() {
|
|
3870
|
-
for (var _len3 = arguments.length, args2 = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
3871
|
-
args2[_key3] = arguments[_key3];
|
|
3872
|
-
}
|
|
3873
|
-
var ret = pack.renderer[prop2].apply(renderer, args2);
|
|
3874
|
-
if (ret === false) {
|
|
3875
|
-
ret = prevRenderer.apply(renderer, args2);
|
|
3876
|
-
}
|
|
3877
|
-
return ret;
|
|
3878
|
-
};
|
|
3879
|
-
};
|
|
3880
|
-
for (var prop in pack.renderer) {
|
|
3881
|
-
_loop(prop);
|
|
3882
|
-
}
|
|
3883
|
-
opts.renderer = renderer;
|
|
3884
|
-
})();
|
|
3885
|
-
}
|
|
3886
|
-
if (pack.tokenizer) {
|
|
3887
|
-
(function() {
|
|
3888
|
-
var tokenizer = marked2.defaults.tokenizer || new Tokenizer();
|
|
3889
|
-
var _loop2 = function _loop22(prop2) {
|
|
3890
|
-
var prevTokenizer = tokenizer[prop2];
|
|
3891
|
-
tokenizer[prop2] = function() {
|
|
3892
|
-
for (var _len4 = arguments.length, args2 = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
3893
|
-
args2[_key4] = arguments[_key4];
|
|
3894
|
-
}
|
|
3895
|
-
var ret = pack.tokenizer[prop2].apply(tokenizer, args2);
|
|
3896
|
-
if (ret === false) {
|
|
3897
|
-
ret = prevTokenizer.apply(tokenizer, args2);
|
|
3898
|
-
}
|
|
3899
|
-
return ret;
|
|
3900
|
-
};
|
|
3901
|
-
};
|
|
3902
|
-
for (var prop in pack.tokenizer) {
|
|
3903
|
-
_loop2(prop);
|
|
3904
|
-
}
|
|
3905
|
-
opts.tokenizer = tokenizer;
|
|
3906
|
-
})();
|
|
3907
|
-
}
|
|
3908
|
-
if (pack.walkTokens) {
|
|
3909
|
-
var walkTokens = marked2.defaults.walkTokens;
|
|
3910
|
-
opts.walkTokens = function(token) {
|
|
3911
|
-
pack.walkTokens.call(_this, token);
|
|
3912
|
-
if (walkTokens) {
|
|
3913
|
-
walkTokens(token);
|
|
3914
|
-
}
|
|
3915
|
-
};
|
|
3840
|
+
}
|
|
3916
3841
|
}
|
|
3917
|
-
if (
|
|
3918
|
-
|
|
3842
|
+
if (ext.childTokens) {
|
|
3843
|
+
extensions.childTokens[ext.name] = ext.childTokens;
|
|
3919
3844
|
}
|
|
3920
|
-
marked2.setOptions(opts);
|
|
3921
3845
|
});
|
|
3922
|
-
}
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
marked2.walkTokens(cell, callback);
|
|
3932
|
-
}
|
|
3933
|
-
for (var _iterator3 = _createForOfIteratorHelperLoose(token.tokens.cells), _step3; !(_step3 = _iterator3()).done; ) {
|
|
3934
|
-
var row = _step3.value;
|
|
3935
|
-
for (var _iterator4 = _createForOfIteratorHelperLoose(row), _step4; !(_step4 = _iterator4()).done; ) {
|
|
3936
|
-
var _cell = _step4.value;
|
|
3937
|
-
marked2.walkTokens(_cell, callback);
|
|
3938
|
-
}
|
|
3939
|
-
}
|
|
3940
|
-
break;
|
|
3941
|
-
}
|
|
3942
|
-
case "list": {
|
|
3943
|
-
marked2.walkTokens(token.items, callback);
|
|
3944
|
-
break;
|
|
3846
|
+
}
|
|
3847
|
+
if (pack.renderer) {
|
|
3848
|
+
const renderer = marked.defaults.renderer || new Renderer();
|
|
3849
|
+
for (const prop in pack.renderer) {
|
|
3850
|
+
const prevRenderer = renderer[prop];
|
|
3851
|
+
renderer[prop] = (...args2) => {
|
|
3852
|
+
let ret = pack.renderer[prop].apply(renderer, args2);
|
|
3853
|
+
if (ret === false) {
|
|
3854
|
+
ret = prevRenderer.apply(renderer, args2);
|
|
3945
3855
|
}
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3856
|
+
return ret;
|
|
3857
|
+
};
|
|
3858
|
+
}
|
|
3859
|
+
opts.renderer = renderer;
|
|
3860
|
+
}
|
|
3861
|
+
if (pack.tokenizer) {
|
|
3862
|
+
const tokenizer = marked.defaults.tokenizer || new Tokenizer();
|
|
3863
|
+
for (const prop in pack.tokenizer) {
|
|
3864
|
+
const prevTokenizer = tokenizer[prop];
|
|
3865
|
+
tokenizer[prop] = (...args2) => {
|
|
3866
|
+
let ret = pack.tokenizer[prop].apply(tokenizer, args2);
|
|
3867
|
+
if (ret === false) {
|
|
3868
|
+
ret = prevTokenizer.apply(tokenizer, args2);
|
|
3954
3869
|
}
|
|
3870
|
+
return ret;
|
|
3871
|
+
};
|
|
3872
|
+
}
|
|
3873
|
+
opts.tokenizer = tokenizer;
|
|
3874
|
+
}
|
|
3875
|
+
if (pack.walkTokens) {
|
|
3876
|
+
const walkTokens = marked.defaults.walkTokens;
|
|
3877
|
+
opts.walkTokens = function(token) {
|
|
3878
|
+
pack.walkTokens.call(this, token);
|
|
3879
|
+
if (walkTokens) {
|
|
3880
|
+
walkTokens.call(this, token);
|
|
3955
3881
|
}
|
|
3956
3882
|
};
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
}
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3883
|
+
}
|
|
3884
|
+
if (hasExtensions) {
|
|
3885
|
+
opts.extensions = extensions;
|
|
3886
|
+
}
|
|
3887
|
+
marked.setOptions(opts);
|
|
3888
|
+
});
|
|
3889
|
+
};
|
|
3890
|
+
marked.walkTokens = function(tokens, callback) {
|
|
3891
|
+
for (const token of tokens) {
|
|
3892
|
+
callback.call(marked, token);
|
|
3893
|
+
switch (token.type) {
|
|
3894
|
+
case "table": {
|
|
3895
|
+
for (const cell of token.header) {
|
|
3896
|
+
marked.walkTokens(cell.tokens, callback);
|
|
3897
|
+
}
|
|
3898
|
+
for (const row of token.rows) {
|
|
3899
|
+
for (const cell of row) {
|
|
3900
|
+
marked.walkTokens(cell.tokens, callback);
|
|
3901
|
+
}
|
|
3902
|
+
}
|
|
3903
|
+
break;
|
|
3964
3904
|
}
|
|
3965
|
-
|
|
3966
|
-
|
|
3905
|
+
case "list": {
|
|
3906
|
+
marked.walkTokens(token.items, callback);
|
|
3907
|
+
break;
|
|
3967
3908
|
}
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
return Parser.parseInline(tokens, opt);
|
|
3976
|
-
} catch (e) {
|
|
3977
|
-
e.message += "\nPlease report this to https://github.com/markedjs/marked.";
|
|
3978
|
-
if (opt.silent) {
|
|
3979
|
-
return "<p>An error occurred:</p><pre>" + escape(e.message + "", true) + "</pre>";
|
|
3909
|
+
default: {
|
|
3910
|
+
if (marked.defaults.extensions && marked.defaults.extensions.childTokens && marked.defaults.extensions.childTokens[token.type]) {
|
|
3911
|
+
marked.defaults.extensions.childTokens[token.type].forEach(function(childTokens) {
|
|
3912
|
+
marked.walkTokens(token[childTokens], callback);
|
|
3913
|
+
});
|
|
3914
|
+
} else if (token.tokens) {
|
|
3915
|
+
marked.walkTokens(token.tokens, callback);
|
|
3980
3916
|
}
|
|
3981
|
-
throw e;
|
|
3982
3917
|
}
|
|
3983
|
-
}
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3918
|
+
}
|
|
3919
|
+
}
|
|
3920
|
+
};
|
|
3921
|
+
marked.parseInline = function(src, opt) {
|
|
3922
|
+
if (typeof src === "undefined" || src === null) {
|
|
3923
|
+
throw new Error("marked.parseInline(): input parameter is undefined or null");
|
|
3924
|
+
}
|
|
3925
|
+
if (typeof src !== "string") {
|
|
3926
|
+
throw new Error("marked.parseInline(): input parameter is of type " + Object.prototype.toString.call(src) + ", string expected");
|
|
3927
|
+
}
|
|
3928
|
+
opt = merge({}, marked.defaults, opt || {});
|
|
3929
|
+
checkSanitizeDeprecation(opt);
|
|
3930
|
+
try {
|
|
3931
|
+
const tokens = Lexer.lexInline(src, opt);
|
|
3932
|
+
if (opt.walkTokens) {
|
|
3933
|
+
marked.walkTokens(tokens, opt.walkTokens);
|
|
3934
|
+
}
|
|
3935
|
+
return Parser.parseInline(tokens, opt);
|
|
3936
|
+
} catch (e) {
|
|
3937
|
+
e.message += "\nPlease report this to https://github.com/markedjs/marked.";
|
|
3938
|
+
if (opt.silent) {
|
|
3939
|
+
return "<p>An error occurred:</p><pre>" + escape(e.message + "", true) + "</pre>";
|
|
3940
|
+
}
|
|
3941
|
+
throw e;
|
|
3942
|
+
}
|
|
3943
|
+
};
|
|
3944
|
+
marked.Parser = Parser;
|
|
3945
|
+
marked.parser = Parser.parse;
|
|
3946
|
+
marked.Renderer = Renderer;
|
|
3947
|
+
marked.TextRenderer = TextRenderer;
|
|
3948
|
+
marked.Lexer = Lexer;
|
|
3949
|
+
marked.lexer = Lexer.lex;
|
|
3950
|
+
marked.Tokenizer = Tokenizer;
|
|
3951
|
+
marked.Slugger = Slugger;
|
|
3952
|
+
marked.parse = marked;
|
|
3953
|
+
Parser.parse;
|
|
3954
|
+
Lexer.lex;
|
|
3998
3955
|
var toggleSelection = function() {
|
|
3999
3956
|
var selection = document.getSelection();
|
|
4000
3957
|
if (!selection.rangeCount) {
|
|
@@ -4220,9 +4177,24 @@ const directive2flag = (direct, selectedText = "", inputArea, params) => {
|
|
|
4220
4177
|
break;
|
|
4221
4178
|
}
|
|
4222
4179
|
case "table": {
|
|
4223
|
-
targetValue = "|
|
|
4180
|
+
targetValue = "|";
|
|
4181
|
+
const { selectedShape = { x: 1, y: 1 } } = params;
|
|
4182
|
+
const { x, y } = selectedShape;
|
|
4183
|
+
for (let i = 0; i <= y; i++) {
|
|
4184
|
+
targetValue += " col |";
|
|
4185
|
+
}
|
|
4186
|
+
targetValue += "\n|";
|
|
4187
|
+
for (let i = 0; i <= y; i++) {
|
|
4188
|
+
targetValue += " - |";
|
|
4189
|
+
}
|
|
4190
|
+
for (let row = 0; row <= x; row++) {
|
|
4191
|
+
targetValue += "\n|";
|
|
4192
|
+
for (let col = 0; col <= y; col++) {
|
|
4193
|
+
targetValue += " content |";
|
|
4194
|
+
}
|
|
4195
|
+
}
|
|
4224
4196
|
deviationStart = 2;
|
|
4225
|
-
deviationEnd =
|
|
4197
|
+
deviationEnd = 5 - targetValue.length;
|
|
4226
4198
|
select = true;
|
|
4227
4199
|
break;
|
|
4228
4200
|
}
|
|
@@ -4362,6 +4334,95 @@ const directive2flag = (direct, selectedText = "", inputArea, params) => {
|
|
|
4362
4334
|
setPosition(inputArea, prefixStrEndRow.length);
|
|
4363
4335
|
return `${prefixStrEndRow}${subfixStrEndRow.replace(/^\n/, "")}`;
|
|
4364
4336
|
}
|
|
4337
|
+
case "flow": {
|
|
4338
|
+
targetValue = `\`\`\`mermaid
|
|
4339
|
+
flowchart TD
|
|
4340
|
+
Start --> Stop
|
|
4341
|
+
\`\`\`
|
|
4342
|
+
`;
|
|
4343
|
+
deviationStart = 2;
|
|
4344
|
+
break;
|
|
4345
|
+
}
|
|
4346
|
+
case "sequence": {
|
|
4347
|
+
targetValue = `\`\`\`mermaid
|
|
4348
|
+
sequenceDiagram
|
|
4349
|
+
A->>B: hello!
|
|
4350
|
+
B-->>A: hi!
|
|
4351
|
+
A-)B: bye!
|
|
4352
|
+
\`\`\`
|
|
4353
|
+
`;
|
|
4354
|
+
deviationStart = 2;
|
|
4355
|
+
break;
|
|
4356
|
+
}
|
|
4357
|
+
case "gantt": {
|
|
4358
|
+
targetValue = `\`\`\`mermaid
|
|
4359
|
+
gantt
|
|
4360
|
+
title A Gantt Diagram
|
|
4361
|
+
dateFormat YYYY-MM-DD
|
|
4362
|
+
section Section
|
|
4363
|
+
A task :a1, 2014-01-01, 30d
|
|
4364
|
+
Another task :after a1, 20d
|
|
4365
|
+
\`\`\`
|
|
4366
|
+
`;
|
|
4367
|
+
deviationStart = 2;
|
|
4368
|
+
break;
|
|
4369
|
+
}
|
|
4370
|
+
case "class": {
|
|
4371
|
+
targetValue = `\`\`\`mermaid
|
|
4372
|
+
classDiagram
|
|
4373
|
+
class Animal
|
|
4374
|
+
Vehicle <|-- Car
|
|
4375
|
+
\`\`\`
|
|
4376
|
+
`;
|
|
4377
|
+
deviationStart = 2;
|
|
4378
|
+
break;
|
|
4379
|
+
}
|
|
4380
|
+
case "state": {
|
|
4381
|
+
targetValue = `\`\`\`mermaid
|
|
4382
|
+
stateDiagram-v2
|
|
4383
|
+
s1 --> s2
|
|
4384
|
+
\`\`\`
|
|
4385
|
+
`;
|
|
4386
|
+
deviationStart = 2;
|
|
4387
|
+
break;
|
|
4388
|
+
}
|
|
4389
|
+
case "pie": {
|
|
4390
|
+
targetValue = `\`\`\`mermaid
|
|
4391
|
+
pie title Pets adopted by volunteers
|
|
4392
|
+
"Dogs" : 386
|
|
4393
|
+
"Cats" : 85
|
|
4394
|
+
"Rats" : 15
|
|
4395
|
+
\`\`\`
|
|
4396
|
+
`;
|
|
4397
|
+
deviationStart = 2;
|
|
4398
|
+
break;
|
|
4399
|
+
}
|
|
4400
|
+
case "relationship": {
|
|
4401
|
+
targetValue = `\`\`\`mermaid
|
|
4402
|
+
erDiagram
|
|
4403
|
+
CAR ||--o{ NAMED-DRIVER : allows
|
|
4404
|
+
PERSON ||--o{ NAMED-DRIVER : is
|
|
4405
|
+
\`\`\`
|
|
4406
|
+
`;
|
|
4407
|
+
deviationStart = 2;
|
|
4408
|
+
break;
|
|
4409
|
+
}
|
|
4410
|
+
case "journey": {
|
|
4411
|
+
targetValue = `\`\`\`mermaid
|
|
4412
|
+
journey
|
|
4413
|
+
title My working day
|
|
4414
|
+
section Go to work
|
|
4415
|
+
Make tea: 5: Me
|
|
4416
|
+
Go upstairs: 3: Me
|
|
4417
|
+
Do work: 1: Me, Cat
|
|
4418
|
+
section Go home
|
|
4419
|
+
Go downstairs: 5: Me
|
|
4420
|
+
Sit down: 5: Me
|
|
4421
|
+
\`\`\`
|
|
4422
|
+
`;
|
|
4423
|
+
deviationStart = 2;
|
|
4424
|
+
break;
|
|
4425
|
+
}
|
|
4365
4426
|
}
|
|
4366
4427
|
}
|
|
4367
4428
|
return insert(inputArea, targetValue, {
|
|
@@ -4442,17 +4503,47 @@ const useHistory = (props2, textAreaRef) => {
|
|
|
4442
4503
|
});
|
|
4443
4504
|
});
|
|
4444
4505
|
};
|
|
4445
|
-
const useMarked = (props2) => {
|
|
4506
|
+
const useMarked = (props2, mermaidData) => {
|
|
4446
4507
|
const showCodeRowNumber = inject("showCodeRowNumber");
|
|
4447
4508
|
const editorId = inject("editorId");
|
|
4448
4509
|
const highlightInited = ref(false);
|
|
4449
|
-
let
|
|
4510
|
+
let heads = [];
|
|
4450
4511
|
const renderer = new marked.Renderer();
|
|
4451
4512
|
renderer.heading = (...headProps) => {
|
|
4452
4513
|
const [, level, raw] = headProps;
|
|
4453
|
-
|
|
4514
|
+
heads.push({ text: raw, level });
|
|
4454
4515
|
return props2.markedHeading(...headProps);
|
|
4455
4516
|
};
|
|
4517
|
+
renderer.defaultCode = renderer.code;
|
|
4518
|
+
renderer.code = (code, language, isEscaped) => {
|
|
4519
|
+
var _a;
|
|
4520
|
+
if (!props2.noMermaid && language === "mermaid") {
|
|
4521
|
+
const idRand = `${prefix}-mermaid-${Date.now().toString(36)}`;
|
|
4522
|
+
try {
|
|
4523
|
+
let svgCode = "";
|
|
4524
|
+
if (props2.mermaid) {
|
|
4525
|
+
svgCode = props2.mermaid.mermaidAPI.render(idRand, code);
|
|
4526
|
+
}
|
|
4527
|
+
if (typeof window !== "undefined" && window.mermaid) {
|
|
4528
|
+
svgCode = window.mermaid.mermaidAPI.render(idRand, code);
|
|
4529
|
+
} else {
|
|
4530
|
+
svgCode = `<div class="mermaid">${code}</div>`;
|
|
4531
|
+
}
|
|
4532
|
+
return `<div class="${prefix}-mermaid">${svgCode}</div>`;
|
|
4533
|
+
} catch (error) {
|
|
4534
|
+
if (typeof document !== "undefined") {
|
|
4535
|
+
const errorDom = document.querySelector(`#${idRand}`);
|
|
4536
|
+
if (errorDom) {
|
|
4537
|
+
const errorSvg = errorDom.outerHTML;
|
|
4538
|
+
(_a = errorDom.parentElement) == null ? void 0 : _a.remove();
|
|
4539
|
+
return errorSvg;
|
|
4540
|
+
}
|
|
4541
|
+
}
|
|
4542
|
+
return "";
|
|
4543
|
+
}
|
|
4544
|
+
}
|
|
4545
|
+
return renderer.defaultCode(code, language, isEscaped);
|
|
4546
|
+
};
|
|
4456
4547
|
renderer.image = (href, _, desc) => {
|
|
4457
4548
|
return `<figure><img src="${href}" alt="${desc}"><figcaption>${desc}</figcaption></figure>`;
|
|
4458
4549
|
};
|
|
@@ -4469,13 +4560,12 @@ const useMarked = (props2) => {
|
|
|
4469
4560
|
});
|
|
4470
4561
|
}
|
|
4471
4562
|
const html = computed(() => {
|
|
4472
|
-
|
|
4473
|
-
const
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
}
|
|
4563
|
+
heads = [];
|
|
4564
|
+
const _html = marked(props2.value);
|
|
4565
|
+
highlightInited.value;
|
|
4566
|
+
mermaidData.reRender;
|
|
4567
|
+
mermaidData.mermaidInited;
|
|
4568
|
+
return props2.sanitize(_html);
|
|
4479
4569
|
});
|
|
4480
4570
|
const highlightLoad = () => {
|
|
4481
4571
|
marked.setOptions({
|
|
@@ -4488,8 +4578,8 @@ const useMarked = (props2) => {
|
|
|
4488
4578
|
};
|
|
4489
4579
|
watch(() => html.value, (nVal) => {
|
|
4490
4580
|
props2.onHtmlChanged(nVal);
|
|
4491
|
-
props2.onGetCatalog(
|
|
4492
|
-
bus.emit(editorId, "catalogChanged",
|
|
4581
|
+
props2.onGetCatalog(heads);
|
|
4582
|
+
bus.emit(editorId, "catalogChanged", heads);
|
|
4493
4583
|
});
|
|
4494
4584
|
return {
|
|
4495
4585
|
html,
|
|
@@ -4601,6 +4691,44 @@ ${nextOrder}. `, {}));
|
|
|
4601
4691
|
selectedText
|
|
4602
4692
|
};
|
|
4603
4693
|
};
|
|
4694
|
+
const useMermaid = (props2) => {
|
|
4695
|
+
const theme = inject("theme");
|
|
4696
|
+
const mermaidData = reactive({
|
|
4697
|
+
reRender: false,
|
|
4698
|
+
mermaidInited: !!props2.mermaid
|
|
4699
|
+
});
|
|
4700
|
+
watch(() => theme.value, () => {
|
|
4701
|
+
if (!props2.noMermaid && window.mermaid) {
|
|
4702
|
+
window.mermaid.initialize({
|
|
4703
|
+
theme: theme.value === "dark" ? "dark" : "default"
|
|
4704
|
+
});
|
|
4705
|
+
mermaidData.reRender = !mermaidData.reRender;
|
|
4706
|
+
}
|
|
4707
|
+
});
|
|
4708
|
+
let mermaidScript;
|
|
4709
|
+
onMounted(() => {
|
|
4710
|
+
if (!props2.noMermaid && props2.mermaid) {
|
|
4711
|
+
window.mermaid = props2.mermaid;
|
|
4712
|
+
} else if (!props2.noMermaid && !props2.mermaid) {
|
|
4713
|
+
mermaidScript = document.createElement("script");
|
|
4714
|
+
mermaidScript.src = props2.mermaidJs;
|
|
4715
|
+
mermaidScript.onload = () => {
|
|
4716
|
+
mermaidData.mermaidInited = true;
|
|
4717
|
+
window.mermaid.initialize({
|
|
4718
|
+
logLevel: "Fatal"
|
|
4719
|
+
});
|
|
4720
|
+
};
|
|
4721
|
+
mermaidScript.id = `${prefix}-mermaid`;
|
|
4722
|
+
appendHandler(mermaidScript);
|
|
4723
|
+
}
|
|
4724
|
+
});
|
|
4725
|
+
onBeforeUnmount(() => {
|
|
4726
|
+
if (!props2.noMermaid && !props2.mermaid && mermaidScript) {
|
|
4727
|
+
mermaidScript.remove();
|
|
4728
|
+
}
|
|
4729
|
+
});
|
|
4730
|
+
return mermaidData;
|
|
4731
|
+
};
|
|
4604
4732
|
var Content = defineComponent({
|
|
4605
4733
|
name: "MDEditorContent",
|
|
4606
4734
|
props: {
|
|
@@ -4634,6 +4762,25 @@ var Content = defineComponent({
|
|
|
4634
4762
|
markedHeading: {
|
|
4635
4763
|
type: Function,
|
|
4636
4764
|
default: () => (text, level) => `<h${level} id="${text}"><a href="#${text}">${text}</a></h${level}>`
|
|
4765
|
+
},
|
|
4766
|
+
mermaid: {
|
|
4767
|
+
type: Object
|
|
4768
|
+
},
|
|
4769
|
+
mermaidJs: {
|
|
4770
|
+
type: String,
|
|
4771
|
+
default: ""
|
|
4772
|
+
},
|
|
4773
|
+
noMermaid: {
|
|
4774
|
+
type: Boolean,
|
|
4775
|
+
default: false
|
|
4776
|
+
},
|
|
4777
|
+
sanitize: {
|
|
4778
|
+
type: Function,
|
|
4779
|
+
default: (html) => html
|
|
4780
|
+
},
|
|
4781
|
+
placeholder: {
|
|
4782
|
+
type: String,
|
|
4783
|
+
default: ""
|
|
4637
4784
|
}
|
|
4638
4785
|
},
|
|
4639
4786
|
setup(props2) {
|
|
@@ -4645,10 +4792,11 @@ var Content = defineComponent({
|
|
|
4645
4792
|
const textAreaRef = ref();
|
|
4646
4793
|
const previewRef = ref();
|
|
4647
4794
|
const htmlRef = ref();
|
|
4795
|
+
const mermaidData = useMermaid(props2);
|
|
4648
4796
|
const {
|
|
4649
4797
|
html,
|
|
4650
4798
|
highlightLoad
|
|
4651
|
-
} = useMarked(props2);
|
|
4799
|
+
} = useMarked(props2, mermaidData);
|
|
4652
4800
|
useAutoScroll(props2, html, textAreaRef, previewRef, htmlRef);
|
|
4653
4801
|
const {
|
|
4654
4802
|
selectedText
|
|
@@ -4667,7 +4815,8 @@ var Content = defineComponent({
|
|
|
4667
4815
|
selectedText.value = "";
|
|
4668
4816
|
props2.onChange(e.target.value);
|
|
4669
4817
|
},
|
|
4670
|
-
"class": [props2.setting.preview || props2.setting.htmlPreview ? "" : "textarea-only"]
|
|
4818
|
+
"class": [props2.setting.preview || props2.setting.htmlPreview ? "" : "textarea-only"],
|
|
4819
|
+
"placeholder": props2.placeholder
|
|
4671
4820
|
}, null)]), props2.setting.preview && createVNode("div", {
|
|
4672
4821
|
"ref": previewRef,
|
|
4673
4822
|
"id": `${prefix}-preview`,
|
|
@@ -4951,6 +5100,29 @@ const props = {
|
|
|
4951
5100
|
markedHeadingId: {
|
|
4952
5101
|
type: Function,
|
|
4953
5102
|
default: markedHeadingId
|
|
5103
|
+
},
|
|
5104
|
+
tableShape: {
|
|
5105
|
+
type: Array,
|
|
5106
|
+
default: () => [6, 4]
|
|
5107
|
+
},
|
|
5108
|
+
mermaid: {
|
|
5109
|
+
type: Object
|
|
5110
|
+
},
|
|
5111
|
+
mermaidJs: {
|
|
5112
|
+
type: String,
|
|
5113
|
+
default: mermaidUrl
|
|
5114
|
+
},
|
|
5115
|
+
noMermaid: {
|
|
5116
|
+
type: Boolean,
|
|
5117
|
+
default: false
|
|
5118
|
+
},
|
|
5119
|
+
sanitize: {
|
|
5120
|
+
type: Function,
|
|
5121
|
+
default: (html) => html
|
|
5122
|
+
},
|
|
5123
|
+
placeholder: {
|
|
5124
|
+
type: String,
|
|
5125
|
+
default: ""
|
|
4954
5126
|
}
|
|
4955
5127
|
};
|
|
4956
5128
|
var Editor = defineComponent({
|
|
@@ -5040,7 +5212,8 @@ var Editor = defineComponent({
|
|
|
5040
5212
|
"toolbars": props2.toolbars,
|
|
5041
5213
|
"toolbarsExclude": props2.toolbarsExclude,
|
|
5042
5214
|
"setting": setting,
|
|
5043
|
-
"updateSetting": updateSetting
|
|
5215
|
+
"updateSetting": updateSetting,
|
|
5216
|
+
"tableShape": props2.tableShape
|
|
5044
5217
|
}, null), createVNode(Content, {
|
|
5045
5218
|
"hljs": hljs,
|
|
5046
5219
|
"value": props2.modelValue,
|
|
@@ -5066,7 +5239,12 @@ var Editor = defineComponent({
|
|
|
5066
5239
|
context.emit("onGetCatalog", list);
|
|
5067
5240
|
}
|
|
5068
5241
|
},
|
|
5069
|
-
"markedHeading": props2.markedHeading
|
|
5242
|
+
"markedHeading": props2.markedHeading,
|
|
5243
|
+
"mermaid": props2.mermaid,
|
|
5244
|
+
"mermaidJs": props2.mermaidJs,
|
|
5245
|
+
"noMermaid": props2.noMermaid,
|
|
5246
|
+
"sanitize": props2.sanitize,
|
|
5247
|
+
"placeholder": props2.placeholder
|
|
5070
5248
|
}, null), catalogShow.value && createVNode(Catalog, {
|
|
5071
5249
|
"markedHeadingId": props2.markedHeadingId
|
|
5072
5250
|
}, null), !previewOnly && createVNode(Teleport, {
|