mirror of
https://github.com/marktext/marktext.git
synced 2025-05-06 09:51:46 +08:00
fix: 1733 wrong task list indentation in parser (#1835)
This commit is contained in:
parent
09b067e371
commit
23435ce6b1
@ -316,8 +316,8 @@ Lexer.prototype.token = function (src, top) {
|
|||||||
const itemWithBullet = cap[i]
|
const itemWithBullet = cap[i]
|
||||||
item = itemWithBullet
|
item = itemWithBullet
|
||||||
let newIsTaskListItem = false
|
let newIsTaskListItem = false
|
||||||
// Remove the list item's bullet
|
|
||||||
// so it is seen as the next token.
|
// Remove the list item's bullet so it is seen as the next token.
|
||||||
space = item.length
|
space = item.length
|
||||||
let newBull
|
let newBull
|
||||||
item = item.replace(/^ *([*+-]|\d+(?:\.|\))) {0,4}/, function (m, p1) {
|
item = item.replace(/^ *([*+-]|\d+(?:\.|\))) {0,4}/, function (m, p1) {
|
||||||
@ -327,13 +327,15 @@ Lexer.prototype.token = function (src, top) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const newIsOrdered = bull.length > 1 && /\d{1,9}/.test(newBull)
|
const newIsOrdered = bull.length > 1 && /\d{1,9}/.test(newBull)
|
||||||
|
|
||||||
if (!newIsOrdered && this.options.gfm) {
|
if (!newIsOrdered && this.options.gfm) {
|
||||||
checked = this.rules.checkbox.exec(item)
|
checked = this.rules.checkbox.exec(item)
|
||||||
if (checked) {
|
if (checked) {
|
||||||
checked = checked[1] === 'x' || checked[1] === 'X'
|
checked = checked[1] === 'x' || checked[1] === 'X'
|
||||||
item = item.replace(this.rules.checkbox, '')
|
|
||||||
newIsTaskListItem = true
|
newIsTaskListItem = true
|
||||||
|
|
||||||
|
// Remove the list item's checkbox and adjust indentation by removing checkbox length.
|
||||||
|
item = item.replace(this.rules.checkbox, '')
|
||||||
|
space -= 4
|
||||||
} else {
|
} else {
|
||||||
checked = undefined
|
checked = undefined
|
||||||
}
|
}
|
||||||
@ -400,6 +402,7 @@ Lexer.prototype.token = function (src, top) {
|
|||||||
} else {
|
} else {
|
||||||
prevItem = cap[i - 1]
|
prevItem = cap[i - 1]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine whether item is loose or not. If previous item is loose
|
// Determine whether item is loose or not. If previous item is loose
|
||||||
// this item is also loose.
|
// this item is also loose.
|
||||||
// A list is loose if any of its constituent list items are separated by blank lines,
|
// A list is loose if any of its constituent list items are separated by blank lines,
|
||||||
@ -450,7 +453,6 @@ Lexer.prototype.token = function (src, top) {
|
|||||||
this.tokens.push({
|
this.tokens.push({
|
||||||
type: 'list_end'
|
type: 'list_end'
|
||||||
})
|
})
|
||||||
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user