mirror of
https://github.com/voson-wang/toon.git
synced 2026-01-29 15:24:10 +08:00
fix: remove deprecated bare list item decoder logic
This commit is contained in:
@@ -405,45 +405,10 @@ function* decodeListItemSync(
|
||||
let afterHyphen: string
|
||||
|
||||
if (line.content === LIST_ITEM_MARKER) {
|
||||
// Bare list item marker: either an empty object or fields at depth +1
|
||||
const followDepth = baseDepth + 1
|
||||
const nextLine = cursor.peekSync()
|
||||
|
||||
if (!nextLine || nextLine.depth < followDepth) {
|
||||
// No fields at the next depth: treat as empty object
|
||||
yield { type: 'startObject' }
|
||||
yield { type: 'endObject' }
|
||||
return
|
||||
}
|
||||
|
||||
if (nextLine.depth === followDepth && !nextLine.content.startsWith(LIST_ITEM_PREFIX)) {
|
||||
// Fields at depth +1: parse them as an object
|
||||
yield { type: 'startObject' }
|
||||
|
||||
while (!cursor.atEndSync()) {
|
||||
const fieldLine = cursor.peekSync()
|
||||
if (!fieldLine || fieldLine.depth < followDepth) {
|
||||
break
|
||||
}
|
||||
|
||||
if (fieldLine.depth === followDepth && !fieldLine.content.startsWith(LIST_ITEM_PREFIX)) {
|
||||
cursor.advanceSync()
|
||||
yield* decodeKeyValueSync(fieldLine.content, cursor, followDepth, options)
|
||||
}
|
||||
else {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
yield { type: 'endObject' }
|
||||
return
|
||||
}
|
||||
else {
|
||||
// Next line is another list item or at a different depth: treat as empty object
|
||||
yield { type: 'startObject' }
|
||||
yield { type: 'endObject' }
|
||||
return
|
||||
}
|
||||
// Bare list item marker: always an empty object
|
||||
yield { type: 'startObject' }
|
||||
yield { type: 'endObject' }
|
||||
return
|
||||
}
|
||||
else if (line.content.startsWith(LIST_ITEM_PREFIX)) {
|
||||
afterHyphen = line.content.slice(LIST_ITEM_PREFIX.length)
|
||||
@@ -826,45 +791,10 @@ async function* decodeListItemAsync(
|
||||
let afterHyphen: string
|
||||
|
||||
if (line.content === LIST_ITEM_MARKER) {
|
||||
// Bare list item marker: either an empty object or fields at depth +1
|
||||
const followDepth = baseDepth + 1
|
||||
const nextLine = await cursor.peek()
|
||||
|
||||
if (!nextLine || nextLine.depth < followDepth) {
|
||||
// No fields at the next depth: treat as empty object
|
||||
yield { type: 'startObject' }
|
||||
yield { type: 'endObject' }
|
||||
return
|
||||
}
|
||||
|
||||
if (nextLine.depth === followDepth && !nextLine.content.startsWith(LIST_ITEM_PREFIX)) {
|
||||
// Fields at depth +1: parse them as an object
|
||||
yield { type: 'startObject' }
|
||||
|
||||
while (!cursor.atEnd()) {
|
||||
const fieldLine = await cursor.peek()
|
||||
if (!fieldLine || fieldLine.depth < followDepth) {
|
||||
break
|
||||
}
|
||||
|
||||
if (fieldLine.depth === followDepth && !fieldLine.content.startsWith(LIST_ITEM_PREFIX)) {
|
||||
await cursor.advance()
|
||||
yield* decodeKeyValueAsync(fieldLine.content, cursor, followDepth, options)
|
||||
}
|
||||
else {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
yield { type: 'endObject' }
|
||||
return
|
||||
}
|
||||
else {
|
||||
// Next line is another list item or at a different depth: treat as empty object
|
||||
yield { type: 'startObject' }
|
||||
yield { type: 'endObject' }
|
||||
return
|
||||
}
|
||||
// Bare list item marker: always an empty object
|
||||
yield { type: 'startObject' }
|
||||
yield { type: 'endObject' }
|
||||
return
|
||||
}
|
||||
else if (line.content.startsWith(LIST_ITEM_PREFIX)) {
|
||||
afterHyphen = line.content.slice(LIST_ITEM_PREFIX.length)
|
||||
|
||||
Reference in New Issue
Block a user