Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/markdown_it/rules_block/code.py: 95%

22 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-07 06:15 +0000

1"""Code block (4 spaces padded).""" 

2import logging 

3 

4from .state_block import StateBlock 

5 

6LOGGER = logging.getLogger(__name__) 

7 

8 

9def 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