mathpix-markdown-it 2.0.29 → 2.0.31
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/es5/bundle.js +2 -2
- package/es5/index.js +2 -2
- package/lib/markdown/common/consts.d.ts +28 -0
- package/lib/markdown/common/consts.js +46 -2
- package/lib/markdown/common/consts.js.map +1 -1
- package/lib/markdown/md-block-rule/begin-tabular/parse-tabular.d.ts +5 -1
- package/lib/markdown/md-block-rule/begin-tabular/parse-tabular.js +15 -5
- package/lib/markdown/md-block-rule/begin-tabular/parse-tabular.js.map +1 -1
- package/lib/markdown/md-block-rule/helper.d.ts +16 -1
- package/lib/markdown/md-block-rule/helper.js +93 -16
- package/lib/markdown/md-block-rule/helper.js.map +1 -1
- package/lib/markdown/md-block-rule/renewcommand.js +1 -1
- package/lib/markdown/md-block-rule/renewcommand.js.map +1 -1
- package/lib/markdown/md-inline-rule/setcounter-section.js +1 -2
- package/lib/markdown/md-inline-rule/setcounter-section.js.map +1 -1
- package/lib/markdown/md-latex-lists-env/index.d.ts +16 -0
- package/lib/markdown/md-latex-lists-env/index.js +55 -0
- package/lib/markdown/md-latex-lists-env/index.js.map +1 -0
- package/lib/markdown/md-latex-lists-env/latex-list-common.d.ts +31 -0
- package/lib/markdown/md-latex-lists-env/latex-list-common.js +78 -0
- package/lib/markdown/md-latex-lists-env/latex-list-common.js.map +1 -0
- package/lib/markdown/md-latex-lists-env/latex-list-env-block.d.ts +13 -0
- package/lib/markdown/md-latex-lists-env/latex-list-env-block.js +295 -0
- package/lib/markdown/md-latex-lists-env/latex-list-env-block.js.map +1 -0
- package/lib/markdown/md-latex-lists-env/latex-list-env-inline.d.ts +59 -0
- package/lib/markdown/md-latex-lists-env/latex-list-env-inline.js +219 -0
- package/lib/markdown/md-latex-lists-env/latex-list-env-inline.js.map +1 -0
- package/lib/markdown/md-latex-lists-env/latex-list-items.d.ts +75 -0
- package/lib/markdown/md-latex-lists-env/latex-list-items.js +235 -0
- package/lib/markdown/md-latex-lists-env/latex-list-items.js.map +1 -0
- package/lib/markdown/md-latex-lists-env/latex-list-tokens.d.ts +74 -0
- package/lib/markdown/md-latex-lists-env/latex-list-tokens.js +290 -0
- package/lib/markdown/md-latex-lists-env/latex-list-tokens.js.map +1 -0
- package/lib/markdown/md-latex-lists-env/latex-list-types.d.ts +52 -0
- package/lib/markdown/md-latex-lists-env/latex-list-types.js +13 -0
- package/lib/markdown/md-latex-lists-env/latex-list-types.js.map +1 -0
- package/lib/markdown/md-latex-lists-env/list-state.d.ts +48 -0
- package/lib/markdown/md-latex-lists-env/list-state.js +86 -0
- package/lib/markdown/md-latex-lists-env/list-state.js.map +1 -0
- package/lib/markdown/md-latex-lists-env/re-level.d.ts +62 -0
- package/lib/markdown/md-latex-lists-env/re-level.js +172 -0
- package/lib/markdown/md-latex-lists-env/re-level.js.map +1 -0
- package/lib/markdown/md-latex-lists-env/render-latex-list-env.d.ts +55 -0
- package/lib/markdown/md-latex-lists-env/render-latex-list-env.js +556 -0
- package/lib/markdown/md-latex-lists-env/render-latex-list-env.js.map +1 -0
- package/lib/markdown/md-theorem/block-rule.js +11 -1
- package/lib/markdown/md-theorem/block-rule.js.map +1 -1
- package/lib/markdown/md-theorem/inline-rule.js +1 -2
- package/lib/markdown/md-theorem/inline-rule.js.map +1 -1
- package/lib/markdown/mdPluginConfigured.d.ts +2 -1
- package/lib/markdown/mdPluginConfigured.js +2 -2
- package/lib/markdown/mdPluginConfigured.js.map +1 -1
- package/lib/markdown/mdPluginText.js +2 -0
- package/lib/markdown/mdPluginText.js.map +1 -1
- package/lib/markdown/utils.d.ts +7 -0
- package/lib/markdown/utils.js +15 -1
- package/lib/markdown/utils.js.map +1 -1
- package/lib/styles/styles-lists.d.ts +1 -1
- package/lib/styles/styles-lists.js +1 -1
- package/lib/styles/styles-lists.js.map +1 -1
- package/package.json +1 -1
- package/lib/markdown/md-block-rule/lists/index.d.ts +0 -9
- package/lib/markdown/md-block-rule/lists/index.js +0 -637
- package/lib/markdown/md-block-rule/lists/index.js.map +0 -1
- package/lib/markdown/md-block-rule/lists/re-level.d.ts +0 -30
- package/lib/markdown/md-block-rule/lists/re-level.js +0 -162
- package/lib/markdown/md-block-rule/lists/re-level.js.map +0 -1
- package/lib/markdown/md-inline-rule/lists.d.ts +0 -5
- package/lib/markdown/md-inline-rule/lists.js +0 -174
- package/lib/markdown/md-inline-rule/lists.js.map +0 -1
- package/lib/markdown/md-renderer-rules/render-lists.d.ts +0 -7
- package/lib/markdown/md-renderer-rules/render-lists.js +0 -339
- package/lib/markdown/md-renderer-rules/render-lists.js.map +0 -1
- package/lib/markdown/mdPluginLists.js +0 -60
- package/lib/markdown/mdPluginLists.js.map +0 -1
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listSetCounterInline = exports.listItemInline = exports.listBeginInline = exports.listCloseInline = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var utils_1 = require("../utils");
|
|
6
|
+
var list_state_1 = require("./list-state");
|
|
7
|
+
var latex_list_types_1 = require("./latex-list-types");
|
|
8
|
+
var latex_list_common_1 = require("./latex-list-common");
|
|
9
|
+
var consts_1 = require("../common/consts");
|
|
10
|
+
/**
|
|
11
|
+
* Inline rule that parses LaTeX list environment closing commands:
|
|
12
|
+
*
|
|
13
|
+
* \end{itemize}
|
|
14
|
+
* \end{enumerate}
|
|
15
|
+
*
|
|
16
|
+
* It:
|
|
17
|
+
* - checks that we are in block/list context,
|
|
18
|
+
* - closes any still-open list item (`latex_list_item_close`),
|
|
19
|
+
* - emits `itemize_list_close` or `enumerate_list_close`,
|
|
20
|
+
* - updates `state.level` and `state.prentLevel`,
|
|
21
|
+
* - updates internal list-level state via `leaveListLevel`,
|
|
22
|
+
* - advances `state.pos` to the end of the `\end{...}` command.
|
|
23
|
+
*/
|
|
24
|
+
var listCloseInline = function (state, silent) {
|
|
25
|
+
var _a;
|
|
26
|
+
var startPos = state.pos;
|
|
27
|
+
// Only handle in block/list context
|
|
28
|
+
if (!state.env.isBlock) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
// Must start with backslash
|
|
32
|
+
if (state.src.charCodeAt(startPos) !== 0x5c /* '\' */) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
var match = state.src
|
|
36
|
+
.slice(startPos)
|
|
37
|
+
.match(consts_1.END_LIST_ENV_RE);
|
|
38
|
+
if (!match) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
var rawType = match[1].trim();
|
|
42
|
+
if (!(0, latex_list_types_1.isListType)(rawType)) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
if (!silent) {
|
|
46
|
+
var listType = rawType;
|
|
47
|
+
(0, latex_list_common_1.closeOpenListItemIfNeeded)(state);
|
|
48
|
+
var _b = (0, latex_list_common_1.getListTokenTypes)(listType), closeType = _b.closeType, htmlTag = _b.htmlTag;
|
|
49
|
+
// itemize_list_close or enumerate_list_close
|
|
50
|
+
var token = state.push(closeType, htmlTag, -1);
|
|
51
|
+
(0, latex_list_common_1.applyListCloseState)(state, token);
|
|
52
|
+
}
|
|
53
|
+
state.pos = startPos + ((_a = match.index) !== null && _a !== void 0 ? _a : 0) + match[0].length;
|
|
54
|
+
return true;
|
|
55
|
+
};
|
|
56
|
+
exports.listCloseInline = listCloseInline;
|
|
57
|
+
/**
|
|
58
|
+
* Inline rule that parses LaTeX list environment openings:
|
|
59
|
+
*
|
|
60
|
+
* \begin{itemize}
|
|
61
|
+
* \begin{enumerate}
|
|
62
|
+
*
|
|
63
|
+
* It:
|
|
64
|
+
* - validates that we are in block/list context,
|
|
65
|
+
* - emits an `itemize_list_open` or `enumerate_list_open` token,
|
|
66
|
+
* - updates `state.prentLevel`, `state.parentType` and `state.types`,
|
|
67
|
+
* - advances `state.pos` to the end of the \begin{...} command,
|
|
68
|
+
* - registers the new list level in the list-level state.
|
|
69
|
+
*/
|
|
70
|
+
var listBeginInline = function (state, silent) {
|
|
71
|
+
var _a;
|
|
72
|
+
var startPos = state.pos;
|
|
73
|
+
// Only inside block/list context
|
|
74
|
+
if (!state.env.isBlock) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
// Must start with backslash
|
|
78
|
+
if (state.src.charCodeAt(startPos) !== 0x5c /* '\' */) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
var match = state.src
|
|
82
|
+
.slice(startPos)
|
|
83
|
+
.match(consts_1.BEGIN_LIST_ENV_RE);
|
|
84
|
+
if (!match) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
var rawType = match[1].trim();
|
|
88
|
+
if (!(0, latex_list_types_1.isListType)(rawType)) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
if (!silent) {
|
|
92
|
+
var listType = rawType;
|
|
93
|
+
var _b = (0, latex_list_common_1.getListTokenTypes)(listType), openType = _b.openType, htmlTag = _b.htmlTag;
|
|
94
|
+
// itemize_list_open or enumerate_list_open
|
|
95
|
+
var token = state.push(openType, htmlTag, 1);
|
|
96
|
+
(0, latex_list_common_1.applyListOpenState)(state, listType, token);
|
|
97
|
+
}
|
|
98
|
+
state.pos = startPos + ((_a = match.index) !== null && _a !== void 0 ? _a : 0) + match[0].length;
|
|
99
|
+
return true;
|
|
100
|
+
};
|
|
101
|
+
exports.listBeginInline = listBeginInline;
|
|
102
|
+
/**
|
|
103
|
+
* Inline rule that parses a single LaTeX list item:
|
|
104
|
+
* \item[marker] content...
|
|
105
|
+
*
|
|
106
|
+
* It:
|
|
107
|
+
* - closes a previously open list item if necessary,
|
|
108
|
+
* - opens a new `latex_list_item_open` token,
|
|
109
|
+
* - parses the optional marker into `markerTokens`,
|
|
110
|
+
* - creates an `inline` token with the item content,
|
|
111
|
+
* - updates `state.pos` to the end of the current item.
|
|
112
|
+
*/
|
|
113
|
+
var listItemInline = function (state, silent) {
|
|
114
|
+
var startPos = state.pos;
|
|
115
|
+
// Must start with backslash
|
|
116
|
+
if (state.src.charCodeAt(startPos) !== 0x5c /* '\' */) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
// Try to match \item[...] command right after '\'
|
|
120
|
+
var itemMatch = state.src
|
|
121
|
+
.slice(startPos)
|
|
122
|
+
.match(consts_1.LATEX_ITEM_COMMAND_RE);
|
|
123
|
+
if (!itemMatch) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
// Find where this item ends: next \item or begin/end list env
|
|
127
|
+
var boundaryMatch = state.src
|
|
128
|
+
.slice(startPos + itemMatch.index + itemMatch[0].length)
|
|
129
|
+
.match(consts_1.LATEX_LIST_BOUNDARY_INLINE_RE);
|
|
130
|
+
var content = boundaryMatch && boundaryMatch.index > 0
|
|
131
|
+
? state.src.slice(startPos + itemMatch.index + itemMatch[0].length, startPos + itemMatch.index + itemMatch[0].length + boundaryMatch.index)
|
|
132
|
+
: state.src.slice(startPos + itemMatch.index + itemMatch[0].length);
|
|
133
|
+
if (!silent) {
|
|
134
|
+
// Close previous <li> if needed
|
|
135
|
+
(0, latex_list_common_1.closeOpenListItemIfNeeded)(state);
|
|
136
|
+
// Open new list item
|
|
137
|
+
var token = state.push("latex_list_item_open", "li", 1);
|
|
138
|
+
(0, list_state_1.incrementItemCount)();
|
|
139
|
+
token.parentType = state.parentType;
|
|
140
|
+
token.inlinePos = {
|
|
141
|
+
start_content: startPos + itemMatch.index + itemMatch[0].length,
|
|
142
|
+
};
|
|
143
|
+
// Skip leading spaces in content for accurate inline range
|
|
144
|
+
token.inlinePos.start_content += (0, utils_1.getSpacesFromLeft)(content);
|
|
145
|
+
token.inlinePos.end_content = token.inlinePos.start_content + content.length;
|
|
146
|
+
// Optional marker: \item[<marker>]
|
|
147
|
+
if (itemMatch[1] !== undefined) {
|
|
148
|
+
token.marker = itemMatch[1] ? itemMatch[1].trim() : "";
|
|
149
|
+
var children = [];
|
|
150
|
+
var beforeOptions = tslib_1.__assign({}, state.md.options);
|
|
151
|
+
if (state.md.options.forDocx) {
|
|
152
|
+
state.md.options = tslib_1.__assign(tslib_1.__assign({}, state.md.options), { outMath: {
|
|
153
|
+
include_svg: true,
|
|
154
|
+
include_mathml_word: false,
|
|
155
|
+
} });
|
|
156
|
+
}
|
|
157
|
+
state.md.inline.parse(itemMatch[1], state.md, state.env, children);
|
|
158
|
+
state.md.options = beforeOptions;
|
|
159
|
+
token.markerTokens = children;
|
|
160
|
+
}
|
|
161
|
+
// Inline content inside the list item
|
|
162
|
+
token = state.push("inline", "", 0);
|
|
163
|
+
token.content = content.trim();
|
|
164
|
+
token.children = [];
|
|
165
|
+
}
|
|
166
|
+
// Advance parser position to after this item
|
|
167
|
+
state.pos = startPos + itemMatch.index + itemMatch[0].length + content.length;
|
|
168
|
+
return true;
|
|
169
|
+
};
|
|
170
|
+
exports.listItemInline = listItemInline;
|
|
171
|
+
/**
|
|
172
|
+
* Inline rule that parses LaTeX \setcounter commands inside list environments:
|
|
173
|
+
*
|
|
174
|
+
* \setcounter{enumi}{3}
|
|
175
|
+
*
|
|
176
|
+
* It:
|
|
177
|
+
* - validates that we are in block/list context (state.env.isBlock),
|
|
178
|
+
* - parses the numeric value,
|
|
179
|
+
* - converts N to N+1 (so the next list item starts from that value),
|
|
180
|
+
* - emits a `setcounter` token with `content = "<nextNumber>"`,
|
|
181
|
+
* - optionally attaches the original LaTeX source in `token.latex`
|
|
182
|
+
* when `md.options.forLatex` is enabled.
|
|
183
|
+
*
|
|
184
|
+
* Example:
|
|
185
|
+
* \setcounter{enumi}{3} → token.type = "setcounter", token.content = "4"
|
|
186
|
+
*/
|
|
187
|
+
var listSetCounterInline = function (state, silent) {
|
|
188
|
+
var _a, _b, _c, _d;
|
|
189
|
+
// Only handle in block/list context (not in pure inline text)
|
|
190
|
+
if (!state.env.isBlock) {
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
var startPos = state.pos;
|
|
194
|
+
// Must start with backslash
|
|
195
|
+
if (state.src.charCodeAt(startPos) !== 0x5c /* '\' */) {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
var match = state.src
|
|
199
|
+
.slice(startPos)
|
|
200
|
+
.match(consts_1.reSetCounter);
|
|
201
|
+
if (!match) {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
if (!silent) {
|
|
205
|
+
var startNumber = (0, latex_list_common_1.parseSetCounterNumber)(match);
|
|
206
|
+
var content = startNumber.toString();
|
|
207
|
+
var token = state.push("setcounter", "", 0);
|
|
208
|
+
token.content = content;
|
|
209
|
+
if ((_b = (_a = state.md) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.forLatex) {
|
|
210
|
+
var absoluteEnd = startPos + ((_c = match.index) !== null && _c !== void 0 ? _c : 0) + match[0].length;
|
|
211
|
+
token.latex = state.src.slice(state.pos, absoluteEnd);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
// Advance parser position to just after the \setcounter call
|
|
215
|
+
state.pos = startPos + ((_d = match.index) !== null && _d !== void 0 ? _d : 0) + match[0].length;
|
|
216
|
+
return true;
|
|
217
|
+
};
|
|
218
|
+
exports.listSetCounterInline = listSetCounterInline;
|
|
219
|
+
//# sourceMappingURL=latex-list-env-inline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"latex-list-env-inline.js","sourceRoot":"","sources":["../../../src/markdown/md-latex-lists-env/latex-list-env-inline.ts"],"names":[],"mappings":";;;;AAEA,kCAA6C;AAC7C,2CAAkD;AAClD,uDAA0D;AAC1D,yDAM6B;AAC7B,2CAKyB;AAEzB;;;;;;;;;;;;;GAaG;AACI,IAAM,eAAe,GAAe,UACzC,KAAkB,EAClB,MAAe;;IAEf,IAAM,QAAQ,GAAW,KAAK,CAAC,GAAG,CAAC;IACnC,oCAAoC;IACpC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,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M,WAAW,GAAW,QAAQ,GAAG,CAAC,MAAA,KAAK,CAAC,KAAK,mCAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;YAC5E,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;SACvD;KACF;IACD,6DAA6D;IAC7D,KAAK,CAAC,GAAG,GAAG,QAAQ,GAAG,CAAC,MAAA,KAAK,CAAC,KAAK,mCAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAC5D,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAhCW,QAAA,oBAAoB,wBAgC/B"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type StateInline from 'markdown-it/lib/rules_inline/state_inline';
|
|
2
|
+
import type StateBlock from 'markdown-it/lib/rules_block/state_block';
|
|
3
|
+
import type Token from 'markdown-it/lib/token';
|
|
4
|
+
import { ListItemsResult, ParsedListItem } from "./latex-list-types";
|
|
5
|
+
/**
|
|
6
|
+
* Processes block-style LaTeX list items by parsing their content
|
|
7
|
+
* using the block parser. This is used for items whose content
|
|
8
|
+
* contains block environments (e.g., \begin{table}, \begin{figure}, etc.).
|
|
9
|
+
*
|
|
10
|
+
* @param state - Markdown-It processing state
|
|
11
|
+
* @param items - Array of parsed list items
|
|
12
|
+
*/
|
|
13
|
+
export declare const ListItemsBlock: (state: any, items: ParsedListItem[] | null | undefined) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Processes LaTeX list items and generates Markdown-It tokens
|
|
16
|
+
* for both inline content and nested list structures.
|
|
17
|
+
*
|
|
18
|
+
* @param state - Markdown-It list processing state
|
|
19
|
+
* @param items - Parsed list items from LaTeX environment
|
|
20
|
+
* @param itemizeLevelTokens - Current itemize nesting level
|
|
21
|
+
* @param enumerateLevelTypes - Current enumerate nesting level
|
|
22
|
+
* @param li - Optional starting value for enumerate items
|
|
23
|
+
* @param iOpen - Current count of open list environments
|
|
24
|
+
* @param itemizeLevelContents - Itemize content depth level
|
|
25
|
+
*
|
|
26
|
+
* @returns {ListItemsResult} Updated open-list count and computed padding
|
|
27
|
+
*/
|
|
28
|
+
export declare const ListItems: (state: StateBlock | StateInline, items: ParsedListItem[], itemizeLevelTokens: Token[][], enumerateLevelTypes: string[], li: {
|
|
29
|
+
value: number;
|
|
30
|
+
} | null, iOpen: number, itemizeLevelContents: string[]) => ListItemsResult;
|
|
31
|
+
/**
|
|
32
|
+
* Splits a line of LaTeX list content into logical items based on `\item`
|
|
33
|
+
* and appends them to the given `items` array.
|
|
34
|
+
*
|
|
35
|
+
* Special handling:
|
|
36
|
+
* - If `\item` appears in the middle of the line and both the prefix and
|
|
37
|
+
* suffix contain backticks, the whole line is treated as a continuation
|
|
38
|
+
* of the previous item.
|
|
39
|
+
* - Otherwise, text before `\item` is appended to the previous item
|
|
40
|
+
* (if any), and the rest is processed recursively as a new item segment.
|
|
41
|
+
*
|
|
42
|
+
* The function mutates and also returns the `items` array for convenience.
|
|
43
|
+
*
|
|
44
|
+
* @param items - Accumulator of parsed list items
|
|
45
|
+
* @param content - Current line content
|
|
46
|
+
* @param startLine - Line number where this piece starts
|
|
47
|
+
* @param endLine - Line number where this piece ends
|
|
48
|
+
* @returns The updated array of parsed list items
|
|
49
|
+
*/
|
|
50
|
+
export declare const ItemsListPush: (items: ParsedListItem[], content: string, startLine: number, endLine: number) => ParsedListItem[];
|
|
51
|
+
/**
|
|
52
|
+
* Appends the given line to the previous parsed list item if it exists,
|
|
53
|
+
* or creates a new list item from the line if the list is empty and
|
|
54
|
+
* the line is not an inline list environment closing command.
|
|
55
|
+
*
|
|
56
|
+
* This is used to merge continuation lines into the last list item.
|
|
57
|
+
*
|
|
58
|
+
* @param items - Accumulated list of parsed items
|
|
59
|
+
* @param lineText - Current line text to append or add as a new item
|
|
60
|
+
* @param nextLine - Line number of the current line
|
|
61
|
+
* @returns The updated list of parsed items
|
|
62
|
+
*/
|
|
63
|
+
export declare const ItemsAddToPrev: (items: ParsedListItem[], lineText: string, nextLine: number) => ParsedListItem[];
|
|
64
|
+
export declare const finalizeListItems: (state: StateBlock | StateInline, items: ParsedListItem[], itemizeLevelTokens: Token[][], enumerateLevelTypes: string[], li: {
|
|
65
|
+
value: number;
|
|
66
|
+
} | null, iOpen: number, itemizeLevelContents: string[], tokenStart: Token | null) => {
|
|
67
|
+
iOpen: number;
|
|
68
|
+
items: any[];
|
|
69
|
+
li: any;
|
|
70
|
+
};
|
|
71
|
+
export declare const splitInlineListEnv: (lineText: string, match: any) => {
|
|
72
|
+
sB: string;
|
|
73
|
+
sE: string;
|
|
74
|
+
isBacktickEscapedPair: boolean;
|
|
75
|
+
};
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.splitInlineListEnv = exports.finalizeListItems = exports.ItemsAddToPrev = exports.ItemsListPush = exports.ListItems = exports.ListItemsBlock = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var latex_list_tokens_1 = require("./latex-list-tokens");
|
|
6
|
+
var helper_1 = require("../md-block-rule/helper");
|
|
7
|
+
var consts_1 = require("../common/consts");
|
|
8
|
+
/**
|
|
9
|
+
* Processes block-style LaTeX list items by parsing their content
|
|
10
|
+
* using the block parser. This is used for items whose content
|
|
11
|
+
* contains block environments (e.g., \begin{table}, \begin{figure}, etc.).
|
|
12
|
+
*
|
|
13
|
+
* @param state - Markdown-It processing state
|
|
14
|
+
* @param items - Array of parsed list items
|
|
15
|
+
*/
|
|
16
|
+
var ListItemsBlock = function (state, items) {
|
|
17
|
+
var e_1, _a;
|
|
18
|
+
var _b;
|
|
19
|
+
if (!items || items.length === 0) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
for (var items_1 = tslib_1.__values(items), items_1_1 = items_1.next(); !items_1_1.done; items_1_1 = items_1.next()) {
|
|
24
|
+
var item = items_1_1.value;
|
|
25
|
+
var rawContent = (_b = item === null || item === void 0 ? void 0 : item.content) !== null && _b !== void 0 ? _b : '';
|
|
26
|
+
var itemContent = rawContent.trim();
|
|
27
|
+
(0, helper_1.SetTokensBlockParse)(state, itemContent, {
|
|
28
|
+
startLine: item.startLine,
|
|
29
|
+
endLine: item.endLine + 1,
|
|
30
|
+
disableBlockRules: true
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
35
|
+
finally {
|
|
36
|
+
try {
|
|
37
|
+
if (items_1_1 && !items_1_1.done && (_a = items_1.return)) _a.call(items_1);
|
|
38
|
+
}
|
|
39
|
+
finally { if (e_1) throw e_1.error; }
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
exports.ListItemsBlock = ListItemsBlock;
|
|
43
|
+
/**
|
|
44
|
+
* Processes LaTeX list items and generates Markdown-It tokens
|
|
45
|
+
* for both inline content and nested list structures.
|
|
46
|
+
*
|
|
47
|
+
* @param state - Markdown-It list processing state
|
|
48
|
+
* @param items - Parsed list items from LaTeX environment
|
|
49
|
+
* @param itemizeLevelTokens - Current itemize nesting level
|
|
50
|
+
* @param enumerateLevelTypes - Current enumerate nesting level
|
|
51
|
+
* @param li - Optional starting value for enumerate items
|
|
52
|
+
* @param iOpen - Current count of open list environments
|
|
53
|
+
* @param itemizeLevelContents - Itemize content depth level
|
|
54
|
+
*
|
|
55
|
+
* @returns {ListItemsResult} Updated open-list count and computed padding
|
|
56
|
+
*/
|
|
57
|
+
var ListItems = function (state, items, itemizeLevelTokens, enumerateLevelTypes, li, iOpen, itemizeLevelContents) {
|
|
58
|
+
var e_2, _a, e_3, _b;
|
|
59
|
+
var _c, _d;
|
|
60
|
+
var padding = 0;
|
|
61
|
+
if (!items || items.length === 0) {
|
|
62
|
+
return { iOpen: iOpen, padding: padding };
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
for (var items_2 = tslib_1.__values(items), items_2_1 = items_2.next(); !items_2_1.done; items_2_1 = items_2.next()) {
|
|
66
|
+
var listItem = items_2_1.value;
|
|
67
|
+
state.env.parentType = state.parentType;
|
|
68
|
+
state.env.isBlock = true;
|
|
69
|
+
state.env.prentLevel = state.prentLevel;
|
|
70
|
+
listItem.content = listItem.content.trim();
|
|
71
|
+
// Detect block-level item content
|
|
72
|
+
if (consts_1.LATEX_BLOCK_ENV_OPEN_RE.test(listItem.content) || (listItem.content.indexOf('`') > -1)) {
|
|
73
|
+
var match = listItem.content.match(consts_1.LATEX_ITEM_COMMAND_RE);
|
|
74
|
+
if (match) {
|
|
75
|
+
(0, latex_list_tokens_1.setTokenListItemOpenBlock)(state, listItem.startLine, listItem.endLine + 1, match[1], li, itemizeLevelTokens, enumerateLevelTypes, itemizeLevelContents);
|
|
76
|
+
if (li && li.hasOwnProperty('value')) {
|
|
77
|
+
li = null;
|
|
78
|
+
}
|
|
79
|
+
var rawContent = (_d = (_c = listItem === null || listItem === void 0 ? void 0 : listItem.content) === null || _c === void 0 ? void 0 : _c.slice(match.index + match[0].length)) !== null && _d !== void 0 ? _d : '';
|
|
80
|
+
var blockContent = rawContent.trim();
|
|
81
|
+
(0, helper_1.SetTokensBlockParse)(state, blockContent, { disableBlockRules: true });
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Parse inline children
|
|
86
|
+
var inlineChildren = [];
|
|
87
|
+
state.md.inline.parse(listItem.content.trim(), state.md, state.env, inlineChildren);
|
|
88
|
+
// Context shared across child token processing
|
|
89
|
+
var ctx = { li: li, padding: padding, iOpen: iOpen, itemizeLevelTokens: itemizeLevelTokens, enumerateLevelTypes: enumerateLevelTypes, itemizeLevelContents: itemizeLevelContents };
|
|
90
|
+
try {
|
|
91
|
+
// Process each inline child token
|
|
92
|
+
for (var inlineChildren_1 = (e_3 = void 0, tslib_1.__values(inlineChildren)), inlineChildren_1_1 = inlineChildren_1.next(); !inlineChildren_1_1.done; inlineChildren_1_1 = inlineChildren_1.next()) {
|
|
93
|
+
var child = inlineChildren_1_1.value;
|
|
94
|
+
(0, latex_list_tokens_1.processListChildToken)(state, listItem, child, ctx);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
98
|
+
finally {
|
|
99
|
+
try {
|
|
100
|
+
if (inlineChildren_1_1 && !inlineChildren_1_1.done && (_b = inlineChildren_1.return)) _b.call(inlineChildren_1);
|
|
101
|
+
}
|
|
102
|
+
finally { if (e_3) throw e_3.error; }
|
|
103
|
+
}
|
|
104
|
+
// Update context after processing children
|
|
105
|
+
li = ctx.li;
|
|
106
|
+
padding = ctx.padding;
|
|
107
|
+
iOpen = ctx.iOpen;
|
|
108
|
+
state.env.isBlock = false;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
112
|
+
finally {
|
|
113
|
+
try {
|
|
114
|
+
if (items_2_1 && !items_2_1.done && (_a = items_2.return)) _a.call(items_2);
|
|
115
|
+
}
|
|
116
|
+
finally { if (e_2) throw e_2.error; }
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
iOpen: iOpen,
|
|
120
|
+
padding: padding
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
exports.ListItems = ListItems;
|
|
124
|
+
/**
|
|
125
|
+
* Splits a line of LaTeX list content into logical items based on `\item`
|
|
126
|
+
* and appends them to the given `items` array.
|
|
127
|
+
*
|
|
128
|
+
* Special handling:
|
|
129
|
+
* - If `\item` appears in the middle of the line and both the prefix and
|
|
130
|
+
* suffix contain backticks, the whole line is treated as a continuation
|
|
131
|
+
* of the previous item.
|
|
132
|
+
* - Otherwise, text before `\item` is appended to the previous item
|
|
133
|
+
* (if any), and the rest is processed recursively as a new item segment.
|
|
134
|
+
*
|
|
135
|
+
* The function mutates and also returns the `items` array for convenience.
|
|
136
|
+
*
|
|
137
|
+
* @param items - Accumulator of parsed list items
|
|
138
|
+
* @param content - Current line content
|
|
139
|
+
* @param startLine - Line number where this piece starts
|
|
140
|
+
* @param endLine - Line number where this piece ends
|
|
141
|
+
* @returns The updated array of parsed list items
|
|
142
|
+
*/
|
|
143
|
+
var ItemsListPush = function (items, content, startLine, endLine) {
|
|
144
|
+
var index = content.indexOf('\\item');
|
|
145
|
+
// No "\item" in the line or at the very start: treat whole line as one chunk
|
|
146
|
+
if (index <= 0) {
|
|
147
|
+
items.push({ content: content, startLine: startLine, endLine: endLine });
|
|
148
|
+
return items;
|
|
149
|
+
}
|
|
150
|
+
var before = content.slice(0, index);
|
|
151
|
+
var after = content.slice(index);
|
|
152
|
+
var hasBacktickBefore = before.includes("`");
|
|
153
|
+
var hasBacktickAfter = after.includes("`");
|
|
154
|
+
// Case 1: both parts contain backticks → treat as continuation of previous item
|
|
155
|
+
if (hasBacktickBefore && hasBacktickAfter) {
|
|
156
|
+
if (items.length > 0) {
|
|
157
|
+
var lastIndex = items.length - 1;
|
|
158
|
+
items[lastIndex].content += "\n" + content;
|
|
159
|
+
items[lastIndex].endLine += 1;
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
items.push({ content: content, startLine: startLine, endLine: endLine });
|
|
163
|
+
}
|
|
164
|
+
return items;
|
|
165
|
+
}
|
|
166
|
+
// Case 2: normal case with "\item" in the middle
|
|
167
|
+
if (items.length > 0) {
|
|
168
|
+
// Append prefix to previous item
|
|
169
|
+
var lastIndex = items.length - 1;
|
|
170
|
+
items[lastIndex].content += "\n" + before;
|
|
171
|
+
items[lastIndex].endLine += 1;
|
|
172
|
+
}
|
|
173
|
+
else if (before.trim().length > 0) {
|
|
174
|
+
// No previous items: keep prefix as a separate item
|
|
175
|
+
items.push({ content: before, startLine: startLine, endLine: endLine });
|
|
176
|
+
}
|
|
177
|
+
// Recursively process the remaining part starting from "\item"
|
|
178
|
+
return (0, exports.ItemsListPush)(items, after, startLine, endLine);
|
|
179
|
+
};
|
|
180
|
+
exports.ItemsListPush = ItemsListPush;
|
|
181
|
+
/**
|
|
182
|
+
* Appends the given line to the previous parsed list item if it exists,
|
|
183
|
+
* or creates a new list item from the line if the list is empty and
|
|
184
|
+
* the line is not an inline list environment closing command.
|
|
185
|
+
*
|
|
186
|
+
* This is used to merge continuation lines into the last list item.
|
|
187
|
+
*
|
|
188
|
+
* @param items - Accumulated list of parsed items
|
|
189
|
+
* @param lineText - Current line text to append or add as a new item
|
|
190
|
+
* @param nextLine - Line number of the current line
|
|
191
|
+
* @returns The updated list of parsed items
|
|
192
|
+
*/
|
|
193
|
+
var ItemsAddToPrev = function (items, lineText, nextLine) {
|
|
194
|
+
if (items.length > 0) {
|
|
195
|
+
var lastIndex = items.length - 1;
|
|
196
|
+
items[lastIndex].content += "\n" + lineText;
|
|
197
|
+
items[lastIndex].endLine = nextLine;
|
|
198
|
+
return items;
|
|
199
|
+
}
|
|
200
|
+
// No previous items: optionally create a new item,
|
|
201
|
+
// but skip pure inline end-of-list commands.
|
|
202
|
+
if (!consts_1.END_LIST_ENV_INLINE_RE.test(lineText)) {
|
|
203
|
+
(0, exports.ItemsListPush)(items, lineText, nextLine, nextLine);
|
|
204
|
+
}
|
|
205
|
+
return items;
|
|
206
|
+
};
|
|
207
|
+
exports.ItemsAddToPrev = ItemsAddToPrev;
|
|
208
|
+
var finalizeListItems = function (state, items, itemizeLevelTokens, enumerateLevelTypes, li, iOpen, itemizeLevelContents, tokenStart) {
|
|
209
|
+
var dataItems = (0, exports.ListItems)(state, items, itemizeLevelTokens, enumerateLevelTypes, li, iOpen, itemizeLevelContents);
|
|
210
|
+
if (tokenStart) {
|
|
211
|
+
var p = tokenStart;
|
|
212
|
+
if (!p.padding || p.padding < dataItems.padding) {
|
|
213
|
+
p.padding = dataItems.padding;
|
|
214
|
+
if (p.padding > 3) {
|
|
215
|
+
p.attrSet("data-padding-inline-start", String(dataItems.padding * 14));
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return {
|
|
220
|
+
iOpen: dataItems.iOpen,
|
|
221
|
+
items: [],
|
|
222
|
+
li: null,
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
exports.finalizeListItems = finalizeListItems;
|
|
226
|
+
var splitInlineListEnv = function (lineText, match) {
|
|
227
|
+
var sB = match.index > 0 ? lineText.slice(0, match.index).trim() : "";
|
|
228
|
+
var sE = match.index + match[0].length < lineText.length
|
|
229
|
+
? lineText.slice(match.index + match[0].length).trim()
|
|
230
|
+
: "";
|
|
231
|
+
var isBacktickEscapedPair = sB.includes("`") && sE.includes("`");
|
|
232
|
+
return { sB: sB, sE: sE, isBacktickEscapedPair: isBacktickEscapedPair };
|
|
233
|
+
};
|
|
234
|
+
exports.splitInlineListEnv = splitInlineListEnv;
|
|
235
|
+
//# sourceMappingURL=latex-list-items.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"latex-list-items.js","sourceRoot":"","sources":["../../../src/markdown/md-latex-lists-env/latex-list-items.ts"],"names":[],"mappings":";;;;AAGA,yDAG6B;AAC7B,kDAA8D;AAE9D,2CAI0B;AAE1B;;;;;;;GAOG;AACI,IAAM,cAAc,GAAG,UAC5B,KAAU,EACV,KAA0C;;;IAE1C,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QAChC,OAAO;KACR;;QACD,KAAmB,IAAA,UAAA,iBAAA,KAAK,CAAA,4BAAA,+CAAE;YAArB,IAAM,IAAI,kBAAA;YACb,IAAM,UAAU,GAAW,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,OAAO,mCAAI,EAAE,CAAC;YAC/C,IAAM,WAAW,GAAW,UAAU,CAAC,IAAI,EAAE,CAAC;YAC9C,IAAA,4BAAmB,EAAC,KAAK,EAAE,WAAW,EAAE;gBACtC,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,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AM;QACjE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,KAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE;QACvD,CAAC,CAAC,EAAE,CAAC;IACP,IAAM,qBAAqB,GAAY,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC5E,OAAO,EAAE,EAAE,IAAA,EAAE,EAAE,IAAA,EAAE,qBAAqB,uBAAA,EAAE,CAAC;AAC3C,CAAC,CAAA;AAVY,QAAA,kBAAkB,sBAU9B"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type Token from 'markdown-it/lib/token';
|
|
2
|
+
import { ListType, ListInlineContext, ParsedListItem, ListOpenResult } from "./latex-list-types";
|
|
3
|
+
/**
|
|
4
|
+
* Creates an opening list-item token (<li>) for block-style LaTeX list items.
|
|
5
|
+
* Handles marker parsing, enumeration start values, nesting metadata,
|
|
6
|
+
* and updates the internal list-level state (item counters).
|
|
7
|
+
*
|
|
8
|
+
* @param state - Markdown-It state object
|
|
9
|
+
* @param startLine - Starting line number of the list item
|
|
10
|
+
* @param endLine - Ending line number of the list item
|
|
11
|
+
* @param marker - Optional raw \item[...] marker string
|
|
12
|
+
* @param li - Optional enumeration start value (e.g., \setcounter)
|
|
13
|
+
* @param itemizeLevelTokens - Pre-parsed bullet tokens for itemize levels
|
|
14
|
+
* @param enumerateLevelTypes - Current enumerate list-style types
|
|
15
|
+
* @param itemizeLevelContents - Raw bullet text for each itemize level
|
|
16
|
+
*/
|
|
17
|
+
export declare const setTokenListItemOpenBlock: (state: any, startLine: number, endLine: number, marker: string | undefined, li: {
|
|
18
|
+
value: number;
|
|
19
|
+
} | null, itemizeLevelTokens: Token[][], enumerateLevelTypes: string[], itemizeLevelContents: string[]) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Creates an opening token for LaTeX list environments (\begin{itemize}, \begin{enumerate}).
|
|
22
|
+
* Updates list nesting state, parent tracking, and attaches itemize/enumerate
|
|
23
|
+
* styling metadata used for rendering markers and list formatting.
|
|
24
|
+
*
|
|
25
|
+
* @param state - Markdown-It processing state
|
|
26
|
+
* @param startLine - Line number where the list begins
|
|
27
|
+
* @param endLine - Line number where the list ends
|
|
28
|
+
* @param type - List type ("itemize" or "enumerate")
|
|
29
|
+
* @param itemizeLevelTokens - Pre-parsed itemize bullet tokens
|
|
30
|
+
* @param enumerateLevelTypes - List-style types for enumerate levels
|
|
31
|
+
* @param itemizeLevelContents - Raw bullet text for each itemize level
|
|
32
|
+
*/
|
|
33
|
+
export declare const setTokenOpenList: (state: StateBlock, startLine: number, endLine: number, type: ListType, itemizeLevelTokens: Token[][], enumerateLevelTypes: string[], itemizeLevelContents: string[]) => Token;
|
|
34
|
+
/**
|
|
35
|
+
* Parses a LaTeX list environment beginning on the current line
|
|
36
|
+
* (e.g., \begin{itemize} or \begin{enumerate}), opens the
|
|
37
|
+
* corresponding list token, and processes any inline content
|
|
38
|
+
* that appears on the same line after \begin{...}.
|
|
39
|
+
*
|
|
40
|
+
* Returns:
|
|
41
|
+
* - iOpen: how many list environments were opened
|
|
42
|
+
* - tokenStart: the created *_list_open token, if any
|
|
43
|
+
* - li: optional enumerate start value extracted via \setcounter
|
|
44
|
+
*/
|
|
45
|
+
export declare const ListOpen: (state: StateBlock, startLine: number, lineText: string, itemizeLevelTokens: Token[][], enumerateLevelTypes: string[], itemizeLevelContents: string[]) => ListOpenResult;
|
|
46
|
+
/**
|
|
47
|
+
* Closes the current LaTeX list environment (\end{itemize} / \end{enumerate}).
|
|
48
|
+
*
|
|
49
|
+
* - Closes any still-open list item if needed
|
|
50
|
+
* - Emits the appropriate *_list_close token
|
|
51
|
+
* - Updates list nesting levels and internal list-level state
|
|
52
|
+
*
|
|
53
|
+
* @param state - Markdown-It processing state
|
|
54
|
+
* @param startLine - Line where the list block starts
|
|
55
|
+
* @param endLine - Line where the list block ends
|
|
56
|
+
* @returns The created closing list token
|
|
57
|
+
*/
|
|
58
|
+
export declare const setTokenCloseList: (state: StateBlock, startLine: number, endLine: number) => void;
|
|
59
|
+
/**
|
|
60
|
+
* Processes a single inline token inside a LaTeX list item.
|
|
61
|
+
*
|
|
62
|
+
* This function:
|
|
63
|
+
* - Applies \setcounter values to list items (\item)
|
|
64
|
+
* - Handles custom list markers and computes marker padding
|
|
65
|
+
* - Updates parent metadata (type, nesting level, line map)
|
|
66
|
+
* - Adjusts list nesting state for itemize/enumerate environments
|
|
67
|
+
* - Attaches itemize/enumerate level styling metadata
|
|
68
|
+
*
|
|
69
|
+
* @param state - The Markdown-It state object
|
|
70
|
+
* @param item - Parsed list item metadata (start/end line and content)
|
|
71
|
+
* @param child - Inline token to process
|
|
72
|
+
* @param ctx - Shared context for updating list state (padding, counters, levels)
|
|
73
|
+
*/
|
|
74
|
+
export declare const processListChildToken: (state: any, item: ParsedListItem, child: Token, ctx: ListInlineContext) => void;
|