diff --git a/markdown_it/parser_block.py b/markdown_it/parser_block.py index 3c4d4019..1458f17d 100644 --- a/markdown_it/parser_block.py +++ b/markdown_it/parser_block.py @@ -58,6 +58,7 @@ def __init__(self) -> None: def tokenize(self, state: StateBlock, startLine: int, endLine: int) -> None: """Generate tokens for input range.""" + ok = False rules = self.ruler.getRules("") line = startLine maxNesting = state.md.options.maxNesting @@ -82,10 +83,19 @@ def tokenize(self, state: StateBlock, startLine: int, endLine: int) -> None: # - update `state.line` # - update `state.tokens` # - return True + prevLine = state.line + for rule in rules: - if rule(state, line, endLine, False): + ok = rule(state, line, endLine, False) + if ok: + if prevLine >= state.line: + raise Exception("block rule didn't increment state.line") break + # this can only happen if user disables paragraph rule + if not ok: + raise Exception("none of the block rules matched") + # set state.tight if we had an empty line before current tag # i.e. latest empty line should not count state.tight = not hasEmptyLines diff --git a/markdown_it/parser_inline.py b/markdown_it/parser_inline.py index 8f3ac1e6..4fae6722 100644 --- a/markdown_it/parser_inline.py +++ b/markdown_it/parser_inline.py @@ -84,6 +84,8 @@ def skipToken(self, state: StateInline) -> None: ok = rule(state, True) state.level -= 1 if ok: + if pos >= state.pos: + raise Exception("inline rule didn't increment state.pos") break else: # Too much nesting, just skip until the end of the paragraph. @@ -117,11 +119,14 @@ def tokenize(self, state: StateInline) -> None: # - update `state.pos` # - update `state.tokens` # - return true + prevPos = state.pos if state.level < maxNesting: for rule in rules: ok = rule(state, False) if ok: + if prevPos >= state.pos: + raise Exception("inline rule didn't increment state.pos") break if ok: diff --git a/markdown_it/port.yaml b/markdown_it/port.yaml index 3e289e9e..60940d33 100644 --- a/markdown_it/port.yaml +++ b/markdown_it/port.yaml @@ -1,7 +1,7 @@ - package: markdown-it/markdown-it version: 13.0.1 - commit: e843acc9edad115cbf8cf85e676443f01658be08 - date: May 3, 2022 + commit: 49ca65bbef067c7dba63468a48c4aee3048607dc + date: Sep 26, 2023 notes: - Rename variables that use python built-in names, e.g. - `max` -> `maximum`