Comments starting with cross-references fail on preprocess
textbook opened this issue · comments
The regex used by preprocess
requires a character other than a backtick prior to the first cross-reference in a comment, so if the comment starts with a cross-reference it is not handled correctly. To recreate, save the following sample as testing.py
and process with pycco testing.py
.
# ==Link Target==
def test_link():
"""[[testing.py#link-target]]"""
pass
Instead of [^
], a negative lookbehind
(?<!)
can be used to remove this requirement. This also means that the opening whitespace in the replacement strings in replace_crossref
is no longer required.