fix: Array.prototype.at() throws error in low version Node.js(<16.6.0) (#1976)

pull/1977/head
fanghaoji 4 years ago
parent 191ac86a85
commit a50bad50d5

@ -27,7 +27,8 @@ export const lineNumberPlugin = (md: MarkdownIt, enable = false) => {
const lineNumbersCode = [
...Array(
lines.length - (lines.at(-1) === `<span class="line"></span>` ? 1 : 0)
lines.length -
(lines[lines.length - 1] === `<span class="line"></span>` ? 1 : 0)
)
]
.map((_, index) => `<span class="line-number">${index + 1}</span><br>`)

@ -115,7 +115,8 @@ export const snippetPlugin = (md: MarkdownIt, srcDir: string) => {
rawTitle = ''
] = (rawPathRegexp.exec(rawPath) || []).slice(1)
const title = rawTitle || filename.split('/').at(-1) || ''
let tmpArr = filename.split('/')
const title = rawTitle || tmpArr[tmpArr.length - 1] || ''
state.line = startLine + 1

Loading…
Cancel
Save