From e7013e66a9acf4a384cd1a6b2be919ceea1f8a29 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Thu, 19 Jan 2023 21:28:19 +0100 Subject: [PATCH] Fixed search crashing for some nested heading combinations (9.0.3 regression) --- material/plugins/search/plugin.py | 8 ++++---- src/plugins/search/plugin.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/material/plugins/search/plugin.py b/material/plugins/search/plugin.py index 38270d5dd..d059043a0 100644 --- a/material/plugins/search/plugin.py +++ b/material/plugins/search/plugin.py @@ -421,11 +421,11 @@ class Parser(HTMLParser): # which could also be a nested section – see https://bit.ly/3IxxIJZ if self.section.depth > len(self.context): for section in reversed(self.data): - if section.depth and section.depth <= len(self.context): + if section.depth <= len(self.context): - # Set depth to 0 in order to denote that the current section - # is exited and must not be considered again. - self.section.depth = 0 + # Set depth to infinity in order to denote that the current + # section is exited and must never be considered again. + self.section.depth = float("inf") self.section = section break diff --git a/src/plugins/search/plugin.py b/src/plugins/search/plugin.py index 38270d5dd..d059043a0 100644 --- a/src/plugins/search/plugin.py +++ b/src/plugins/search/plugin.py @@ -421,11 +421,11 @@ class Parser(HTMLParser): # which could also be a nested section – see https://bit.ly/3IxxIJZ if self.section.depth > len(self.context): for section in reversed(self.data): - if section.depth and section.depth <= len(self.context): + if section.depth <= len(self.context): - # Set depth to 0 in order to denote that the current section - # is exited and must not be considered again. - self.section.depth = 0 + # Set depth to infinity in order to denote that the current + # section is exited and must never be considered again. + self.section.depth = float("inf") self.section = section break