utils.py 364 B

123456789101112
  1. from markdown_it.rules_block import StateBlock
  2. def is_code_block(state: StateBlock, line: int) -> bool:
  3. """Check if the line is part of a code block, compat for markdown-it-py v2."""
  4. try:
  5. # markdown-it-py v3+
  6. return state.is_code_block(line)
  7. except AttributeError:
  8. pass
  9. return (state.sCount[line] - state.blkIndent) >= 4