Markdown parser, done right. 100% CommonMark support, extensions, syntax plugins & high speed
https://markdown-it.github.io/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
686 B
30 lines
686 B
// Code block (4 spaces padded)
|
|
|
|
export default function code (state, startLine, endLine/*, silent */) {
|
|
if (state.sCount[startLine] - state.blkIndent < 4) { return false }
|
|
|
|
let nextLine = startLine + 1
|
|
let last = nextLine
|
|
|
|
while (nextLine < endLine) {
|
|
if (state.isEmpty(nextLine)) {
|
|
nextLine++
|
|
continue
|
|
}
|
|
|
|
if (state.sCount[nextLine] - state.blkIndent >= 4) {
|
|
nextLine++
|
|
last = nextLine
|
|
continue
|
|
}
|
|
break
|
|
}
|
|
|
|
state.line = last
|
|
|
|
const token = state.push('code_block', 'code', 0)
|
|
token.content = state.getLines(startLine, last, 4 + state.blkIndent, false) + '\n'
|
|
token.map = [startLine, state.line]
|
|
|
|
return true
|
|
}
|
|
|