in eng/tools/lint-diff/src/markdown-utils.ts [194:223]
export function getDefaultTag(markdownContent: string): string {
const parsed = parseMarkdown(markdownContent);
const startNode = parsed.markDown;
const codeBlockMap = amd.getCodeBlocksAndHeadings(startNode);
const latestHeader = "Basic Information";
const lh = codeBlockMap[latestHeader];
if (lh) {
const latestDefinition = YAML.load(lh.literal!, { schema: YAML.FAILSAFE_SCHEMA }) as undefined | { tag: string };
if (latestDefinition) {
return latestDefinition.tag;
}
} else {
for (let idx of Object.keys(codeBlockMap)) {
const lh = codeBlockMap[idx];
if (!lh || !lh.info || lh.info.trim().toLocaleLowerCase() !== "yaml") {
continue;
}
const latestDefinition = YAML.load(lh.literal!, { schema: YAML.FAILSAFE_SCHEMA }) as
| undefined
| { tag: string };
if (latestDefinition) {
return latestDefinition.tag;
}
}
}
return "";
}