Detect ``[!TYPE]`` on *startLine* (after ``>`` prefix has been stripped). Returns the alert type string (e.g. ``"NOTE"``) or ``None``.
(state: StateBlock, startLine: int)
| 344 | |
| 345 | |
| 346 | def _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 |
no outgoing calls
no test coverage detected
searching dependent graphs…