(state: StateBlock, startLine: int, endLine: int, silent: bool)
| 12 | |
| 13 | |
| 14 | def hr(state: StateBlock, startLine: int, endLine: int, silent: bool) -> bool: |
| 15 | LOGGER.debug("entering hr: %s, %s, %s, %s", state, startLine, endLine, silent) |
| 16 | |
| 17 | pos = state.bMarks[startLine] + state.tShift[startLine] |
| 18 | maximum = state.eMarks[startLine] |
| 19 | |
| 20 | if state.is_code_block(startLine): |
| 21 | return False |
| 22 | |
| 23 | try: |
| 24 | marker = state.src[pos] |
| 25 | except IndexError: |
| 26 | return False |
| 27 | pos += 1 |
| 28 | |
| 29 | # Check hr marker |
| 30 | if marker not in ("*", "-", "_"): |
| 31 | return False |
| 32 | |
| 33 | # markers can be mixed with spaces, but there should be at least 3 of them |
| 34 | |
| 35 | cnt = 1 |
| 36 | while pos < maximum: |
| 37 | ch = state.src[pos] |
| 38 | pos += 1 |
| 39 | if ch != marker and not isStrSpace(ch): |
| 40 | return False |
| 41 | if ch == marker: |
| 42 | cnt += 1 |
| 43 | |
| 44 | if cnt < 3: |
| 45 | return False |
| 46 | |
| 47 | if silent: |
| 48 | return True |
| 49 | |
| 50 | state.line = startLine + 1 |
| 51 | |
| 52 | token = state.push("hr", "hr", 0) |
| 53 | token.map = [startLine, state.line] |
| 54 | token.markup = marker * (cnt + 1) |
| 55 | |
| 56 | return True |
nothing calls this directly
no test coverage detected