Ejemplo n.º 1
0
def test_replace_href_inline():
    doc = """A link to [some file](some-file) followed by
a link to [another file](another-file) and
[the first file again](some-file)."""
    expected = """A link to [some file](new-ref) followed by
a link to [another file](another-file) and
[the first file again](new-ref)."""
    assert _replace_href(doc, 'some-file', 'new-ref') == expected
Ejemplo n.º 2
0
def test_replace_href_refstyle():
    doc = """Here we see the ref style syntax:
[some id]: file-1 "Some Text"
[other id]: file-1
[third id]: file-2
Ignored in the middle of a line: [some id]: file-1"""
    expected = """Here we see the ref style syntax:
[some id]: new-ref "Some Text"
[other id]: new-ref
[third id]: file-2
Ignored in the middle of a line: [some id]: file-1"""
    assert _replace_href(doc, 'file-1', 'new-ref') == expected
Ejemplo n.º 3
0
def test_replace_href_replacement_string_special_characters():
    doc = """A [link](foo.md).
[refstyle]: foo.md"""
    expected = """A [link](2-foo\\3.md).
[refstyle]: 2-foo\\3.md"""
    assert _replace_href(doc, 'foo.md', '2-foo\\3.md') == expected
Ejemplo n.º 4
0
def test_replace_href_image():
    doc = "An ![image link](http://example.com/foo.png) should work too."
    expected = "An ![image link](http://example.com/bar.png) should work too."
    assert _replace_href(doc, 'http://example.com/foo.png', 'http://example.com/bar.png') == expected