MCPcopy Create free account
hub / github.com/executablebooks/markdown-it-py / html_block

Function html_block

markdown_it/rules_block/html_block.py:34–90  ·  view source on GitHub ↗
(state: StateBlock, startLine: int, endLine: int, silent: bool)

Source from the content-addressed store, hash-verified

32
33
34def html_block(state: StateBlock, startLine: int, endLine: int, silent: bool) -> bool:
35 LOGGER.debug(
36 "entering html_block: %s, %s, %s, %s", state, startLine, endLine, silent
37 )
38 pos = state.bMarks[startLine] + state.tShift[startLine]
39 maximum = state.eMarks[startLine]
40
41 if state.is_code_block(startLine):
42 return False
43
44 if not state.md.options.get("html", None):
45 return False
46
47 if state.src[pos] != "<":
48 return False
49
50 lineText = state.src[pos:maximum]
51
52 html_seq = None
53 for HTML_SEQUENCE in HTML_SEQUENCES:
54 if HTML_SEQUENCE[0].search(lineText):
55 html_seq = HTML_SEQUENCE
56 break
57
58 if not html_seq:
59 return False
60
61 if silent:
62 # true if this sequence can be a terminator, false otherwise
63 return html_seq[2]
64
65 nextLine = startLine + 1
66
67 # If we are here - we detected HTML block.
68 # Let's roll down till block end.
69 if not html_seq[1].search(lineText):
70 while nextLine < endLine:
71 if state.sCount[nextLine] < state.blkIndent:
72 break
73
74 pos = state.bMarks[nextLine] + state.tShift[nextLine]
75 maximum = state.eMarks[nextLine]
76 lineText = state.src[pos:maximum]
77
78 if html_seq[1].search(lineText):
79 if len(lineText) != 0:
80 nextLine += 1
81 break
82 nextLine += 1
83
84 state.line = nextLine
85
86 token = state.push("html_block", "", 0)
87 token.map = [startLine, nextLine]
88 token.content = state.getLines(startLine, nextLine, state.blkIndent, True)
89
90 return True

Callers

nothing calls this directly

Calls 3

is_code_blockMethod · 0.80
getLinesMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…