diff --git a/material/plugins/search/plugin.py b/material/plugins/search/plugin.py index 710746bec..89f72b4ba 100644 --- a/material/plugins/search/plugin.py +++ b/material/plugins/search/plugin.py @@ -401,8 +401,10 @@ class Parser(HTMLParser): # Render opening tag if kept if not self.skip.intersection(self.context): if tag in self.keep: + + # Check whether we're inside the section title data = self.section.text - if self.section.el in reversed(self.context): + if self.section.el in self.context: data = self.section.title # Append to section title or text diff --git a/src/plugins/search/plugin.py b/src/plugins/search/plugin.py index 710746bec..89f72b4ba 100644 --- a/src/plugins/search/plugin.py +++ b/src/plugins/search/plugin.py @@ -401,8 +401,10 @@ class Parser(HTMLParser): # Render opening tag if kept if not self.skip.intersection(self.context): if tag in self.keep: + + # Check whether we're inside the section title data = self.section.text - if self.section.el in reversed(self.context): + if self.section.el in self.context: data = self.section.title # Append to section title or text