Debian Codegraph @

third_party/python/markdown_it_py/markdown_it/rules_block/code.py

raw
1 """Code block (4 spaces padded)."""
2 import logging
3
4 from .state_block import StateBlock
5
6 LOGGER = logging.getLogger(__name__)
7
8
9 def code(state: StateBlock, startLine: int, endLine: int, silent: bool) -> bool:
10 LOGGER.debug("entering code: %s, %s, %s, %s", state, startLine, endLine, silent)
11
12 if not state.is_code_block(startLine):
13 return False
14
15 last = nextLine = startLine + 1
16
17 while nextLine < endLine:
18 if state.isEmpty(nextLine):
19 nextLine += 1
20 continue
21
22 if state.is_code_block(nextLine):
23 nextLine += 1
24 last = nextLine
25 continue
26
27 break
28
29 state.line = last
30
31 token = state.push("code_block", "code", 0)
32 token.content = state.getLines(startLine, last, 4 + state.blkIndent, False) + "\n"
33 token.map = [startLine, state.line]
34
35 return True