Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/mdit_py_plugins/utils.py: 64%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

11 statements  

1import re 

2 

3from markdown_it.rules_block import StateBlock 

4 

5 

6def is_code_block(state: StateBlock, line: int) -> bool: 

7 """Check if the line is part of a code block, compat for markdown-it-py v2.""" 

8 try: 

9 # markdown-it-py v3+ 

10 return state.is_code_block(line) 

11 except AttributeError: 

12 pass 

13 

14 return (state.sCount[line] - state.blkIndent) >= 4 

15 

16 

17# Regex for subscript and superscript plugins 

18UNESCAPE_RE = re.compile(r"\\([ \\!\"#$%&'()*+,./:;<=>?@[\]^_`{|}~-])") 

19WHITESPACE_RE = re.compile(r"(^|[^\\])(\\\\)*\s")