๐๐๐๐๐
whxaxes / check-md Goto Github PK
View Code? Open in Web Editor NEWchecks dead links of markdown
checks dead links of markdown
For example, when using webpack aliases (as suggested by vuepress docs), we have URLs for images that look like this:
![image alt](~@assets/my-image.png)
There is currently no way to declare this alias.
When cross-linking to "external" websites, the website you're linking to may be extremely slow in returning a response. This results in some false failures being reported.
It would be good to allow for a max timeout or delay before reporting that the link is "dead".
An example site that I link to that always reports as "dead":
https://www.tobiidynavox.com/en-us/support-training/windows-control-2/
When linking to other markdown files, in particular to the default README.md
, it may be preferable (most of the time?) to reference them by their permalink, instead of the actual location in the directory structure. Because, if the default README.md
ever changes, then the link will work; however, the content isn't exactly what it should be, so to guard against that, you want to be explicit as you can in your links.
For example, this is fine, as long as the content in /path/to/some/README.md
doesn't change.
Go read the [usage docs](/path/to/some/README.md)
But, to safe guard against accidentally pointing someone to the wrong docs, it's preferred to instead to do this:
Go read the [usage docs](/path/to/some/usage-docs)
and, in the /path/to/some/README.md
file, provide a permalink
...
---
permalink: /path/to/some/usage-docs.html
---
This is the `/path/to/some/README.md` file, containing content for the usage docs.
But, check-md
doesn't appear to account for this, and returns a dead link, even though the link isn't really dead because the permalink properly places the README.md at the permalink location.
File is not found: [usage docs](/path/to/some/usage-docs) (/Users/CDura/code/my-project/src/another/page/README.md:32:99)
When the markdown file contains typescript like:
- Type: `{ [path: string]: Object }`
We'll get following error:
File is not found: [path: string]: Object }` (/path/to/foo.md:86:12)
I have added a sizing to my svg link and it generated a dead link error.
1 dead links was found
File is not found: ![document structure](/document_structure.svg =573x400) (/documentation/guides/main_concepts/documents.md:6:1)
This is how the link is transformed:
'/document_structure.svg%20=573x400',
Should we pattern match %
and remove what is behind ?
The strict extension mode makes the .md extension mandatory in links to recognized md files.
This means that a link to a markdown file not containing the .md extension will raise a warning:
This only raises an error when the .md extension is missing on a md file. If the link is to a directory because it will automatically redirect to the README.md
or index.md
file inside that directory, it will NOT raise a warning.
Since dir
is a directory containing a README.md file, this will NOT raise an error:
[test17](/dir)
[test18](/dir#test)
Since other
is a markdown file whose .md extension is missing, this will raise an error:
[test7](/other#ctx-get-name)
[test8](/other#cccc)
Checking markdown...
2 warning was found
File found with this name but .md extension missing: [test7](/other#ctx-get-name) (/Users/charlottevermandel/check-md/test/fixtures/docs1/test.md:17:1)
File found with this name but .md extension missing: [test8](/other#cccc) (/Users/charlottevermandel/check-md/test/fixtures/docs1/test.md:19:1)
it is used, as --fix, by adding the option without parameter.
check-md -p 'vuepress' -c 'test/fixtures/vuepress' --strict-ext
I'm working on it on this PR: bidoubiwa#1. I will make a PR here once it's done.
There's some legit reasons that you may want to have a link that actually doesn't go anywhere in the markdown, like [example link text](#)
, especially in documentation sites.
In fact, you may want to be able to ignore any particular pattern
in the link URL (not just ignore a particular filename pattern). For example:
Here's a [internal link](https://auth.my-project.com) that is behind Oauth, so it'll always look โ ๏ธ, but it's not ๐
It would be nice to be able to pass in a format that would print all of the errors as GitHub Actions annotations.
Vuepress has updated its slugify function (for both v1 and next/v2):
const rControl = /[\u0000-\u001f]/g
const rSpecial = /[\s~`!@#$%^&*()\-_+=[\]{}|\\;:"'โโโโโโ<>,.?/]+/g
const rCombining = /[\u0300-\u036F]/g
export const slugify = (str: string): string =>
str
.normalize('NFKD')
// Remove accents
.replace(rCombining, '')
// Remove control characters
.replace(rControl, '')
// Replace special characters
.replace(rSpecial, '-')
// Remove continuos separators
.replace(/-{2,}/g, '-')
// Remove prefixing and trailing separators
.replace(/^-+|-+$/g, '')
// ensure it doesn't start with a number (#121)
.replace(/^(\d)/, '_$1')
// lowercase
.toLowerCase()
It adds steps of normalizing and removing accents, and no longer requires diacritics
dependency. Also, rSpecial
adds some new characters.
It's time to fix it now, but should we change defaultSlugify
function directly or add a new function / config for vuepress preset?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.