Repository: jupyterlab/pytest-check-links (language: python)

Issue:
Ignore links for notebook (ipynb) files
The --check-links-ignore argument does not work for ipynb files. It is working fine for other file formats.


Discussion / hints:
Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
<br>If you haven't done so already, check out [Jupyter's Code of Conduct](https://github.com/jupyter/governance/blob/master/conduct/code_of_conduct.md). Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
![welcome](https://raw.githubusercontent.com/jupyterlab/.github/master/images/welcome.jpg)
You can meet the other [Jovyans](https://jupyter.readthedocs.io/en/latest/community/content-community.html?highlight=jovyan#what-is-a-jovyan) by joining our [Discourse forum](http://discourse.jupyter.org/). There is also an intro thread there where you can stop by and say Hi! :wave:
<br>Welcome to the Jupyter community! :tada:

I think I can fix this, will send a PR soon.

Fix patch:
diff --git a/examples/linkcheck.ipynb b/examples/linkcheck.ipynb
index ecb967d..cd5a50d 100644
--- a/examples/linkcheck.ipynb
+++ b/examples/linkcheck.ipynb
@@ -46,8 +46,15 @@
     "\n",
     "[markdown local bad](doesntexist.html)\n",
     "\n",
-    "[markdown absolute](/tmp)"
+    "[markdown absolute](/tmp)\n",
+    "\n",
+    "[markdown link to ignore](http://example.com/404)"
    ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": []
   }
  ],
  "metadata": {


Test patch:
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index d3ff428..ebaf6ec 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -16,7 +16,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        PLATFORM: ['ubuntu-latest', 'macos-latest',  'windows-latest']
+        PLATFORM: ['ubuntu-latest', 'macos-10.15',  'windows-latest']
         PYTHON_VERSION: ['3.6', '3.9']
     steps:
       - name: Checkout
diff --git a/pytest_check_links/plugin.py b/pytest_check_links/plugin.py
index af27aad..165f7a7 100644
--- a/pytest_check_links/plugin.py
+++ b/pytest_check_links/plugin.py
@@ -136,7 +136,12 @@ def _items_from_notebook(self):
             html = MarkdownWithMath(renderer=renderer).render(cell.source)
             basename = 'Cell %i' % cell_num
             for item in links_in_html(basename, self, html):
-                yield item
+                ignore = False
+                for pattern in self.ignore_links:
+                    if re.match(pattern, item.target):
+                        ignore = True
+                if not ignore:
+                    yield item
 
     def collect(self):
         path = self.fspath
diff --git a/test/test_cache.py b/test/test_cache.py
index 8ffc1cd..417ec87 100644
--- a/test/test_cache.py
+++ b/test/test_cache.py
@@ -31,7 +31,7 @@ def test_cache_expiry(testdir, base_args, cache_name, tmpdir):
     args = base_args + ["--check-links-cache-expire-after", "2"]
     if cache_name:
         args += ["--check-links-cache-name", os.path.join(str(tmpdir), cache_name)]
-    expected = dict(passed=3, failed=3)
+    expected = dict(passed=3, failed=4)
     t0 = time.time()
     result = testdir.runpytest(*args)
     t1 = time.time()
diff --git a/test/test_check_links.py b/test/test_check_links.py
index 2a2a92a..b9d3fb4 100644
--- a/test/test_check_links.py
+++ b/test/test_check_links.py
@@ -6,6 +6,8 @@
 def test_ipynb(testdir):
     testdir.copy_example('linkcheck.ipynb')
     result = testdir.runpytest("-v", "--check-links")
+    result.assert_outcomes(passed=3, failed=4)
+    result = testdir.runpytest("-v", "--check-links", "--check-links-ignore", "http.*example.com/.*")
     result.assert_outcomes(passed=3, failed=3)
 
 def test_markdown(testdir):
@@ -47,4 +49,4 @@ def test_link_ext(testdir):
     testdir.copy_example('rst.rst')
     testdir.copy_example('markdown.md')
     result = testdir.runpytest("-v", "--check-links", "--links-ext=md,ipynb")
-    result.assert_outcomes(passed=11, failed=7)
+    result.assert_outcomes(passed=11, failed=8)