Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
code.py37 linesDownload Raw Back to rules_block
1"""Code block (4 spaces padded)."""2 3import logging4 5from .state_block import StateBlock6 7LOGGER = logging.getLogger(__name__)8 9 10def code(state: StateBlock, startLine: int, endLine: int, silent: bool) -> bool:11    LOGGER.debug("entering code: %s, %s, %s, %s", state, startLine, endLine, silent)12 13    if not state.is_code_block(startLine):14        return False15 16    last = nextLine = startLine + 117 18    while nextLine < endLine:19        if state.isEmpty(nextLine):20            nextLine += 121            continue22 23        if state.is_code_block(nextLine):24            nextLine += 125            last = nextLine26            continue27 28        break29 30    state.line = last31 32    token = state.push("code_block", "code", 0)33    token.content = state.getLines(startLine, last, 4 + state.blkIndent, False) + "\n"34    token.map = [startLine, state.line]35 36    return True37