// @ts-check import os from "node:os"; import path from "node:path"; import test from "ava"; import { characterEntities } from "character-entities"; import { gemoji } from "gemoji"; import helpers, { formatLintResults } from "../helpers/helpers.cjs"; import { lint } from "markdownlint/promise"; import { forEachInlineCodeSpan } from "../lib/markdownit.cjs"; import { getReferenceLinkImageData } from "../lib/cache.mjs"; test("clearHtmlCommentTextValid", (t) => { t.plan(1); const validComments = [ "", "", "", "", " ", " ", "", "", "", "", "", "", "", "", "", "", "", "", "", "texttext", "texttext", "texttext", "", "texttexttext", "texttext", "", "", "", "", " ", " ", "", "", "", "", "", "", "", "", "", "", "", "", "", "texttext", "texttext", "texttext", "", "texttexttext", "texttext", "", "", " -->", "text-->", "text-->", "", "-->", "t-->", "-->", "t-->", "t-->", " " ]; const actual = helpers.clearHtmlCommentText(invalidComments.join("\n")); const expected = invalidComments.join("\n"); t.is(actual, expected); }); test("clearHtmlCommentTextNonGreedy", (t) => { t.plan(1); const nonGreedyComments = [ " -->", " -->", " -->", " -->" ]; const nonGreedyResult = [ " -->", " -->", " -->", " -->" ]; const actual = helpers.clearHtmlCommentText(nonGreedyComments.join("\n")); const expected = nonGreedyResult.join("\n"); t.is(actual, expected); }); test("clearHtmlCommentTextEmbedded", (t) => { t.plan(1); const embeddedComments = [ "texttext", "", "texttext", "texttext", "texttext" ]; const embeddedResult = [ "texttext", "", "texttext", "texttext", "texttext" ]; const actual = helpers.clearHtmlCommentText(embeddedComments.join("\n")); const expected = embeddedResult.join("\n"); t.is(actual, expected); }); test("isBlankLine", (t) => { t.plan(33); // @ts-ignore t.true(helpers.isBlankLine(null), "[null]"); const blankLines = [ "", " ", " ", "\t\t\t", "\r", "\n", "\t\r\n", " ", "", "", "\t", ">", "> ", "> > > \t", "> ", ">>", " ", "-->", "text --> --> text", "text ", "text text", "text --> text --> text " } }); t.deepEqual( formatLintResults(lintResults), [ "content:1:3 error MD019/no-multiple-space-atx Multiple spaces after hash on atx style heading [Context: \"# Heading\"]", "content:1 error MD022/blanks-around-headings Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: \"# Heading\"]", "content:2:1 warning MD033/no-inline-html Inline HTML [Element: br]", "content:2:64 error MD047/single-trailing-newline Files should end with a single newline character" ] ); });