diff --git a/sync/sync.py b/sync/sync.py index 99e8e7c2b..cb8770b4d 100755 --- a/sync/sync.py +++ b/sync/sync.py @@ -198,8 +198,11 @@ def decode(s, encodings=('utf8', 'latin1', 'ascii')): def transform_line(line, base_path, local_files, rewrite_path, rewrite_url): """ transform all the links in one line """ line = line.rstrip() - links = get_links(line) - # If there are links in this line we may need to fix them + # We need to left strip lines before paring for links because + # reading the markdown line by line, the context is lost and line + # indented because of a list is otherwise considered as a code block + # Links are ignored in code blocks + links = get_links(line.lstrip()) # If there are links in this line we may need to fix them for link in links: # link contains the text and href href =link.get("href") diff --git a/sync/test_sync.py b/sync/test_sync.py index 83e75a573..3acdd4749 100644 --- a/sync/test_sync.py +++ b/sync/test_sync.py @@ -282,7 +282,9 @@ def test_transform_line(self): "[notfound-relative-link-dotdot](../examples/notfound.txt)", "[invalid-absolute-link](www.github.com)", ("[valid-absolute-link](https://website-random321.net#FRagment) " - "[valid-ref-link](#fooTEr)") + "[valid-ref-link](#fooTEr)"), + " - [exists-link-in-list](./test.txt)", + " [exists-link-indented](./test.txt) " ] expected_results = [ "[exists-relative-link](/docs/test/test.txt)", @@ -295,7 +297,9 @@ def test_transform_line(self): "[notfound-relative-link-dotdot](http://test.com/tree/docs/examples/notfound.txt)", "[invalid-absolute-link](http://test.com/tree/docs/www.github.com)", ("[valid-absolute-link](https://website-random321.net#FRagment) " - "[valid-ref-link](#footer)") + "[valid-ref-link](#footer)"), + " - [exists-link-in-list](/docs/test/test.txt)", + " [exists-link-indented](/docs/test/test.txt) " ] for case, expected in zip(cases, expected_results):