Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
ZEROM22 committed Nov 18, 2024
1 parent a58e32b commit 10f22c1
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions packages/mdast-util-extract-section/lib/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,27 @@ export function extractSection(h: string, n: Node): Root {

h = h.trim().toLocaleLowerCase()

let f = false
let f = -1

let i = 0
for (const c of n.children) {
if (isHeadingNode(c) && c.depth === 2 && f) {
rc.push(...n.children.slice(i))
break
if (isHeadingNode(c) && c.depth === 2 && f === 0) {
f = 1
}

if (isHeadingNode(c) && c.depth === 2) {
const s = toString(c).toLocaleLowerCase()

if (s === h) {
f = true
i += 1
if (s === h && f === -1) {
f = 0
continue
}
}

if (f) {
if (f === 0) {
r.children.push(c)
} else {
rc.push(c)
}
i += 1
}

n.children = rc
Expand Down

0 comments on commit 10f22c1

Please sign in to comment.