diff options
| author | altaf-creator <dev@altafcreator.com> | 2026-04-30 22:01:53 +0800 |
|---|---|---|
| committer | altaf-creator <dev@altafcreator.com> | 2026-04-30 22:01:53 +0800 |
| commit | db1c6676a13798ee57dbac429a1d5045b60356fb (patch) | |
| tree | 5ff305c09686de50bbcac404c1954e42c26ba494 /www/packages/markdown-it-14.1.0/lib/rules_block/code.mjs | |
| parent | 97fa8f57fbefcbfa6b3e56c31a1e5b60ef1a9e37 (diff) | |
quite a big commit
Diffstat (limited to 'www/packages/markdown-it-14.1.0/lib/rules_block/code.mjs')
| -rw-r--r-- | www/packages/markdown-it-14.1.0/lib/rules_block/code.mjs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/www/packages/markdown-it-14.1.0/lib/rules_block/code.mjs b/www/packages/markdown-it-14.1.0/lib/rules_block/code.mjs new file mode 100644 index 0000000..e45e6f9 --- /dev/null +++ b/www/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 +} |
