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

Function _detect_alert

markdown_it/rules_block/blockquote.py:346–368  ·  view source on GitHub ↗

Detect ``[!TYPE]`` on *startLine* (after ``>`` prefix has been stripped). Returns the alert type string (e.g. ``"NOTE"``) or ``None``.

(state: StateBlock, startLine: int)

Source from the content-addressed store, hash-verified

344
345
346def _detect_alert(state: StateBlock, startLine: int) -> str | None:
347 """Detect ``[!TYPE]`` on *startLine* (after ``>`` prefix has been stripped).
348
349 Returns the alert type string (e.g. ``"NOTE"``) or ``None``.
350 """
351 pos = state.bMarks[startLine] + state.tShift[startLine]
352 maximum = state.eMarks[startLine]
353 src = state.src
354
355 # Trim trailing whitespace
356 while maximum > pos and src[maximum - 1] in (" ", "\t"):
357 maximum -= 1
358
359 if maximum - pos < 4:
360 return None
361 if src[pos] != "[" or src[pos + 1] != "!":
362 return None
363 if src[maximum - 1] != "]":
364 return None
365 type_str = src[pos + 2 : maximum - 1].upper()
366 if type_str not in _ALERT_TYPES:
367 return None
368 return type_str

Callers 1

blockquoteFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…