diff --git a/pymdownx/snippets.py b/pymdownx/snippets.py index 305c7c0aa..7c2c19ceb 100644 --- a/pymdownx/snippets.py +++ b/pymdownx/snippets.py @@ -245,6 +245,9 @@ def download(self, url): continue raise SnippetMissingError(f"Cannot download snippet '{url}' (HTTP Error {e.code})") from e + def post_process_snippet(self, s_lines, snippet): + """Override to post-process the snippet's content.""" + return s_lines def parse_snippets(self, lines, file_name=None, is_url=False, is_section=False): """Parse snippets snippet.""" @@ -390,6 +393,10 @@ def parse_snippets(self, lines, file_name=None, is_url=False, is_section=False): elif section: s_lines = self.extract_section(section, s_lines) + # call the post-process hook + if s_lines: + s_lines = self.post_process_snippet(s_lines, snippet) + # Process lines looking for more snippets new_lines.extend( [