Update MD025/single-title and MD051/link-fragments to ignore headings that exactly match Docfx tab syntax (fixes #1099) (fixes #1101).

This commit is contained in:
David Anson 2025-05-01 22:09:36 -07:00
parent a4b7ffa8ce
commit 6adfaf68b5
6 changed files with 115 additions and 4 deletions

View file

@ -1,7 +1,7 @@
// @ts-check
import { addError, getHtmlAttributeRe } from "../helpers/helpers.cjs";
import { filterByPredicate, filterByTypes, getHtmlTagInfo } from "../helpers/micromark-helpers.cjs";
import { filterByPredicate, filterByTypes, getHtmlTagInfo, isDocfxTab } from "../helpers/micromark-helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";
// Regular expression for identifying HTML anchor names
@ -110,7 +110,10 @@ export default {
[ "definition", "definitionDestinationString" ]
];
for (const [ parentType, definitionType ] of parentChilds) {
const links = filterByTypesCached([ parentType ]);
const links = filterByTypesCached([ parentType ])
.filter(
(link) => !((link.parent?.type === "atxHeadingText") && isDocfxTab(link.parent.parent))
);
for (const link of links) {
const definitions = filterByTypes(link.children, [ definitionType ]);
for (const definition of definitions) {