Skip to content

Commit 3e0cb45

Browse files
ldeluigitimvink
authored andcommitted
Fix fallback behaviour
1 parent 137c5e7 commit 3e0cb45

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

mkdocs_git_authors_plugin/plugin.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,13 @@ def on_page_content(self, html, page, config, files, **kwargs):
108108
Returns:
109109
str: HTML text of page as string
110110
"""
111-
if self._fallback:
112-
return html
113111

114112
list_pattern = re.compile(
115113
r"\{\{\s*git_site_authors\s*\}\}", flags=re.IGNORECASE
116114
)
117115
if list_pattern.search(html):
118116
html = list_pattern.sub(
117+
"" if self._fallback else
119118
util.site_authors_summary(self.repo().get_authors(), self.config), html
120119
)
121120
return html
@@ -140,9 +139,6 @@ def on_page_markdown(self, markdown, page, config, files, **kwargs):
140139
Returns:
141140
str: Markdown source text of page as string
142141
"""
143-
if self._fallback:
144-
return markdown
145-
146142
pattern_authors_summary = re.compile(
147143
r"\{\{\s*git_authors_summary\s*\}\}", flags=re.IGNORECASE
148144
)
@@ -155,6 +151,11 @@ def on_page_markdown(self, markdown, page, config, files, **kwargs):
155151
) and not pattern_page_authors.search(markdown):
156152
return markdown
157153

154+
if self._fallback:
155+
markdown = pattern_authors_summary.sub("", markdown)
156+
markdown = pattern_page_authors.sub("", markdown)
157+
return markdown
158+
158159
page_obj = self.repo().page(page.file.abs_src_path)
159160
page_authors = util.page_authors_summary(page_obj, self.config)
160161

0 commit comments

Comments
 (0)