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.
32 lines
710 B
32 lines
710 B
10 years ago
|
// Code block (4 spaces padded)
|
||
|
|
||
1 year ago
|
export default function code(state, startLine, endLine/*, silent*/) {
|
||
8 years ago
|
var nextLine, last, token;
|
||
10 years ago
|
|
||
10 years ago
|
if (state.sCount[startLine] - state.blkIndent < 4) { return false; }
|
||
10 years ago
|
|
||
|
last = nextLine = startLine + 1;
|
||
|
|
||
|
while (nextLine < endLine) {
|
||
10 years ago
|
if (state.isEmpty(nextLine)) {
|
||
10 years ago
|
nextLine++;
|
||
|
continue;
|
||
|
}
|
||
9 years ago
|
|
||
10 years ago
|
if (state.sCount[nextLine] - state.blkIndent >= 4) {
|
||
10 years ago
|
nextLine++;
|
||
|
last = nextLine;
|
||
|
continue;
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
|
||
9 years ago
|
state.line = last;
|
||
10 years ago
|
|
||
|
token = state.push('code_block', 'code', 0);
|
||
3 years ago
|
token.content = state.getLines(startLine, last, 4 + state.blkIndent, false) + '\n';
|
||
10 years ago
|
token.map = [ startLine, state.line ];
|
||
10 years ago
|
|
||
|
return true;
|
||
1 year ago
|
}
|