blob: 6c08ce4d978c1913c2fe6d02aa381c2e0cd827ce (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
import re
from markdown_it.rules_block import StateBlock
def is_code_block(state: StateBlock, line: int) -> bool:
"""Check if the line is part of a code block, compat for markdown-it-py v2."""
try:
# markdown-it-py v3+
return state.is_code_block(line)
except AttributeError:
pass
return (state.sCount[line] - state.blkIndent) >= 4
# Regex for subscript and superscript plugins
UNESCAPE_RE = re.compile(r"\\([ \\!\"#$%&'()*+,./:;<=>?@[\]^_`{|}~-])")
WHITESPACE_RE = re.compile(r"(^|[^\\])(\\\\)*\s")
|