Skip to content

Instantly share code, notes, and snippets.

@Vnthf
Created January 6, 2017 01:20
Show Gist options
  • Save Vnthf/add63b2080c91e55bf0f974326d3c503 to your computer and use it in GitHub Desktop.
Save Vnthf/add63b2080c91e55bf0f974326d3c503 to your computer and use it in GitHub Desktop.
// Code block (4 spaces padded)
'use strict';
module.exports = function code(state, startLine, endLine/*, silent*/) {
var nextLine, last, token;
if (state.sCount[startLine] - state.blkIndent < 4) { return false; }
last = nextLine = startLine + 1;
while (nextLine < endLine) {
if (state.isEmpty(nextLine)) {
nextLine++;
continue;
}
if (state.sCount[nextLine] - state.blkIndent >= 4) {
nextLine++;
last = nextLine;
continue;
}
break;
}
state.line = last;
token = state.push('code_block', 'code', 0);
token.content = state.getLines(startLine, last, 4 + state.blkIndent, true);
token.map = [ startLine, state.line ];
return true;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment