Several issues with Citavi
dawtmaytrikx opened this issue · 3 comments
Hi there,
I noticed two things that might not require fixing, but I'd at least want to point out to the next person trying to get this plugin work with Citavi: The regex currently does not capture bibtex keys that contain a period, e. g. @Bermudez.2020. This is the default setting for Citavi, and it took me quite a while to figure out why the plugin wasn't parsing my citations in mkdocs.
Also, enabling the URL-package in Citavi (i. e. rendering the URLs in the bibtex file as url = {\url{https://doi.org/10.21577/0103-5053.20190253}}
) causes the following error:
ERROR - Error reading page 'sandalwood.md': bad escape \u at position 248
Traceback (most recent call last):
File "/usr/lib/python3.9/sre_parse.py", line 1039, in parse_template
this = chr(ESCAPES[this][1])
KeyError: '\\u'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/mkdocs", line 8, in <module>
sys.exit(cli())
File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/mkdocs/__main__.py", line 250, in build_command
build.build(cfg, dirty=not clean)
File "/usr/local/lib/python3.9/dist-packages/mkdocs/commands/build.py", line 308, in build
_populate_page(file.page, config, files, dirty)
File "/usr/local/lib/python3.9/dist-packages/mkdocs/commands/build.py", line 177, in _populate_page
page.markdown = config.plugins.run_event(
File "/usr/local/lib/python3.9/dist-packages/mkdocs/plugins.py", line 520, in run_event
result = method(item, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/mkdocs_bibtex/plugin.py", line 132, in on_page_markdown
markdown = re.sub(
File "/usr/lib/python3.9/re.py", line 210, in sub
return _compile(pattern, flags).sub(repl, string, count)
File "/usr/lib/python3.9/re.py", line 327, in _subx
template = _compile_repl(template, pattern)
File "/usr/lib/python3.9/re.py", line 318, in _compile_repl
return sre_parse.parse_template(repl, pattern)
File "/usr/lib/python3.9/sre_parse.py", line 1042, in parse_template
raise s.error('bad escape %s' % this, len(this))
re.error: bad escape \u at position 248
Wow, never heard of Citavi til now.
The .
not working in cite keys is an actual issue.
The 2nd error is a bit odd. It appears the issue is that escaping in python regex is really complicated. Probably shouldn't use regex here since the plugin already knows the tag to replace.
I'll work on these sometime next week.
I added some tests in #155 and they seem to work. Can you provide a minimal breaking example? Maybe try updating your mkdocs-bibtex
version first?
Closing this due to lack of update.