File: utils.py

package info (click to toggle)
mdit-py-plugins 0.4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 672 kB
  • sloc: python: 3,595; sh: 8; makefile: 7
file content (12 lines) | stat: -rw-r--r-- 364 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
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