You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi
I'm facing the problem below, please let me know if there is some workaround to build document with as_datetime setting is enabled.
Description
When if as_datetime: true as the plugin setting, then the command mkdocs build will fail by the following error:
ERROR - Error reading page 'index.md': decoding to str: need a bytes-like object, datetime.datetime found
Traceback (most recent call last):
File "/usr/local/bin/mkdocs", line 8, in <module>
sys.exit(cli())
File "/usr/local/lib/python3.8/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.8/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/mkdocs/__main__.py", line 152, in build_command
build.build(config.load_config(**kwargs), dirty=not clean)
File "/usr/local/lib/python3.8/site-packages/mkdocs/commands/build.py", line 271, in build
_populate_page(file.page, config, files, dirty)
File "/usr/local/lib/python3.8/site-packages/mkdocs/commands/build.py", line 167, in _populate_page
page.markdown = config['plugins'].run_event(
File "/usr/local/lib/python3.8/site-packages/mkdocs/plugins.py", line 94, in run_event
result = method(item, **kwargs)
File "/usr/local/lib/python3.8/site-packages/mkdocs_git_revision_date_plugin/plugin.py", line 57, in on_page_markdown
markdown = re.sub(r"\{\{(\s)*git_revision_date(\s)*\}\}",
File "/usr/local/lib/python3.8/re.py", line 210, in sub
return _compile(pattern, flags).sub(repl, string, count)
File "/usr/local/lib/python3.8/re.py", line 327, in _subx
template = _compile_repl(template, pattern)
File "/usr/local/lib/python3.8/re.py", line 318, in _compile_repl
return sre_parse.parse_template(repl, pattern)
File "/usr/local/lib/python3.8/sre_parse.py", line 972, in parse_template
s = Tokenizer(source)
File "/usr/local/lib/python3.8/sre_parse.py", line 228, in __init__
string = str(string, 'latin1')
TypeError: decoding to str: need a bytes-like object, datetime.datetime found
I'm investigating this issue.
it is caused by regex replacing as reported in the stacktrace above:
File "/usr/local/lib/python3.8/site-packages/mkdocs_git_revision_date_plugin/plugin.py", line 57, in on_page_markdown
markdown = re.sub(r"\{\{(\s)*git_revision_date(\s)*\}\}",
The repl argument of re.sub should be string or function but it is taking datetime object because of as_datetime: true.
This change is created by the PR #10, and it had been provided to solve the issue #9.
I have no idea to avoid both (reported here and #9) issues for now...I'll investigate for more.
Hi
I'm facing the problem below, please let me know if there is some workaround to build document with as_datetime setting is enabled.
Description
When if
as_datetime: true
as the plugin setting, then the commandmkdocs build
will fail by the following error:Steps to reproduce the bug
The problem can be reproduced by using the simple project below with the package versions below:
https://github.com/hitsumabushi845/git-revision-issue-reproduction
Package versions
3.8.6
1.1.2
0.3.1
The text was updated successfully, but these errors were encountered: