mirror of
https://github.com/voson-wang/toon.git
synced 2026-01-29 23:34: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
|
let afterHyphen: string
|
||||||
|
|
||||||
if (line.content === LIST_ITEM_MARKER) {
|
if (line.content === LIST_ITEM_MARKER) {
|
||||||
// Bare list item marker: either an empty object or fields at depth +1
|
// Bare list item marker: always an empty object
|
||||||
const followDepth = baseDepth + 1
|
yield { type: 'startObject' }
|
||||||
const nextLine = cursor.peekSync()
|
yield { type: 'endObject' }
|
||||||
|
return
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (line.content.startsWith(LIST_ITEM_PREFIX)) {
|
else if (line.content.startsWith(LIST_ITEM_PREFIX)) {
|
||||||
afterHyphen = line.content.slice(LIST_ITEM_PREFIX.length)
|
afterHyphen = line.content.slice(LIST_ITEM_PREFIX.length)
|
||||||
@@ -826,45 +791,10 @@ async function* decodeListItemAsync(
|
|||||||
let afterHyphen: string
|
let afterHyphen: string
|
||||||
|
|
||||||
if (line.content === LIST_ITEM_MARKER) {
|
if (line.content === LIST_ITEM_MARKER) {
|
||||||
// Bare list item marker: either an empty object or fields at depth +1
|
// Bare list item marker: always an empty object
|
||||||
const followDepth = baseDepth + 1
|
yield { type: 'startObject' }
|
||||||
const nextLine = await cursor.peek()
|
yield { type: 'endObject' }
|
||||||
|
return
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (line.content.startsWith(LIST_ITEM_PREFIX)) {
|
else if (line.content.startsWith(LIST_ITEM_PREFIX)) {
|
||||||
afterHyphen = line.content.slice(LIST_ITEM_PREFIX.length)
|
afterHyphen = line.content.slice(LIST_ITEM_PREFIX.length)
|
||||||
|
|||||||
Reference in New Issue
Block a user