mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-26 13:26:22 +00:00
parent
73a890ab12
commit
5163504517
1 changed files with 3 additions and 1 deletions
|
@ -106,8 +106,9 @@ export function renderPage(
|
||||||
blockRef = blockRef.slice(1)
|
blockRef = blockRef.slice(1)
|
||||||
let startIdx = undefined
|
let startIdx = undefined
|
||||||
let endIdx = undefined
|
let endIdx = undefined
|
||||||
|
let headerRegex = /h[1-6]/
|
||||||
for (const [i, el] of page.htmlAst.children.entries()) {
|
for (const [i, el] of page.htmlAst.children.entries()) {
|
||||||
if (el.type === "element" && el.tagName.match(/h[1-6]/)) {
|
if (el.type === "element" && el.tagName.match(headerRegex)) {
|
||||||
if (endIdx) {
|
if (endIdx) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -116,6 +117,7 @@ export function renderPage(
|
||||||
endIdx = i
|
endIdx = i
|
||||||
} else if (el.properties?.id === blockRef) {
|
} else if (el.properties?.id === blockRef) {
|
||||||
startIdx = i
|
startIdx = i
|
||||||
|
headerRegex = new RegExp(`h[1-${el.tagName.slice(-1)}]`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue