From 033a9cc517dde35664e8608708539a2d4a7326ac Mon Sep 17 00:00:00 2001 From: shaokeyibb Date: Sun, 11 Aug 2024 01:44:50 +0800 Subject: [PATCH] fix: #21 --- .../extension.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/python-markdown-extension/src/python_markdown_document_offsets_injection_extension/extension.py b/python-markdown-extension/src/python_markdown_document_offsets_injection_extension/extension.py index 95dbec74..f88e2d08 100644 --- a/python-markdown-extension/src/python_markdown_document_offsets_injection_extension/extension.py +++ b/python-markdown-extension/src/python_markdown_document_offsets_injection_extension/extension.py @@ -91,11 +91,15 @@ class OffsetsInjectionBlockProcessor(BlockProcessor): last_processed_line_idx: int = -1 + is_in_prerender: bool = False + def __init__(self, parser: BlockParser, meta: dict): super(OffsetsInjectionBlockProcessor, self).__init__(parser) self.meta = meta def test(self, _, block) -> bool: + if self.is_in_prerender: + return False for i in range(0, len(self.meta["preprocessed_document"])): line: str = self.meta["preprocessed_document"][i] if len(line) == 0: @@ -129,9 +133,11 @@ def run(self, parent: etree.Element, blocks: list[str]): if start == -1: return + self.is_in_prerender = True previous_len = len(parent) self.parser.parseBlocks(parent, [block]) parsed_len = len(parent) + self.is_in_prerender = False blocks.pop(0)