Skip to content

Commit e60d56c

Browse files
committed
simplify code by using regex to replace tags
1 parent 74e978a commit e60d56c

File tree

1 file changed

+20
-2
lines changed
  • mkdocs_git_revision_date_localized_plugin

1 file changed

+20
-2
lines changed

mkdocs_git_revision_date_localized_plugin/plugin.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import re
12
from os import environ
23

34
from mkdocs.config import config_options
45
from mkdocs.plugins import BasePlugin
56
from mkdocs.utils import string_types
6-
from jinja2 import Template
77
from .util import Util
88
from datetime import datetime
99

@@ -64,5 +64,23 @@ def on_page_markdown(self, markdown, page, config, files):
6464
print('WARNING - macros plugin must be placed AFTER the git-revision-date-localized plugin. Skipping markdown modifications')
6565
return markdown
6666
else:
67-
return Template(markdown).render({'git_revision_date_localized': revision_date})
67+
#print("TEST TEST")
68+
# print()
69+
# print(f"revision_date: {revision_date}")
70+
# revision_date = "2019-21-12"
71+
# markdown = "text with {{ git_revision_date_localized }} here"
72+
73+
markdown = re.sub(r"\{\{(\s)*git_revision_date_localized(\s)*\}\}",
74+
revision_date,
75+
markdown,
76+
flags=re.IGNORECASE)
77+
78+
# print(markdown)
79+
80+
markdown = re.sub(r"\{\{\s*page\.meta\.git_revision_date_localized\s*\}\}",
81+
revision_date,
82+
markdown,
83+
flags=re.IGNORECASE)
84+
85+
return markdown
6886

0 commit comments

Comments
 (0)