diff options
author | Zach Smith <subsetpark@gmail.com> | 2015-11-08 14:13:57 -0500 |
---|---|---|
committer | Zach Smith <subsetpark@gmail.com> | 2015-11-08 14:13:57 -0500 |
commit | bbeee06f1222fa47439717d2e4b642a41e9d7f4b (patch) | |
tree | 0600a08bcf93b6aaa20b931e0715ea7e39fe7276 | |
parent | ff586cd08ad4e226ea5d65eda8683afb5a5c9373 (diff) | |
parent | b82a8e45fa5b17ef5f15a410bfd5b694e5a07cba (diff) | |
download | pycco-bbeee06f1222fa47439717d2e4b642a41e9d7f4b.tar.gz |
Merge pull request #82 from textbook/cross-ref
Handle comments that contain only cross-references
-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'] |