code.js 729 B

12345678910111213141516171819202122232425262728293031323334
  1. // Code block (4 spaces padded)
  2. 'use strict';
  3. module.exports = function code(state, startLine, endLine/*, silent*/) {
  4. var nextLine, last, token;
  5. if (state.sCount[startLine] - state.blkIndent < 4) { return false; }
  6. last = nextLine = startLine + 1;
  7. while (nextLine < endLine) {
  8. if (state.isEmpty(nextLine)) {
  9. nextLine++;
  10. continue;
  11. }
  12. if (state.sCount[nextLine] - state.blkIndent >= 4) {
  13. nextLine++;
  14. last = nextLine;
  15. continue;
  16. }
  17. break;
  18. }
  19. state.line = last;
  20. token = state.push('code_block', 'code', 0);
  21. token.content = state.getLines(startLine, last, 4 + state.blkIndent, false) + '\n';
  22. token.map = [ startLine, state.line ];
  23. return true;
  24. };