Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/icewind1991/files_markdown.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'js/CheckboxPlugin.ts')
-rw-r--r--js/CheckboxPlugin.ts16
1 files changed, 11 insertions, 5 deletions
diff --git a/js/CheckboxPlugin.ts b/js/CheckboxPlugin.ts
index 0bb6800..c83ba06 100644
--- a/js/CheckboxPlugin.ts
+++ b/js/CheckboxPlugin.ts
@@ -45,7 +45,7 @@ export function CheckBoxReplacer(md: MarkdownIt.MarkdownIt, userOptions: Partial
}
/**
- * <input type="checkbox" id="checkbox{n}" checked="true">
+ * <input type="checkbox" id="checkbox{n}" checked="true data-line="{n}">
*/
const id = options.idPrefix + lastId;
lastId += 1;
@@ -102,9 +102,15 @@ export function CheckBoxReplacer(md: MarkdownIt.MarkdownIt, userOptions: Partial
return function (state: CheckboxReplacerState) {
for (const token of state.tokens) {
if (token.type === "inline") {
- token.children = ([] as Token[]).concat.apply([],
- token.children.map(childToken => splitTextToken(childToken, state.Token, token.map ? token.map[0] : 0))
- );
+ let currentLine = token.map ? token.map[0] : 0;
+ let newChildren: Token[] = [];
+ for (const childToken of token.children) {
+ if (childToken.type === 'hardbreak' || childToken.type === 'softbreak') {
+ currentLine++;
+ }
+ newChildren = newChildren.concat(splitTextToken(childToken, state.Token, currentLine))
+ }
+ token.children = newChildren;
}
}
};
@@ -112,4 +118,4 @@ export function CheckBoxReplacer(md: MarkdownIt.MarkdownIt, userOptions: Partial
export function CheckboxPlugin(md: MarkdownIt.MarkdownIt, options: CheckboxPluginOptions) {
md.core.ruler.push("checkbox", CheckBoxReplacer(md, options));
-} \ No newline at end of file
+}