diff options
-rw-r--r-- | pycco/main.py | 2 | ||||
-rw-r--r-- | tests/test_pycco.py | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/pycco/main.py b/pycco/main.py index cde05d7..eeaf816 100644 --- a/pycco/main.py +++ b/pycco/main.py @@ -195,7 +195,7 @@ def preprocess(comment, preserve_paths=True, outdir=None): ) comment = re.sub('^([=]+)([^=]+)[=]*\s*$', replace_section_name, comment) - comment = re.sub('[^`]\[\[(.+?)\]\]', replace_crossref, comment) + comment = re.sub('(?<!`)\[\[(.+?)\]\]', replace_crossref, comment) return comment diff --git a/tests/test_pycco.py b/tests/test_pycco.py index 5a38dd5..7248a1a 100644 --- a/tests/test_pycco.py +++ b/tests/test_pycco.py @@ -60,6 +60,13 @@ def test_multi_line_leading_spaces(): assert parsed[0]["docs_text"] == "This is a\ncomment that\nis indented\n" +def test_comment_with_only_cross_ref(): + source = '''# ==Link Target==\n\ndef test_link():\n """[[testing.py#link-target]]"""\n pass''' + sections = p.parse(source, PYTHON) + p.highlight(sections, PYTHON, outdir=tempfile.gettempdir()) + assert sections[1]['docs_html'] == '<p><a href="testing.html#link-target">testing.py</a></p>' + + @given(text(), text()) def test_get_language_specify_language(source, code): assert p.get_language(source, code, language="python") == p.languages['.py'] |