Skip to content

Commit 146f904

Browse files
committed
chore: small tweaks
1 parent 6439695 commit 146f904

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

.markdownlint-cli2.jsonc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"config": {
33
"extends": "markdownlint/style/prettier",
4-
"relative-links": true,
54
"default": true,
6-
"MD033": false
5+
"relative-links": true,
6+
"no-inline-html": false
77
},
88
"globs": ["**/*.{md,mdx}"],
99
"ignores": ["**/node_modules", "**/test/fixtures/**"],

src/utils.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ const getMarkdownHeadings = (content) => {
7777
return headings
7878
}
7979

80-
const anchorNameRe = getHtmlAttributeRe("name")
81-
const anchorIdRe = getHtmlAttributeRe("id")
80+
const nameHTMLAttributeRegex = getHtmlAttributeRe("name")
81+
const idHTMLAttributeRegex = getHtmlAttributeRe("id")
8282

8383
/**
8484
* Gets the id or anchor name fragments from a Markdown string.
@@ -93,20 +93,21 @@ const getMarkdownIdOrAnchorNameFragments = (content) => {
9393
const result = []
9494

9595
for (const token of tokens) {
96-
const anchorMatch =
97-
anchorIdRe.exec(token.content) || anchorNameRe.exec(token.content)
98-
if (anchorMatch == null) {
96+
const regexMatch =
97+
idHTMLAttributeRegex.exec(token.content) ||
98+
nameHTMLAttributeRegex.exec(token.content)
99+
if (regexMatch == null) {
99100
continue
100101
}
101102

102-
const anchorIdOrName = anchorMatch[1]
103-
if (anchorIdOrName == null || anchorIdOrName.length <= 0) {
103+
const idOrName = regexMatch[1]
104+
if (idOrName == null || idOrName.length <= 0) {
104105
continue
105106
}
106107

107-
const anchorHTMLFragment = "#" + anchorIdOrName
108-
if (!result.includes(anchorHTMLFragment)) {
109-
result.push(anchorHTMLFragment)
108+
const htmlFragment = "#" + idOrName
109+
if (!result.includes(htmlFragment)) {
110+
result.push(htmlFragment)
110111
}
111112
}
112113

0 commit comments

Comments
 (0)