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 { addErrorContext, frontMatterHasTitle } from "../helpers/helpers.cjs";
import { getHeadingLevel, getHeadingText, isHtmlFlowComment, nonContentTokens } from "../helpers/micromark-helpers.cjs";
import { getHeadingLevel, getHeadingText, isDocfxTab, isHtmlFlowComment, nonContentTokens } from "../helpers/micromark-helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";
/** @type {import("markdownlint").Rule} */
@ -14,7 +14,7 @@ export default {
const level = Number(params.config.level || 1);
const { tokens } = params.parsers.micromark;
const matchingHeadings = filterByTypesCached([ "atxHeading", "setextHeading" ])
.filter((heading) => level === getHeadingLevel(heading));
.filter((heading) => (level === getHeadingLevel(heading)) && !isDocfxTab(heading));
if (matchingHeadings.length > 0) {
const foundFrontMatterTitle =
frontMatterHasTitle(