@@ -138,6 +138,7 @@ def on_page_content(self, html, page, config, files, **kwargs):
138138 if exclude (page .file .src_path , excluded_pages ):
139139 return html
140140
141+ # Replace {{ git_site_authors }}
141142 list_pattern = re .compile (
142143 r"\{\{\s*git_site_authors\s*\}\}" , flags = re .IGNORECASE
143144 )
@@ -146,59 +147,20 @@ def on_page_content(self, html, page, config, files, **kwargs):
146147 "" if self ._fallback else
147148 util .site_authors_summary (self .repo ().get_authors (), self .config ), html
148149 )
149- return html
150-
151- def on_page_markdown (self , markdown , page , config , files , ** kwargs ):
152- """
153- Replace jinja tags in markdown.
154-
155- The page_markdown event is called after the page's markdown is loaded
156- from file and can be used to alter the Markdown source text.
157- The meta- data has been stripped off and is available as page.meta
158- at this point.
159-
160- https://www.mkdocs.org/user-guide/plugins/#on_page_markdown
161-
162- Args:
163- markdown (str): Markdown source text of page as string
164- page: mkdocs.nav.Page instance
165- config: global configuration object
166- site_navigation: global navigation object
167150
168- Returns:
169- str: Markdown source text of page as string
170- """
171- if not self .config .get ('enabled' ):
172- return markdown
173-
174- # Exclude pages specified in config
175- excluded_pages = self .config .get ("exclude" , [])
176- if exclude (page .file .src_path , excluded_pages ):
177- return markdown
151+ # Replace {{ git_page_authors }}
152+ page_obj = self .repo ().page (page .file .abs_src_path )
153+ page_authors = util .page_authors_summary (page_obj , self .config )
178154
179- pattern_authors_summary = re .compile (
180- r"\{\{\s*git_authors_summary\s*\}\}" , flags = re .IGNORECASE
181- )
182- pattern_page_authors = re .compile (
155+ list_pattern = re .compile (
183156 r"\{\{\s*git_page_authors\s*\}\}" , flags = re .IGNORECASE
184157 )
158+ if list_pattern .search (html ):
159+ html = list_pattern .sub (
160+ "" if self ._fallback else page_authors , html
161+ )
185162
186- if not pattern_authors_summary .search (
187- markdown
188- ) and not pattern_page_authors .search (markdown ):
189- return markdown
190-
191- if self ._fallback :
192- markdown = pattern_authors_summary .sub ("" , markdown )
193- markdown = pattern_page_authors .sub ("" , markdown )
194- return markdown
195-
196- page_obj = self .repo ().page (page .file .abs_src_path )
197- page_authors = util .page_authors_summary (page_obj , self .config )
198-
199- markdown = pattern_authors_summary .sub (page_authors , markdown )
200- markdown = pattern_page_authors .sub (page_authors , markdown )
201- return markdown
163+ return html
202164
203165 def on_page_context (self , context , page , config , nav , ** kwargs ):
204166 """
@@ -255,10 +217,6 @@ def on_page_context(self, context, page, config, nav, **kwargs):
255217 context ["git_page_authors" ] = page_authors
256218 context ["git_site_authors" ] = site_authors
257219
258- # For backward compatibility, deprecate in 1.2
259- context ["git_authors" ] = util .page_authors (authors , path )
260- context ["git_authors_summary" ] = page_authors
261-
262220 return context
263221
264222 def repo (self ):
0 commit comments