mathpix-markdown-it 1.0.83 → 1.0.85
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/.idea/vcs.xml +1 -0
- package/.idea/workspace.xml +588 -455
- package/README.md +2 -2
- package/doc/images/sections/section_01.png +0 -0
- package/doc/images/sections/section_02.png +0 -0
- package/doc/images/sections/section_03.png +0 -0
- package/doc/images/sections/section_04.png +0 -0
- package/doc/sections.md +103 -0
- package/es5/bundle.js +1 -1
- package/es5/context-menu.js +1 -1
- package/es5/index.js +1 -1
- package/lib/contex-menu/index.js +8 -8
- package/lib/contex-menu/index.js.map +1 -1
- package/lib/contex-menu/menu/consts.d.ts +6 -1
- package/lib/contex-menu/menu/consts.js +15 -2
- package/lib/contex-menu/menu/consts.js.map +1 -1
- package/lib/contex-menu/menu/helper.d.ts +2 -1
- package/lib/contex-menu/menu/helper.js +25 -7
- package/lib/contex-menu/menu/helper.js.map +1 -1
- package/lib/contex-menu/menu/menu-item-actions.js +1 -1
- package/lib/contex-menu/menu/menu-item-actions.js.map +1 -1
- package/lib/contex-menu/menu/menu-item.js +12 -0
- package/lib/contex-menu/menu/menu-item.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/markdown/common/consts.d.ts +11 -0
- package/lib/markdown/common/consts.js +12 -1
- package/lib/markdown/common/consts.js.map +1 -1
- package/lib/markdown/common/tsv.js +4 -2
- package/lib/markdown/common/tsv.js.map +1 -1
- package/lib/markdown/common.d.ts +30 -0
- package/lib/markdown/common.js +76 -1
- package/lib/markdown/common.js.map +1 -1
- package/lib/markdown/md-block-rule/begin-tabular/index.d.ts +1 -0
- package/lib/markdown/md-block-rule/begin-tabular/index.js +1 -0
- package/lib/markdown/md-block-rule/begin-tabular/index.js.map +1 -1
- package/lib/markdown/md-block-rule/begin-tabular/multi-column-row.js +23 -4
- package/lib/markdown/md-block-rule/begin-tabular/multi-column-row.js.map +1 -1
- package/lib/markdown/md-block-rule/begin-tabular/sub-math.d.ts +1 -1
- package/lib/markdown/md-block-rule/begin-tabular/sub-math.js +16 -7
- package/lib/markdown/md-block-rule/begin-tabular/sub-math.js.map +1 -1
- package/lib/markdown/md-block-rule/begin-tabular/tabular-td.js +2 -1
- package/lib/markdown/md-block-rule/begin-tabular/tabular-td.js.map +1 -1
- package/lib/markdown/md-inline-rule/setcounter-section.d.ts +6 -0
- package/lib/markdown/md-inline-rule/setcounter-section.js +47 -0
- package/lib/markdown/md-inline-rule/setcounter-section.js.map +1 -0
- package/lib/markdown/md-renderer-rules/render-tabular.js +1 -1
- package/lib/markdown/md-renderer-rules/render-tabular.js.map +1 -1
- package/lib/markdown/md-theorem/block-rule.js +23 -8
- package/lib/markdown/md-theorem/block-rule.js.map +1 -1
- package/lib/markdown/md-theorem/index.js +6 -2
- package/lib/markdown/md-theorem/index.js.map +1 -1
- package/lib/markdown/md-theorem/inline-rule.js +106 -53
- package/lib/markdown/md-theorem/inline-rule.js.map +1 -1
- package/lib/markdown/mdPluginRaw.js +42 -1
- package/lib/markdown/mdPluginRaw.js.map +1 -1
- package/lib/markdown/mdPluginTOC.d.ts +14 -0
- package/lib/markdown/mdPluginTOC.js +105 -96
- package/lib/markdown/mdPluginTOC.js.map +1 -1
- package/lib/markdown/mdPluginText.d.ts +7 -1
- package/lib/markdown/mdPluginText.js +248 -105
- package/lib/markdown/mdPluginText.js.map +1 -1
- package/lib/markdown/rules.js +6 -5
- package/lib/markdown/rules.js.map +1 -1
- package/lib/markdown/test.d.ts +0 -0
- package/lib/markdown/test.js +399 -0
- package/lib/markdown/test.js.map +1 -0
- package/lib/mathjax/helpers/array/ArrayConfiguration.d.ts +6 -0
- package/lib/mathjax/helpers/array/ArrayConfiguration.js +14 -0
- package/lib/mathjax/helpers/array/ArrayConfiguration.js.map +1 -0
- package/lib/mathjax/helpers/array/ArrayMappings.d.ts +1 -0
- package/lib/mathjax/helpers/array/ArrayMappings.js +12 -0
- package/lib/mathjax/helpers/array/ArrayMappings.js.map +1 -0
- package/lib/mathjax/helpers/array/ArrayMethods.d.ts +6 -0
- package/lib/mathjax/helpers/array/ArrayMethods.js +28 -0
- package/lib/mathjax/helpers/array/ArrayMethods.js.map +1 -0
- package/lib/mathjax/index.d.ts +2 -0
- package/lib/mathjax/index.js +45 -8
- package/lib/mathjax/index.js.map +1 -1
- package/lib/mathjax/mathjax.d.ts +4 -0
- package/lib/mathjax/mathjax.js +12 -0
- package/lib/mathjax/mathjax.js.map +1 -1
- package/lib/mathjax/serialized-ascii/handlers.d.ts +2 -0
- package/lib/mathjax/serialized-ascii/handlers.js +246 -48
- package/lib/mathjax/serialized-ascii/handlers.js.map +1 -1
- package/lib/mathjax/serialized-ascii/helperA.d.ts +46 -0
- package/lib/mathjax/serialized-ascii/helperA.js +135 -124
- package/lib/mathjax/serialized-ascii/helperA.js.map +1 -1
- package/lib/mathjax/serialized-ascii/index.d.ts +3 -0
- package/lib/mathjax/serialized-ascii/index.js +43 -5
- package/lib/mathjax/serialized-ascii/index.js.map +1 -1
- package/lib/mathpix-markdown-model/index.d.ts +2 -1
- package/lib/mathpix-markdown-model/index.js +6 -1
- package/lib/mathpix-markdown-model/index.js.map +1 -1
- package/lib/styles/index.js +1 -1
- package/lib/styles/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,23 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resetTextCounter = exports.resetCounter = void 0;
|
|
3
|
+
exports.renderInlineContent = exports.headingSection = exports.setTextCounterSection = exports.resetTextCounter = exports.resetCounter = exports.subSubCount = exports.subCount = exports.sectionCount = void 0;
|
|
4
|
+
var isSpace = require('markdown-it/lib/common/utils').isSpace;
|
|
4
5
|
var render_tabular_1 = require("./md-renderer-rules/render-tabular");
|
|
5
6
|
var consts_1 = require("./common/consts");
|
|
7
|
+
var common_1 = require("./common");
|
|
6
8
|
// import { escapeHtml } from 'markdown-it/lib/common/utils';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var subSubCount = 0;
|
|
9
|
+
exports.sectionCount = 0;
|
|
10
|
+
exports.subCount = 0;
|
|
11
|
+
exports.subSubCount = 0;
|
|
11
12
|
var isNewSect = false;
|
|
12
13
|
var isNewSubSection = false;
|
|
13
14
|
exports.resetCounter = function () {
|
|
14
|
-
|
|
15
|
+
exports.resetTextCounter();
|
|
15
16
|
};
|
|
16
17
|
exports.resetTextCounter = function () {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
exports.sectionCount = 0;
|
|
19
|
+
exports.subCount = 0;
|
|
20
|
+
exports.subSubCount = 0;
|
|
21
|
+
};
|
|
22
|
+
exports.setTextCounterSection = function (envName, num) {
|
|
23
|
+
switch (envName) {
|
|
24
|
+
case "section":
|
|
25
|
+
exports.sectionCount = num;
|
|
26
|
+
break;
|
|
27
|
+
case "subsection":
|
|
28
|
+
exports.subCount = num;
|
|
29
|
+
break;
|
|
30
|
+
case "subsubsection":
|
|
31
|
+
exports.subSubCount = num;
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
21
34
|
};
|
|
22
35
|
var separatingSpan = function (state, startLine, endLine) {
|
|
23
36
|
var lineText, pos = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine];
|
|
@@ -56,11 +69,136 @@ var separatingSpan = function (state, startLine, endLine) {
|
|
|
56
69
|
// state.pos = nextPos;
|
|
57
70
|
return true;
|
|
58
71
|
};
|
|
59
|
-
|
|
72
|
+
/**
|
|
73
|
+
* To add an unnumbered section to the table of contents, use the \addcontentsline command like this:
|
|
74
|
+
* \addcontentsline{toc}{section}{Unnumbered Section}
|
|
75
|
+
* */
|
|
76
|
+
var addContentsLineBlock = function (state, startLine, endLine) {
|
|
77
|
+
var _a, _b;
|
|
78
|
+
var token, lineText, pos = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine];
|
|
79
|
+
var startPos = 0;
|
|
80
|
+
var nextLine = startLine + 1;
|
|
81
|
+
var latex = '';
|
|
82
|
+
lineText = state.src.slice(pos, max).trim();
|
|
83
|
+
if (state.src.charCodeAt(pos) !== 0x5c /* \ */) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
var match = lineText
|
|
87
|
+
.slice(startPos)
|
|
88
|
+
.match(consts_1.reAddContentsLine);
|
|
89
|
+
if (!match) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
var envExp = ((_a = match.groups) === null || _a === void 0 ? void 0 : _a.exp) ? match.groups.exp : match[1];
|
|
93
|
+
if (envExp !== 'toc') {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
var envUnit = ((_b = match.groups) === null || _b === void 0 ? void 0 : _b.unit) ? match.groups.unit : match[2];
|
|
97
|
+
if (!['section', 'subsection', 'subsubsection'].includes(envUnit)) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
startPos += match[0].length;
|
|
101
|
+
latex = match[0];
|
|
102
|
+
// nextPos += match[0].length;
|
|
103
|
+
// \addcontentsline{toc}{section} {Unnumbered Section}
|
|
104
|
+
// ^^ skipping these spaces
|
|
105
|
+
for (; startPos < max; startPos++) {
|
|
106
|
+
var code = lineText.charCodeAt(startPos);
|
|
107
|
+
if (!isSpace(code) && code !== 0x0A) {
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (startPos >= max) {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
// \addcontentsline{toc}{section}{Unnumbered Section}
|
|
115
|
+
// ^^ should be {
|
|
116
|
+
if (lineText.charCodeAt(startPos) !== 123 /* { */) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
var _c = common_1.findEndMarker(lineText, startPos), _d = _c.res, res = _d === void 0 ? false : _d, _e = _c.content, content = _e === void 0 ? '' : _e, _f = _c.nextPos, nextPos = _f === void 0 ? 0 : _f;
|
|
120
|
+
var resString = content;
|
|
121
|
+
var hasEndMarker = false;
|
|
122
|
+
var last = nextLine;
|
|
123
|
+
var inlineStr = '';
|
|
124
|
+
if (!res) {
|
|
125
|
+
for (; nextLine <= endLine; nextLine++) {
|
|
126
|
+
if (lineText === '') {
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
pos = state.bMarks[nextLine] + state.tShift[nextLine];
|
|
130
|
+
max = state.eMarks[nextLine];
|
|
131
|
+
lineText = state.src.slice(pos, max);
|
|
132
|
+
var _g = common_1.findEndMarker(lineText, -1, "{", "}", true), _h = _g.res, res_1 = _h === void 0 ? false : _h, _j = _g.content, content_1 = _j === void 0 ? '' : _j, _k = _g.nextPos, nextPos_1 = _k === void 0 ? 0 : _k;
|
|
133
|
+
if (res_1) {
|
|
134
|
+
resString += resString ? ' ' : '';
|
|
135
|
+
resString += content_1;
|
|
136
|
+
hasEndMarker = true;
|
|
137
|
+
if (nextPos_1 && nextPos_1 < lineText.length) {
|
|
138
|
+
inlineStr = lineText.slice(nextPos_1);
|
|
139
|
+
}
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
resString += resString ? ' ' : '';
|
|
143
|
+
resString += lineText;
|
|
144
|
+
}
|
|
145
|
+
last = nextLine + 1;
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
hasEndMarker = true;
|
|
149
|
+
last = nextLine;
|
|
150
|
+
if (nextPos && nextPos < lineText.length) {
|
|
151
|
+
inlineStr = lineText.slice(nextPos);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (!hasEndMarker) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
var level;
|
|
158
|
+
switch (envUnit) {
|
|
159
|
+
case 'section':
|
|
160
|
+
level = 2;
|
|
161
|
+
break;
|
|
162
|
+
case 'subsection':
|
|
163
|
+
level = 3;
|
|
164
|
+
break;
|
|
165
|
+
case 'subsubsection':
|
|
166
|
+
level = 4;
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
state.line = last;
|
|
170
|
+
token = state.push('addcontentsline_open', 'div', 1);
|
|
171
|
+
if (state.md.options.forLatex) {
|
|
172
|
+
token.latex = latex + '{';
|
|
173
|
+
}
|
|
174
|
+
token.map = [startLine, state.line];
|
|
175
|
+
token.envLevel = level;
|
|
176
|
+
token.attrJoin('class', 'addcontentsline');
|
|
177
|
+
token.attrSet('style', 'margin-top: 0; margin-bottom: 0;');
|
|
178
|
+
token = state.push('inline', '', 0);
|
|
179
|
+
token.content = resString;
|
|
180
|
+
token.type = "addcontentsline";
|
|
181
|
+
token.map = [startLine, state.line];
|
|
182
|
+
if (state.md.options.forLatex) {
|
|
183
|
+
token.latex = resString;
|
|
184
|
+
}
|
|
185
|
+
var children = [];
|
|
186
|
+
state.md.inline.parse(token.content.trim(), state.md, state.env, children);
|
|
187
|
+
token.children = children;
|
|
188
|
+
token = state.push('addcontentsline_close', 'div', -1);
|
|
189
|
+
token.envLevel = level;
|
|
190
|
+
if (state.md.options.forLatex) {
|
|
191
|
+
token.latex = '}';
|
|
192
|
+
}
|
|
193
|
+
if (inlineStr && inlineStr.trim()) {
|
|
194
|
+
token = state.push('inline', '', 0);
|
|
195
|
+
token.content = inlineStr;
|
|
196
|
+
token.children = [];
|
|
197
|
+
}
|
|
198
|
+
return true;
|
|
199
|
+
};
|
|
200
|
+
exports.headingSection = function (state, startLine, endLine, silent) {
|
|
60
201
|
var _a;
|
|
61
|
-
sectionCount = 0;
|
|
62
|
-
subCount = 0;
|
|
63
|
-
subSubCount = 0;
|
|
64
202
|
var token, lineText, pos = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine];
|
|
65
203
|
var nextLine = startLine + 1;
|
|
66
204
|
var startPos = 0, type, className = '', is_numerable = false, beginMarker = "{", level = 1;
|
|
@@ -70,11 +208,12 @@ var headingSection = function (state, startLine, endLine) {
|
|
|
70
208
|
}
|
|
71
209
|
var match = lineText
|
|
72
210
|
.slice(++startPos)
|
|
73
|
-
.match(/^(?:title|section|subsection|subsubsection)/);
|
|
211
|
+
.match(/^(?:title|section\*|section|subsection\*|subsection|subsubsection\*|subsubsection)/);
|
|
74
212
|
if (!match) {
|
|
75
213
|
return false;
|
|
76
214
|
}
|
|
77
215
|
var attrStyle = '';
|
|
216
|
+
var isUnNumbered = false;
|
|
78
217
|
startPos += match[0].length;
|
|
79
218
|
switch (match[0]) {
|
|
80
219
|
case "title":
|
|
@@ -87,7 +226,6 @@ var headingSection = function (state, startLine, endLine) {
|
|
|
87
226
|
level = 2;
|
|
88
227
|
type = "section";
|
|
89
228
|
is_numerable = true;
|
|
90
|
-
subsectionParentCount++;
|
|
91
229
|
isNewSect = true;
|
|
92
230
|
className = "section-title";
|
|
93
231
|
attrStyle = 'margin-top: 1.5em;';
|
|
@@ -103,13 +241,32 @@ var headingSection = function (state, startLine, endLine) {
|
|
|
103
241
|
type = "subsubsection";
|
|
104
242
|
className = "sub_sub_section-title";
|
|
105
243
|
break;
|
|
244
|
+
case "section*":
|
|
245
|
+
isUnNumbered = true;
|
|
246
|
+
level = 2;
|
|
247
|
+
type = "section";
|
|
248
|
+
className = "section-title";
|
|
249
|
+
attrStyle = 'margin-top: 1.5em;';
|
|
250
|
+
break;
|
|
251
|
+
case "subsection*":
|
|
252
|
+
isUnNumbered = true;
|
|
253
|
+
level = 3;
|
|
254
|
+
type = "subsection";
|
|
255
|
+
className = "sub_section-title";
|
|
256
|
+
break;
|
|
257
|
+
case "subsubsection*":
|
|
258
|
+
isUnNumbered = true;
|
|
259
|
+
level = 4;
|
|
260
|
+
type = "subsubsection";
|
|
261
|
+
className = "sub_sub_section-title";
|
|
262
|
+
break;
|
|
106
263
|
default:
|
|
107
264
|
break;
|
|
108
265
|
}
|
|
109
266
|
if (lineText[startPos] !== beginMarker) {
|
|
110
267
|
return false;
|
|
111
268
|
}
|
|
112
|
-
var _b = findEndMarker(lineText, startPos), _c = _b.res, res = _c === void 0 ? false : _c, _d = _b.content, content = _d === void 0 ? '' : _d, _e = _b.nextPos, nextPos = _e === void 0 ? 0 : _e;
|
|
269
|
+
var _b = common_1.findEndMarker(lineText, startPos), _c = _b.res, res = _c === void 0 ? false : _c, _d = _b.content, content = _d === void 0 ? '' : _d, _e = _b.nextPos, nextPos = _e === void 0 ? 0 : _e;
|
|
113
270
|
var resString = content;
|
|
114
271
|
resString = resString.split('\\\\').join('\n');
|
|
115
272
|
var hasEndMarker = false;
|
|
@@ -123,14 +280,14 @@ var headingSection = function (state, startLine, endLine) {
|
|
|
123
280
|
pos = state.bMarks[nextLine] + state.tShift[nextLine];
|
|
124
281
|
max = state.eMarks[nextLine];
|
|
125
282
|
lineText = state.src.slice(pos, max);
|
|
126
|
-
var _f = findEndMarker(lineText, -1, "{", "}", true), _g = _f.res,
|
|
127
|
-
if (
|
|
283
|
+
var _f = common_1.findEndMarker(lineText, -1, "{", "}", true), _g = _f.res, res_2 = _g === void 0 ? false : _g, _h = _f.content, content_2 = _h === void 0 ? '' : _h, _j = _f.nextPos, nextPos_2 = _j === void 0 ? 0 : _j;
|
|
284
|
+
if (res_2) {
|
|
128
285
|
resString += resString ? ' ' : '';
|
|
129
|
-
|
|
130
|
-
resString +=
|
|
286
|
+
content_2 = content_2.split('\\\\').join('\n');
|
|
287
|
+
resString += content_2;
|
|
131
288
|
hasEndMarker = true;
|
|
132
|
-
if (
|
|
133
|
-
inlineStr = lineText.slice(
|
|
289
|
+
if (nextPos_2 && nextPos_2 < lineText.length) {
|
|
290
|
+
inlineStr = lineText.slice(nextPos_2);
|
|
134
291
|
}
|
|
135
292
|
break;
|
|
136
293
|
}
|
|
@@ -150,6 +307,10 @@ var headingSection = function (state, startLine, endLine) {
|
|
|
150
307
|
if (!hasEndMarker) {
|
|
151
308
|
return false;
|
|
152
309
|
}
|
|
310
|
+
/** For validation mode we can terminate immediately */
|
|
311
|
+
if (silent) {
|
|
312
|
+
return true;
|
|
313
|
+
}
|
|
153
314
|
state.line = last;
|
|
154
315
|
token = state.push('heading_open', 'h' + String(level), 1);
|
|
155
316
|
if (state.md.options.forLatex) {
|
|
@@ -158,6 +319,10 @@ var headingSection = function (state, startLine, endLine) {
|
|
|
158
319
|
token.markup = '########'.slice(0, level);
|
|
159
320
|
token.map = [startLine, state.line];
|
|
160
321
|
token.attrJoin('type', type);
|
|
322
|
+
token.isUnNumbered = isUnNumbered;
|
|
323
|
+
if (isUnNumbered) {
|
|
324
|
+
token.attrJoin('data-unnumbered', "true");
|
|
325
|
+
}
|
|
161
326
|
token.attrJoin('class', className);
|
|
162
327
|
if (((_a = state.md.options) === null || _a === void 0 ? void 0 : _a.forDocx) && attrStyle) {
|
|
163
328
|
token.attrSet('style', attrStyle);
|
|
@@ -166,29 +331,50 @@ var headingSection = function (state, startLine, endLine) {
|
|
|
166
331
|
token.content = resString;
|
|
167
332
|
token.type = type;
|
|
168
333
|
token.is_numerable = is_numerable;
|
|
334
|
+
token.isUnNumbered = isUnNumbered;
|
|
169
335
|
token.map = [startLine, state.line];
|
|
170
336
|
var children = [];
|
|
171
337
|
state.md.inline.parse(token.content.trim(), state.md, state.env, children);
|
|
172
338
|
token.children = children;
|
|
173
|
-
if (type === "section") {
|
|
174
|
-
|
|
339
|
+
if (type === "section" && !isUnNumbered) {
|
|
340
|
+
exports.sectionCount = exports.sectionCount ? exports.sectionCount + 1 : 1;
|
|
341
|
+
state.env.section = exports.sectionCount;
|
|
342
|
+
token.section = exports.sectionCount;
|
|
175
343
|
}
|
|
176
|
-
if (type === "subsection") {
|
|
177
|
-
token.secNumber = subsectionParentCount;
|
|
344
|
+
if (type === "subsection" && !isUnNumbered) {
|
|
178
345
|
token.isNewSect = isNewSect;
|
|
179
346
|
isNewSect = false;
|
|
180
|
-
|
|
181
|
-
?
|
|
347
|
+
exports.subCount = !token.isNewSect
|
|
348
|
+
? exports.subCount ? exports.subCount + 1 : 1 : 1;
|
|
349
|
+
state.env.subsection = exports.subCount;
|
|
350
|
+
token.section = exports.sectionCount;
|
|
351
|
+
token.subsection = exports.subCount;
|
|
182
352
|
}
|
|
183
|
-
if (type === "subsubsection") {
|
|
184
|
-
token.secNumber = subsectionParentCount;
|
|
353
|
+
if (type === "subsubsection" && !isUnNumbered) {
|
|
185
354
|
token.isNewSubSection = isNewSubSection;
|
|
186
355
|
isNewSubSection = false;
|
|
187
|
-
|
|
188
|
-
|
|
356
|
+
if (isNewSect) {
|
|
357
|
+
token.isNewSect = isNewSect;
|
|
358
|
+
isNewSect = false;
|
|
359
|
+
if (state.env.hasOwnProperty('subsection') && state.env.subsection === exports.subCount) {
|
|
360
|
+
exports.subCount = 0;
|
|
361
|
+
state.env.subsection = exports.subCount;
|
|
362
|
+
}
|
|
363
|
+
exports.subSubCount = 1;
|
|
364
|
+
}
|
|
365
|
+
else {
|
|
366
|
+
exports.subSubCount = !token.isNewSubSection
|
|
367
|
+
? exports.subSubCount ? exports.subSubCount + 1 : 1 : 1;
|
|
368
|
+
}
|
|
369
|
+
state.env.subsubsection = exports.subSubCount;
|
|
370
|
+
token.section = exports.sectionCount;
|
|
371
|
+
token.subsection = exports.subCount;
|
|
372
|
+
token.subsubsection = exports.subSubCount;
|
|
189
373
|
}
|
|
190
374
|
token = state.push('heading_close', 'h' + String(level), -1);
|
|
375
|
+
token.isUnNumbered = isUnNumbered;
|
|
191
376
|
token.markup = '########'.slice(0, level);
|
|
377
|
+
state.parentType = 'paragraph';
|
|
192
378
|
if (state.md.options.forLatex) {
|
|
193
379
|
token.latex = type;
|
|
194
380
|
}
|
|
@@ -381,56 +567,6 @@ var pageBreaksBlock = function (state, startLine) {
|
|
|
381
567
|
state.line = nextLine;
|
|
382
568
|
return true;
|
|
383
569
|
};
|
|
384
|
-
var findEndMarker = function (str, startPos, beginMarker, endMarker, onlyEnd) {
|
|
385
|
-
if (startPos === void 0) { startPos = 0; }
|
|
386
|
-
if (beginMarker === void 0) { beginMarker = "{"; }
|
|
387
|
-
if (endMarker === void 0) { endMarker = "}"; }
|
|
388
|
-
if (onlyEnd === void 0) { onlyEnd = false; }
|
|
389
|
-
var content = '';
|
|
390
|
-
var nextPos = 0;
|
|
391
|
-
if (str[startPos] !== beginMarker && !onlyEnd) {
|
|
392
|
-
return { res: false };
|
|
393
|
-
}
|
|
394
|
-
var openBrackets = 1;
|
|
395
|
-
var openCode = 0;
|
|
396
|
-
for (var i = startPos + 1; i < str.length; i++) {
|
|
397
|
-
var chr = str[i];
|
|
398
|
-
nextPos = i;
|
|
399
|
-
if (chr === '`') {
|
|
400
|
-
if (openCode > 0) {
|
|
401
|
-
openCode--;
|
|
402
|
-
}
|
|
403
|
-
else {
|
|
404
|
-
openCode++;
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
if (chr === beginMarker && openCode === 0) {
|
|
408
|
-
content += chr;
|
|
409
|
-
openBrackets++;
|
|
410
|
-
continue;
|
|
411
|
-
}
|
|
412
|
-
if (chr === endMarker && openCode === 0) {
|
|
413
|
-
openBrackets--;
|
|
414
|
-
if (openBrackets > 0) {
|
|
415
|
-
content += chr;
|
|
416
|
-
continue;
|
|
417
|
-
}
|
|
418
|
-
break;
|
|
419
|
-
}
|
|
420
|
-
content += chr;
|
|
421
|
-
}
|
|
422
|
-
if (openBrackets > 0) {
|
|
423
|
-
return {
|
|
424
|
-
res: false,
|
|
425
|
-
content: content
|
|
426
|
-
};
|
|
427
|
-
}
|
|
428
|
-
return {
|
|
429
|
-
res: true,
|
|
430
|
-
content: content,
|
|
431
|
-
nextPos: nextPos + endMarker.length
|
|
432
|
-
};
|
|
433
|
-
};
|
|
434
570
|
var textAuthor = function (state) {
|
|
435
571
|
var _a;
|
|
436
572
|
var startPos = state.pos;
|
|
@@ -444,7 +580,7 @@ var textAuthor = function (state) {
|
|
|
444
580
|
return false;
|
|
445
581
|
}
|
|
446
582
|
startPos += match[0].length;
|
|
447
|
-
var _b = findEndMarker(state.src, startPos), _c = _b.res, res = _c === void 0 ? false : _c, _d = _b.content, content = _d === void 0 ? '' : _d, _e = _b.nextPos, nextPos = _e === void 0 ? 0 : _e;
|
|
583
|
+
var _b = common_1.findEndMarker(state.src, startPos), _c = _b.res, res = _c === void 0 ? false : _c, _d = _b.content, content = _d === void 0 ? '' : _d, _e = _b.nextPos, nextPos = _e === void 0 ? 0 : _e;
|
|
448
584
|
if (!res) {
|
|
449
585
|
return false;
|
|
450
586
|
}
|
|
@@ -517,7 +653,7 @@ var textTypes = function (state) {
|
|
|
517
653
|
if (!type || type === '') {
|
|
518
654
|
return false;
|
|
519
655
|
}
|
|
520
|
-
var _b = findEndMarker(state.src, startPos), _c = _b.res, res = _c === void 0 ? false : _c, _d = _b.content, content = _d === void 0 ? '' : _d, _e = _b.nextPos, nextPos = _e === void 0 ? 0 : _e;
|
|
656
|
+
var _b = common_1.findEndMarker(state.src, startPos), _c = _b.res, res = _c === void 0 ? false : _c, _d = _b.content, content = _d === void 0 ? '' : _d, _e = _b.nextPos, nextPos = _e === void 0 ? 0 : _e;
|
|
521
657
|
if (!res) {
|
|
522
658
|
return false;
|
|
523
659
|
}
|
|
@@ -654,10 +790,10 @@ var linkifyURL = function (state) {
|
|
|
654
790
|
};
|
|
655
791
|
var renderDocTitle = function (tokens, index, options, env, slf) {
|
|
656
792
|
var token = tokens[index];
|
|
657
|
-
var content = renderInlineContent(token, options, env, slf);
|
|
793
|
+
var content = exports.renderInlineContent(token, options, env, slf);
|
|
658
794
|
return content;
|
|
659
795
|
};
|
|
660
|
-
|
|
796
|
+
exports.renderInlineContent = function (token, options, env, slf) {
|
|
661
797
|
var sContent = '';
|
|
662
798
|
var content = '';
|
|
663
799
|
if (token.children && token.children.length) {
|
|
@@ -682,32 +818,35 @@ var renderInlineContent = function (token, options, env, slf) {
|
|
|
682
818
|
};
|
|
683
819
|
var renderSectionTitle = function (tokens, index, options, env, slf) {
|
|
684
820
|
var token = tokens[index];
|
|
821
|
+
var content = exports.renderInlineContent(token, options, env, slf);
|
|
822
|
+
if (token.isUnNumbered) {
|
|
823
|
+
return content;
|
|
824
|
+
}
|
|
685
825
|
var sectionNumber = token.is_numerable
|
|
686
|
-
? "<span class=\"section-number\">" +
|
|
826
|
+
? "<span class=\"section-number\">" + token.section + ". </span>"
|
|
687
827
|
: "";
|
|
688
|
-
var content = renderInlineContent(token, options, env, slf);
|
|
689
828
|
return "" + sectionNumber + content;
|
|
690
829
|
};
|
|
691
830
|
var renderSubsectionTitle = function (tokens, index, options, env, slf) {
|
|
692
831
|
var token = tokens[index];
|
|
693
|
-
|
|
694
|
-
|
|
832
|
+
var content = exports.renderInlineContent(token, options, env, slf);
|
|
833
|
+
if (token.isUnNumbered) {
|
|
834
|
+
return content;
|
|
695
835
|
}
|
|
696
|
-
|
|
697
|
-
return "<span class=\"section-number\">" + token.secNumber + ".</span><span class=\"sub_section-number\">" + ++subCount + ".</span> " + content;
|
|
836
|
+
return "<span class=\"section-number\">" + token.section + ".</span><span class=\"sub_section-number\">" + token.subsection + ".</span> " + content;
|
|
698
837
|
};
|
|
699
838
|
var renderSubSubsectionTitle = function (tokens, index, options, env, slf) {
|
|
700
839
|
var token = tokens[index];
|
|
701
|
-
|
|
702
|
-
|
|
840
|
+
var content = exports.renderInlineContent(token, options, env, slf);
|
|
841
|
+
if (token.isUnNumbered) {
|
|
842
|
+
return content;
|
|
703
843
|
}
|
|
704
|
-
|
|
705
|
-
return "<span class=\"section-number\">" + token.secNumber + ".</span><span class=\"sub_section-number\">" + subCount + "." + ++subSubCount + ".</span> " + content;
|
|
844
|
+
return "<span class=\"section-number\">" + token.section + ".</span><span class=\"sub_section-number\">" + token.subsection + "." + token.subsubsection + ".</span> " + content;
|
|
706
845
|
};
|
|
707
846
|
var getAuthorItemToken = function (tokens, index, options, env, slf) {
|
|
708
847
|
var res = '';
|
|
709
848
|
var token = tokens[index];
|
|
710
|
-
var content = renderInlineContent(token, options, env, slf);
|
|
849
|
+
var content = exports.renderInlineContent(token, options, env, slf);
|
|
711
850
|
var attrStyle = options.forDocx
|
|
712
851
|
? ' display: block; text-align: center;'
|
|
713
852
|
: '';
|
|
@@ -724,7 +863,7 @@ var getAuthorColumnToken = function (tokens, index, options, env, slf) {
|
|
|
724
863
|
: '';
|
|
725
864
|
var content = token.children && token.children.length
|
|
726
865
|
? slf.renderInline(token.children, options)
|
|
727
|
-
: renderInlineContent(token, options, env, slf);
|
|
866
|
+
: exports.renderInlineContent(token, options, env, slf);
|
|
728
867
|
if (attrStyle) {
|
|
729
868
|
res += "<p style=\"" + attrStyle + "\">" + content + "</p>";
|
|
730
869
|
}
|
|
@@ -740,7 +879,7 @@ var renderAuthorToken = function (tokens, index, options, env, slf) {
|
|
|
740
879
|
: '';
|
|
741
880
|
var res = token.children && token.children.length
|
|
742
881
|
? slf.renderInline(token.children, options)
|
|
743
|
-
: renderInlineContent(token, options, env, slf);
|
|
882
|
+
: exports.renderInlineContent(token, options, env, slf);
|
|
744
883
|
if (divStyle) {
|
|
745
884
|
return "<div class=\"author\" style=\"" + divStyle + "\">\n " + res + "\n </div>";
|
|
746
885
|
}
|
|
@@ -750,12 +889,12 @@ var renderAuthorToken = function (tokens, index, options, env, slf) {
|
|
|
750
889
|
};
|
|
751
890
|
var renderBoldText = function (tokens, idx, options, env, slf) {
|
|
752
891
|
var token = tokens[idx];
|
|
753
|
-
var content = renderInlineContent(token, options, env, slf);
|
|
892
|
+
var content = exports.renderInlineContent(token, options, env, slf);
|
|
754
893
|
return content;
|
|
755
894
|
};
|
|
756
895
|
var renderItalicText = function (tokens, idx, options, env, slf) {
|
|
757
896
|
var token = tokens[idx];
|
|
758
|
-
var content = renderInlineContent(token, options, env, slf);
|
|
897
|
+
var content = exports.renderInlineContent(token, options, env, slf);
|
|
759
898
|
return content;
|
|
760
899
|
};
|
|
761
900
|
var renderCodeInlineOpen = function (tokens, idx, options, env, slf) {
|
|
@@ -768,7 +907,7 @@ var renderCodeInlineClose = function () {
|
|
|
768
907
|
var renderCodeInline = function (tokens, idx, options, env, slf) {
|
|
769
908
|
var token = tokens[idx];
|
|
770
909
|
// return escapeHtml(token.content);
|
|
771
|
-
var content = renderInlineContent(token, options, env, slf);
|
|
910
|
+
var content = exports.renderInlineContent(token, options, env, slf);
|
|
772
911
|
return content;
|
|
773
912
|
};
|
|
774
913
|
var renderUrl = function (token) { return "<a href=\"" + token.content + "\">" + token.content + "</a>"; };
|
|
@@ -808,12 +947,14 @@ var mapping = {
|
|
|
808
947
|
subsection: "Subsection",
|
|
809
948
|
subsubsection: "Subsubsection",
|
|
810
949
|
url: "Url",
|
|
811
|
-
textUrl: "textUrl"
|
|
950
|
+
textUrl: "textUrl",
|
|
951
|
+
addcontentsline: "addcontentsline"
|
|
812
952
|
};
|
|
813
953
|
exports.default = (function () {
|
|
814
954
|
return function (md) {
|
|
815
955
|
exports.resetCounter();
|
|
816
|
-
md.block.ruler.before("heading", "headingSection", headingSection);
|
|
956
|
+
md.block.ruler.before("heading", "headingSection", exports.headingSection);
|
|
957
|
+
md.block.ruler.before("heading", "addContentsLineBlock", addContentsLineBlock);
|
|
817
958
|
md.block.ruler.before("headingSection", "separatingSpan", separatingSpan);
|
|
818
959
|
md.block.ruler.before("paragraphDiv", "abstractBlock", abstractBlock);
|
|
819
960
|
md.block.ruler.before("paragraphDiv", "pageBreaksBlock", pageBreaksBlock);
|
|
@@ -869,6 +1010,8 @@ exports.default = (function () {
|
|
|
869
1010
|
return renderUrl(tokens[idx]);
|
|
870
1011
|
case "textUrl":
|
|
871
1012
|
return renderTextUrl(tokens[idx]);
|
|
1013
|
+
case "addcontentsline":
|
|
1014
|
+
return '';
|
|
872
1015
|
default:
|
|
873
1016
|
return '';
|
|
874
1017
|
}
|