@cnblogs/markdown-it-presets 1.9.0-next → 1.9.0-next1

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.
Files changed (85) hide show
  1. package/dist/commonjs/index.cjs +3 -0
  2. package/dist/commonjs/index.cjs.map +1 -0
  3. package/dist/commonjs/math/factory.cjs +13 -0
  4. package/dist/commonjs/math/factory.cjs.map +1 -0
  5. package/dist/commonjs/math/impl.cjs +161 -0
  6. package/dist/commonjs/math/impl.cjs.map +1 -0
  7. package/dist/commonjs/math/index.cjs +3 -0
  8. package/dist/commonjs/math/index.cjs.map +1 -0
  9. package/dist/commonjs/math/model.cjs +20 -0
  10. package/dist/commonjs/math/model.cjs.map +1 -0
  11. package/dist/commonjs/presets/index.cjs +103 -0
  12. package/dist/commonjs/presets/index.cjs.map +1 -0
  13. package/dist/commonjs/presets/option.cjs +27 -0
  14. package/dist/commonjs/presets/option.cjs.map +1 -0
  15. package/dist/commonjs/presets/plugins/highlight-code-lines.plugin.cjs +49 -0
  16. package/dist/commonjs/presets/plugins/highlight-code-lines.plugin.cjs.map +1 -0
  17. package/dist/commonjs/presets/plugins/html-filter.plugin.cjs +43 -0
  18. package/dist/commonjs/presets/plugins/html-filter.plugin.cjs.map +1 -0
  19. package/dist/commonjs/presets/plugins/meta.cjs +36 -0
  20. package/dist/commonjs/presets/plugins/meta.cjs.map +1 -0
  21. package/dist/commonjs/presets/plugins/multiline-blockquote/multiline-blockquote.plugin.cjs +11 -0
  22. package/dist/commonjs/presets/plugins/multiline-blockquote/multiline-blockquote.plugin.cjs.map +1 -0
  23. package/dist/commonjs/presets/plugins/multiline-blockquote/multiline-blockquote.rule.cjs +40 -0
  24. package/dist/commonjs/presets/plugins/multiline-blockquote/multiline-blockquote.rule.cjs.map +1 -0
  25. package/dist/commonjs/presets/plugins/simple-math.plugin.cjs +147 -0
  26. package/dist/commonjs/presets/plugins/simple-math.plugin.cjs.map +1 -0
  27. package/dist/commonjs/presets/plugins/simple-mermaid.plugin.cjs +17 -0
  28. package/dist/commonjs/presets/plugins/simple-mermaid.plugin.cjs.map +1 -0
  29. package/dist/commonjs/presets/plugins/toc/index.cjs +184 -0
  30. package/dist/commonjs/presets/plugins/toc/index.cjs.map +1 -0
  31. package/dist/commonjs/presets/plugins/toc/slugify.cjs +5 -0
  32. package/dist/commonjs/presets/plugins/toc/slugify.cjs.map +1 -0
  33. package/dist/commonjs/presets/plugins/toc/toc-item.cjs +2 -0
  34. package/dist/commonjs/presets/plugins/toc/toc-item.cjs.map +1 -0
  35. package/dist/commonjs/presets/plugins/toc/toc-option.cjs +15 -0
  36. package/dist/commonjs/presets/plugins/toc/toc-option.cjs.map +1 -0
  37. package/dist/commonjs/presets/plugins/unique-custom-id.cjs +27 -0
  38. package/dist/commonjs/presets/plugins/unique-custom-id.cjs.map +1 -0
  39. package/dist/es6/index.mjs +3 -0
  40. package/dist/es6/index.mjs.map +1 -0
  41. package/dist/es6/math/factory.mjs +13 -0
  42. package/dist/es6/math/factory.mjs.map +1 -0
  43. package/dist/es6/math/impl.mjs +161 -0
  44. package/dist/es6/math/impl.mjs.map +1 -0
  45. package/dist/es6/math/index.mjs +3 -0
  46. package/dist/es6/math/index.mjs.map +1 -0
  47. package/dist/es6/math/model.mjs +20 -0
  48. package/dist/es6/math/model.mjs.map +1 -0
  49. package/dist/es6/presets/index.mjs +103 -0
  50. package/dist/es6/presets/index.mjs.map +1 -0
  51. package/dist/es6/presets/option.mjs +27 -0
  52. package/dist/es6/presets/option.mjs.map +1 -0
  53. package/dist/es6/presets/plugins/highlight-code-lines.plugin.mjs +49 -0
  54. package/dist/es6/presets/plugins/highlight-code-lines.plugin.mjs.map +1 -0
  55. package/dist/es6/presets/plugins/html-filter.plugin.mjs +43 -0
  56. package/dist/es6/presets/plugins/html-filter.plugin.mjs.map +1 -0
  57. package/dist/es6/presets/plugins/meta.mjs +36 -0
  58. package/dist/es6/presets/plugins/meta.mjs.map +1 -0
  59. package/dist/es6/presets/plugins/multiline-blockquote/multiline-blockquote.plugin.mjs +11 -0
  60. package/dist/es6/presets/plugins/multiline-blockquote/multiline-blockquote.plugin.mjs.map +1 -0
  61. package/dist/es6/presets/plugins/multiline-blockquote/multiline-blockquote.rule.mjs +40 -0
  62. package/dist/es6/presets/plugins/multiline-blockquote/multiline-blockquote.rule.mjs.map +1 -0
  63. package/dist/es6/presets/plugins/simple-math.plugin.mjs +147 -0
  64. package/dist/es6/presets/plugins/simple-math.plugin.mjs.map +1 -0
  65. package/dist/es6/presets/plugins/simple-mermaid.plugin.mjs +17 -0
  66. package/dist/es6/presets/plugins/simple-mermaid.plugin.mjs.map +1 -0
  67. package/dist/es6/presets/plugins/toc/index.mjs +184 -0
  68. package/dist/es6/presets/plugins/toc/index.mjs.map +1 -0
  69. package/dist/es6/presets/plugins/toc/slugify.mjs +5 -0
  70. package/dist/es6/presets/plugins/toc/slugify.mjs.map +1 -0
  71. package/dist/es6/presets/plugins/toc/toc-item.mjs +2 -0
  72. package/dist/es6/presets/plugins/toc/toc-item.mjs.map +1 -0
  73. package/dist/es6/presets/plugins/toc/toc-option.mjs +15 -0
  74. package/dist/es6/presets/plugins/toc/toc-option.mjs.map +1 -0
  75. package/dist/es6/presets/plugins/unique-custom-id.mjs +27 -0
  76. package/dist/es6/presets/plugins/unique-custom-id.mjs.map +1 -0
  77. package/dist/styles/task-lists.less +19 -0
  78. package/dist/styles/task-lists.min.css +1 -0
  79. package/dist/styles/task-lists.min.js +1 -0
  80. package/dist/types/index.d.ts +97 -0
  81. package/dist/types/math/index.d.ts +47 -0
  82. package/dist/types/tsdoc-metadata.json +11 -0
  83. package/dist/umd/markdownItPresets.js +1 -0
  84. package/dist/umd/mathRenderer.js +1 -0
  85. package/package.json +3 -3
@@ -0,0 +1,184 @@
1
+ import { defaultTocOption } from './toc-option';
2
+ const defaults = defaultTocOption;
3
+ const findHeadlineElements = (levels, tokens, options, md, env) => {
4
+ const headings = [];
5
+ let currentHeading = null;
6
+ tokens.forEach(token => {
7
+ if (token.type === 'heading_open') {
8
+ const id = findExistingIdAttr(token);
9
+ const level = parseInt(token.tag.toLowerCase().replace('h', ''), 10);
10
+ if (levels.indexOf(level) >= 0) {
11
+ currentHeading = {
12
+ level: level,
13
+ textContent: null,
14
+ anchor: id || null,
15
+ markdownContent: null,
16
+ };
17
+ }
18
+ }
19
+ else if (currentHeading && token.type === 'inline') {
20
+ const textContent = token.children
21
+ .filter(childToken => childToken.type === 'text' || childToken.type === 'code_inline')
22
+ .reduce((acc, t) => acc + t.content, '');
23
+ currentHeading.textContent = textContent;
24
+ currentHeading.markdownContent = md.renderer.renderInline(token.children, options, env);
25
+ if (!currentHeading.anchor) {
26
+ currentHeading.anchor = options.slugify(textContent, token.content);
27
+ }
28
+ }
29
+ else if (token.type === 'heading_close') {
30
+ if (currentHeading) {
31
+ headings.push(currentHeading);
32
+ }
33
+ currentHeading = null;
34
+ }
35
+ });
36
+ return headings;
37
+ };
38
+ const findExistingIdAttr = (token) => {
39
+ if (token && token.attrs && token.attrs.length > 0) {
40
+ const idAttr = token.attrs.find(attr => {
41
+ if (Array.isArray(attr) && attr.length >= 2) {
42
+ return attr[0] === 'id';
43
+ }
44
+ return false;
45
+ });
46
+ if (idAttr && Array.isArray(idAttr) && idAttr.length >= 2) {
47
+ const [, val] = idAttr;
48
+ return val;
49
+ }
50
+ }
51
+ return null;
52
+ };
53
+ function getMinLevel(headlineItems) {
54
+ return Math.min(...headlineItems.map(item => item.level));
55
+ }
56
+ const addListItem = (level, text, anchor, rootNode) => {
57
+ const listItem = {
58
+ level,
59
+ text,
60
+ anchor,
61
+ children: [],
62
+ parent: rootNode,
63
+ };
64
+ rootNode.children.push(listItem);
65
+ return listItem;
66
+ };
67
+ const flatHeadlineItemsToNestedTree = (headlineItems) => {
68
+ const toc = {
69
+ level: getMinLevel(headlineItems) - 1,
70
+ anchor: null,
71
+ text: null,
72
+ children: [],
73
+ parent: null,
74
+ };
75
+ let currentRootNode = toc;
76
+ let prevListItem = currentRootNode;
77
+ headlineItems.forEach(headlineItem => {
78
+ if (headlineItem.level > prevListItem.level) {
79
+ Array.from({ length: headlineItem.level - prevListItem.level }).forEach(_ => {
80
+ currentRootNode = prevListItem;
81
+ prevListItem = addListItem(headlineItem.level, null, null, currentRootNode);
82
+ });
83
+ prevListItem.text = headlineItem.markdownContent;
84
+ prevListItem.anchor = headlineItem.anchor;
85
+ }
86
+ else if (headlineItem.level === prevListItem.level) {
87
+ prevListItem = addListItem(headlineItem.level, headlineItem.markdownContent, headlineItem.anchor, currentRootNode);
88
+ }
89
+ else if (headlineItem.level < prevListItem.level) {
90
+ for (let i = 0; i < prevListItem.level - headlineItem.level; i++) {
91
+ currentRootNode = currentRootNode.parent;
92
+ }
93
+ prevListItem = addListItem(headlineItem.level, headlineItem.markdownContent, headlineItem.anchor, currentRootNode);
94
+ }
95
+ });
96
+ return toc;
97
+ };
98
+ const tocItemToHtml = (tocItem, options, md) => {
99
+ return ('<' +
100
+ options.listType +
101
+ '>' +
102
+ tocItem.children
103
+ .map(childItem => {
104
+ let li = '<li>';
105
+ let anchor = childItem.anchor;
106
+ if (options && options.transformLink) {
107
+ anchor = options.transformLink(anchor);
108
+ }
109
+ let text = childItem.text ? options.format(childItem.text, md, anchor) : null;
110
+ li += anchor ? `<a href="#${anchor}">${text}</a>` : text || '';
111
+ return li + (childItem.children.length > 0 ? tocItemToHtml(childItem, options, md) : '') + '</li>';
112
+ })
113
+ .join('') +
114
+ '</' +
115
+ options.listType +
116
+ '>');
117
+ };
118
+ const plugin = (md, o) => {
119
+ const options = Object.assign({}, defaults, o);
120
+ const tocRegexp = options.markerPattern;
121
+ let gState;
122
+ const toc = (state, silent) => {
123
+ let token;
124
+ let match;
125
+ if (state.src.charCodeAt(state.pos) !== 0x5b) {
126
+ return false;
127
+ }
128
+ if (silent) {
129
+ return false;
130
+ }
131
+ match = tocRegexp.exec(state.src.substr(state.pos));
132
+ match = !match
133
+ ? []
134
+ : match.filter(function (m) {
135
+ return m;
136
+ });
137
+ if (match.length < 1) {
138
+ return false;
139
+ }
140
+ token = state.push('toc_open', 'toc', 1);
141
+ token.markup = '[[toc]]';
142
+ token = state.push('toc_body', '', 0);
143
+ token = state.push('toc_close', 'toc', -1);
144
+ const newline = state.src.indexOf('\n', state.pos);
145
+ if (newline !== -1) {
146
+ state.pos = newline;
147
+ }
148
+ else {
149
+ state.pos = state.pos + state.posMax + 1;
150
+ }
151
+ return true;
152
+ };
153
+ md.renderer.rules.toc_open = (tokens, index) => {
154
+ let tocOpenHtml = '<div class="' + options.containerClass + '">';
155
+ if (options.containerHeaderHtml) {
156
+ tocOpenHtml += options.containerHeaderHtml;
157
+ }
158
+ return tocOpenHtml;
159
+ };
160
+ md.renderer.rules.toc_close = (tokens, index) => {
161
+ let tocFooterHtml = '';
162
+ if (options.containerFooterHtml) {
163
+ tocFooterHtml = options.containerFooterHtml;
164
+ }
165
+ return tocFooterHtml + '</div>';
166
+ };
167
+ md.renderer.rules.toc_body = (tokens, index, opt, env) => {
168
+ if (options.forceFullToc) {
169
+ throw 'forceFullToc was removed in version 0.5.0. For more information, see https://github.com/Oktavilla/markdown-it-table-of-contents/pull/41';
170
+ }
171
+ else {
172
+ const headlineItems = findHeadlineElements(options.includeLevel, gState.tokens, options, md, env);
173
+ const toc = flatHeadlineItemsToNestedTree(headlineItems);
174
+ return tocItemToHtml(toc, options, md);
175
+ }
176
+ };
177
+ md.core.ruler.push('grab_state', state => {
178
+ gState = state;
179
+ return true;
180
+ });
181
+ md.inline.ruler.after('emphasis', 'toc', toc);
182
+ };
183
+ export { plugin as TocPlugin };
184
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/presets/plugins/toc/index.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,gBAAgB,EAAa,MAAM,cAAc,CAAC;AAI3D,MAAM,QAAQ,GAAG,gBAAgB,CAAC;AAkClC,MAAM,oBAAoB,GAAG,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G,oBAAoB,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;YAClG,MAAM,GAAG,GAAG,6BAA6B,CAAC,aAAa,CAAC,CAAC;YACzD,OAAO,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;SAC1C;IACL,CAAC,CAAC;IAGF,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,CAAC,EAAE;QACrC,MAAM,GAAG,KAAK,CAAC;QACf,OAAO,IAAI,CAAC;IAChB,CAAC,CAAC,CAAC;IAGH,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;AAClD,CAAC,CAAC;AAEF,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,CAAC"}
@@ -0,0 +1,5 @@
1
+ const slugify = function (s) {
2
+ return encodeURIComponent(String(s).trim().toLowerCase().replace(/\s+/g, '-'));
3
+ };
4
+ export { slugify };
5
+ //# sourceMappingURL=slugify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slugify.js","sourceRoot":"","sources":["../../../../../src/presets/plugins/toc/slugify.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG,UAAU,CAAC;IACvB,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;AACnF,CAAC,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=toc-item.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toc-item.js","sourceRoot":"","sources":["../../../../../src/presets/plugins/toc/toc-item.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ import { slugify } from './slugify';
2
+ const defaultTocOption = {
3
+ includeLevel: [1, 2, 3, 4, 5, 6],
4
+ containerClass: 'toc',
5
+ slugify: slugify,
6
+ markerPattern: /\[TOC]/im,
7
+ listType: 'ul',
8
+ format: content => content.replace(/<\/?a.*?>/g, ''),
9
+ forceFullToc: false,
10
+ containerHeaderHtml: `<div class="toc-container-header">目录</div>`,
11
+ containerFooterHtml: undefined,
12
+ transformLink: undefined,
13
+ };
14
+ export { defaultTocOption };
15
+ //# sourceMappingURL=toc-option.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toc-option.js","sourceRoot":"","sources":["../../../../../src/presets/plugins/toc/toc-option.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAepC,MAAM,gBAAgB,GAAG;IACrB,YAAY,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAChC,cAAc,EAAE,KAAK;IACrB,OAAO,EAAE,OAAO;IAChB,aAAa,EAAE,UAAU;IACzB,QAAQ,EAAE,IAAI;IACd,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;IACpD,YAAY,EAAE,KAAK;IACnB,mBAAmB,EAAE,4CAA4C;IACjE,mBAAmB,EAAE,SAAS;IAC9B,aAAa,EAAE,SAAS;CAC3B,CAAC;AAEF,OAAO,EAAa,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,27 @@
1
+ const attrPluginName = 'curly_attributes';
2
+ const uniqueCustomIdAttr = state => {
3
+ const { tokens } = state;
4
+ let map;
5
+ tokens
6
+ .filter(x => !!x.attrGet('id'))
7
+ .forEach(token => {
8
+ map !== null && map !== void 0 ? map : (map = {});
9
+ const idAttrValue = token.attrGet('id');
10
+ if (map.hasOwnProperty(idAttrValue)) {
11
+ const count = map[idAttrValue];
12
+ token.attrSet('id', `${idAttrValue}-${count}`);
13
+ map[idAttrValue] = count + 1;
14
+ }
15
+ else {
16
+ map[idAttrValue] = 1;
17
+ }
18
+ });
19
+ map = undefined;
20
+ };
21
+ const plugin = (md, opt) => {
22
+ if (md.core.ruler.getRules('').some(x => x.name === attrPluginName) != null) {
23
+ md.core.ruler.after(attrPluginName, 'unique_custom_id_attribute', uniqueCustomIdAttr, opt);
24
+ }
25
+ };
26
+ export { plugin as UniqueCustomIdAttrs };
27
+ //# sourceMappingURL=unique-custom-id.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unique-custom-id.js","sourceRoot":"","sources":["../../../../src/presets/plugins/unique-custom-id.ts"],"names":[],"mappings":"AAGA,MAAM,cAAc,GAAG,kBAAkB,CAAC;AAE1C,MAAM,kBAAkB,GAAa,KAAK,CAAC,EAAE;IACzC,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IACzB,IAAI,GAA0C,CAAC;IAC/C,MAAM;SACD,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SAC9B,OAAO,CAAC,KAAK,CAAC,EAAE;QACb,GAAG,aAAH,GAAG,cAAH,GAAG,IAAH,GAAG,GAAK,EAAE,EAAC;QACX,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,GAAG,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE;YACjC,MAAM,KAAK,GAAG,GAAG,CAAC,WAAW,CAAC,CAAC;YAC/B,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,WAAW,IAAI,KAAK,EAAE,CAAC,CAAC;YAC/C,GAAG,CAAC,WAAW,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;SAChC;aAAM;YACH,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;SACxB;IACL,CAAC,CAAC,CAAC;IACP,GAAG,GAAG,SAAS,CAAC;AACpB,CAAC,CAAC;AAEF,MAAM,MAAM,GAAsB,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE;IAC1C,IAAI,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,cAAc,CAAC,IAAI,IAAI,EAAE;QACzE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,EAAE,4BAA4B,EAAE,kBAAkB,EAAE,GAAG,CAAC,CAAC;KAC9F;AACL,CAAC,CAAC;AAEF,OAAO,EAAE,MAAM,IAAI,mBAAmB,EAAE,CAAC"}
@@ -0,0 +1,19 @@
1
+ .contains-task-list {
2
+ & {
3
+ margin-left: 0;
4
+ padding-left: 0;
5
+ }
6
+
7
+ li.task-list-item {
8
+ display: flex;
9
+ align-items: center;
10
+ //noinspection CssReplaceWithShorthandSafely
11
+ list-style: none;
12
+ //noinspection CssOverwrittenProperties,CssReplaceWithShorthandSafely
13
+ list-style-type: none;
14
+
15
+ input.task-list-item-checkbox {
16
+ margin: 0 6px 0 0;
17
+ }
18
+ }
19
+ }
@@ -0,0 +1 @@
1
+ .contains-task-list{margin-left:0;padding-left:0}.contains-task-list li.task-list-item{align-items:center;display:flex;list-style:none;list-style-type:none}.contains-task-list li.task-list-item input.task-list-item-checkbox{margin:0 6px 0 0}
@@ -0,0 +1 @@
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["styles/task-lists.min"]=t():e["styles/task-lists.min"]=t()}(self,(function(){return function(){"use strict";var e={};return function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}(e),e}()}));
@@ -0,0 +1,97 @@
1
+ /// <reference types="mathjax2" />
2
+
3
+ import MarkdownIt from 'markdown-it';
4
+ import { MathJaxConfig as MathJaxConfig_2 } from 'mathjax-full/js/components/startup';
5
+ import { MathJaxObject as MathJaxObject_2 } from 'mathjax-full/js/components/startup';
6
+ import MdAnchor from 'markdown-it-anchor';
7
+ import { Options } from 'linkify-it';
8
+ import { PluginWithOptions } from 'markdown-it';
9
+ import { RuleBlock } from 'markdown-it/lib/parser_block';
10
+
11
+ export declare const anchorOption: MdAnchor.AnchorOptions;
12
+
13
+ export declare const createMathJaxRenderer: <T extends Partial<MathJax2RendererConfig | MathJax3RendererConfig>>(rendererConfig: T) => IMathRenderer<MathEngine.MathJax2> | IMathRenderer<MathEngine.MathJax3>;
14
+
15
+ export declare const defaultLinkifyOptions: LinkifyOption;
16
+
17
+ export declare const defaultMarkdownItOption: MarkdownItPresetOption;
18
+
19
+ export declare const defaultTaskListsOption: TaskListsOption;
20
+
21
+ export declare interface HighlightCodeLinesOptions {
22
+ enable?: (md: MarkdownIt) => boolean;
23
+ }
24
+
25
+ export declare const HighlightCodeLinesPlugin: PluginWithOptions<HighlightCodeLinesOptions>;
26
+
27
+ export declare interface IMathRenderer<TEngine extends MathEngine> {
28
+ config(value: Partial<RendererConfig<TEngine>>): this;
29
+ render(container: HTMLElement, callback?: () => unknown): Promise<void>;
30
+ }
31
+
32
+ declare type LinkifyOption = Options & {
33
+ fuzzyLinkUseHttps?: boolean;
34
+ };
35
+
36
+ export { MarkdownIt }
37
+
38
+ export declare const markdownItFactory: ({ html, codeHighlight, taskListsOption, math, disableRules, linkify: linkifyOption, }?: MarkdownItPresetOption) => MarkdownIt;
39
+
40
+ export declare interface MarkdownItPresetOption {
41
+ codeHighlight: boolean;
42
+ math: boolean;
43
+ html: boolean;
44
+ disableRules: string[];
45
+ taskListsOption?: TaskListsOption;
46
+ linkify?: LinkifyOption;
47
+ }
48
+
49
+ export declare enum MathEngine {
50
+ MathJax2 = 0,
51
+ MathJax3 = 1
52
+ }
53
+
54
+ export declare type MathJax2RendererConfig = RendererConfig<MathEngine.MathJax2> & {
55
+ engine: MathEngine.MathJax2;
56
+ };
57
+
58
+ export declare type MathJax3RendererConfig = RendererConfig<MathEngine.MathJax3> & {
59
+ engine: MathEngine.MathJax3;
60
+ };
61
+
62
+ declare type MathJaxConfig = MathJaxConfig_2 & {
63
+ tex: Record<string, unknown>;
64
+ [name: string]: unknown;
65
+ };
66
+
67
+ declare interface MathJaxObject {
68
+ config: MathJaxConfig;
69
+ startup: MathJaxObject_2['startup'];
70
+ typeset(arg: unknown[]): void;
71
+ typesetPromise(arg: unknown[]): Promise<void>;
72
+ }
73
+
74
+ export declare interface MultilineBlockquoteOptions {
75
+ enable?: (md: MarkdownIt) => boolean;
76
+ }
77
+
78
+ export declare const MultilineBlockquotePlugin: PluginWithOptions<MultilineBlockquoteOptions>;
79
+
80
+ export declare const MultilineBlockquoteRule: RuleBlock;
81
+
82
+ export declare interface RendererConfig<TEngine extends MathEngine> {
83
+ engine: MathEngine;
84
+ entryScript: string;
85
+ document: Document;
86
+ isEnabled: boolean;
87
+ onRendered?: (mathjax: TEngine extends MathEngine.MathJax2 ? typeof MathJax : MathJaxObject) => void | Promise<void>;
88
+ tapMathJaxConfig?: <TConfig = TEngine extends MathEngine.MathJax2 ? MathJax.Config : MathJaxConfig>(config: TConfig) => TConfig;
89
+ }
90
+
91
+ export declare interface TaskListsOption {
92
+ enable: boolean;
93
+ label: boolean;
94
+ labelAfter: boolean;
95
+ }
96
+
97
+ export { }
@@ -0,0 +1,47 @@
1
+ /// <reference types="mathjax2" />
2
+
3
+ import { MathJaxConfig as MathJaxConfig_2 } from 'mathjax-full/js/components/startup';
4
+ import { MathJaxObject as MathJaxObject_2 } from 'mathjax-full/js/components/startup';
5
+
6
+ export declare const createMathJaxRenderer: <T extends Partial<MathJax2RendererConfig | MathJax3RendererConfig>>(rendererConfig: T) => IMathRenderer<MathEngine.MathJax2> | IMathRenderer<MathEngine.MathJax3>;
7
+
8
+ export declare interface IMathRenderer<TEngine extends MathEngine> {
9
+ config(value: Partial<RendererConfig<TEngine>>): this;
10
+ render(container: HTMLElement, callback?: () => unknown): Promise<void>;
11
+ }
12
+
13
+ export declare enum MathEngine {
14
+ MathJax2 = 0,
15
+ MathJax3 = 1
16
+ }
17
+
18
+ export declare type MathJax2RendererConfig = RendererConfig<MathEngine.MathJax2> & {
19
+ engine: MathEngine.MathJax2;
20
+ };
21
+
22
+ export declare type MathJax3RendererConfig = RendererConfig<MathEngine.MathJax3> & {
23
+ engine: MathEngine.MathJax3;
24
+ };
25
+
26
+ declare type MathJaxConfig = MathJaxConfig_2 & {
27
+ tex: Record<string, unknown>;
28
+ [name: string]: unknown;
29
+ };
30
+
31
+ declare interface MathJaxObject {
32
+ config: MathJaxConfig;
33
+ startup: MathJaxObject_2['startup'];
34
+ typeset(arg: unknown[]): void;
35
+ typesetPromise(arg: unknown[]): Promise<void>;
36
+ }
37
+
38
+ export declare interface RendererConfig<TEngine extends MathEngine> {
39
+ engine: MathEngine;
40
+ entryScript: string;
41
+ document: Document;
42
+ isEnabled: boolean;
43
+ onRendered?: (mathjax: TEngine extends MathEngine.MathJax2 ? typeof MathJax : MathJaxObject) => void | Promise<void>;
44
+ tapMathJaxConfig?: <TConfig = TEngine extends MathEngine.MathJax2 ? MathJax.Config : MathJaxConfig>(config: TConfig) => TConfig;
45
+ }
46
+
47
+ export { }
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.34.4"
9
+ }
10
+ ]
11
+ }