diff options
author | altaf-creator <dev@altafcreator.com> | 2024-05-12 12:14:02 +0700 |
---|---|---|
committer | altaf-creator <dev@altafcreator.com> | 2024-05-12 12:14:02 +0700 |
commit | d607ac12097afb5cb6f398a4e7b5cf4316efedc6 (patch) | |
tree | 6f4bc5b98a6ff3a1c3189f7ef9b570c0481e100d /packages/markdown-it-14.1.0/lib/rules_block/code.mjs | |
parent | 7441f212967256ac4c9a93ba0b1f026308a8bfb6 (diff) |
self host
Diffstat (limited to 'packages/markdown-it-14.1.0/lib/rules_block/code.mjs')
-rw-r--r-- | packages/markdown-it-14.1.0/lib/rules_block/code.mjs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/packages/markdown-it-14.1.0/lib/rules_block/code.mjs b/packages/markdown-it-14.1.0/lib/rules_block/code.mjs new file mode 100644 index 0000000..e45e6f9 --- /dev/null +++ b/packages/markdown-it-14.1.0/lib/rules_block/code.mjs @@ -0,0 +1,30 @@ +// 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 +} |