mirror of
https://github.com/theoludwig/markdownlint-rule-relative-links.git
synced 2024-12-08 00:45:32 +01:00
fix: should only check valid fragments in markdown (.md) files
This commit is contained in:
parent
5c39afbe20
commit
e20ee54b05
@ -97,6 +97,10 @@ const customRule = {
|
||||
continue
|
||||
}
|
||||
|
||||
if (!url.pathname.endsWith(".md")) {
|
||||
continue
|
||||
}
|
||||
|
||||
const fileContent = fs.readFileSync(url, { encoding: "utf8" })
|
||||
const headings = getMarkdownHeadings(fileContent)
|
||||
const idOrAnchorNameHTMLFragments =
|
||||
|
0
test/fixtures/valid/only-parse-markdown-files-for-fragments/abc.txt
vendored
Normal file
0
test/fixtures/valid/only-parse-markdown-files-for-fragments/abc.txt
vendored
Normal file
9
test/fixtures/valid/only-parse-markdown-files-for-fragments/awesome.html
vendored
Normal file
9
test/fixtures/valid/only-parse-markdown-files-for-fragments/awesome.html
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Awesome</title>
|
||||
</head>
|
||||
<body></body>
|
||||
</html>
|
@ -0,0 +1,7 @@
|
||||
# Valid
|
||||
|
||||
[Link fragment HTML](./awesome.html#existing-heading)
|
||||
|
||||
[Link fragment TXT](./abc.txt#existing-heading)
|
||||
|
||||
[Link fragment Image](../../image.png#existing-heading)
|
@ -123,6 +123,11 @@ test("ensure the rule validates correctly", async (t) => {
|
||||
fixturePath:
|
||||
"test/fixtures/valid/existing-heading-fragment/existing-heading-fragment.md",
|
||||
},
|
||||
{
|
||||
name: "should only parse markdown files for fragments checking",
|
||||
fixturePath:
|
||||
"test/fixtures/valid/only-parse-markdown-files-for-fragments/only-parse-markdown-files-for-fragments.md",
|
||||
},
|
||||
{
|
||||
name: "with an existing file",
|
||||
fixturePath: "test/fixtures/valid/existing-file.md",
|
||||
|
Loading…
Reference in New Issue
Block a user