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

Function getNextLine

markdown_it/rules_block/reference.py:195–235  ·  view source on GitHub ↗
(state: StateBlock, nextLine: int)

Source from the content-addressed store, hash-verified

193
194
195def getNextLine(state: StateBlock, nextLine: int) -> None | str:
196 endLine = state.lineMax
197
198 if nextLine >= endLine or state.isEmpty(nextLine):
199 # empty line or end of input
200 return None
201
202 isContinuation = False
203
204 # this would be a code block normally, but after paragraph
205 # it's considered a lazy continuation regardless of what's there
206 if state.is_code_block(nextLine):
207 isContinuation = True
208
209 # quirk for blockquotes, this line should already be checked by that rule
210 if state.sCount[nextLine] < 0:
211 isContinuation = True
212
213 if not isContinuation:
214 terminatorRules = state.md.block.ruler.getRules("reference")
215 oldParentType = state.parentType
216 state.parentType = "reference"
217
218 # Some tags can terminate paragraph without empty line.
219 terminate = False
220 for terminatorRule in terminatorRules:
221 if terminatorRule(state, nextLine, endLine, True):
222 terminate = True
223 break
224
225 state.parentType = oldParentType
226
227 if terminate:
228 # terminated by another block
229 return None
230
231 pos = state.bMarks[nextLine] + state.tShift[nextLine]
232 maximum = state.eMarks[nextLine]
233
234 # max + 1 explicitly includes the newline
235 return state.src[pos : maximum + 1]

Callers 1

referenceFunction · 0.85

Calls 3

isEmptyMethod · 0.80
is_code_blockMethod · 0.80
getRulesMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…