Simple things can be difficult. Links can be complicated. With this package headache no more.
Package verifies links in Markdown files. Typical use case is to verify Markdown files stored locally (e.g. as part of project's documentation in repository).
- find Markdown files in subdirectories
- check standard links
- check linked images
- handle relative and absolute links, local and external resources
- handle links to elements
- check if extenal URLs are reachable
- ignore Markdown syntax in code blocks (C++ lambdas syntax is simillar to Markdown links)
There is description of command line arguments. To simple run execute (dedicated script):
checkmdlinks.py --dir <path-to-dir-with-MD-files>
or run as module:
python3 -m mdlinkscheck --dir <path-to-dir-with-MD-files>
Application then will go recursively and look for .md
files and validate them. By passing -f
with list of
files there is possibility to run the check against given files only. Other options include passing
particular files and setting compatibility mode with GitHub or BitBucket version of Markdown.
Library simply converts Markdown to HTML and then extracts links using BeautifulSoup. After that links are
verified - this is quite tricky, because links can be absolute, relative, can point to HTML element, can point to
local file or external resource. Moreover links can contain e-mail address (mailto:
) or JavaScript. Even worse,
element links can point to implicit elements (GitHub does it in it's own way, bitbucket does it in different way).
There are couple of helpfull scripts to run:
src/install-deps.sh
- installation of dependenciessrc/install-package.sh
- installation of package (normal mode)src/install-devel.sh
- installation of package in editable modesrc/testmdlinkscheck/runtests.py
- runner for unit teststools/checkall.sh
- execute static code checks against source codetools/installvenv.sh
- prepare venv with packageprocess-all.sh
- run all tests (in venv), generators and code checks
- linkcheckmd - does not validate links to element
- markdown-link-checker - false positives in case of links to element
- md-url-checker - does not validate links to element
- Check-That-Link - does not validate links to element
- awesome-check-link - does not validate links to element
- HTML
a
href Attribute - HTML
img
src Attribute - Markdown format
- mistune - Markdown to HTML conversion
BSD 3-Clause License
Copyright (c) 2023, Arkadiusz Netczuk dev.arnet@gmail.com
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-
Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.