import { describe, it, expect } from "vitest"; import { trimIndentation } from "../../../spec/support/utils.js"; import markdownService from "./markdown.js"; describe("markdown", () => { it("rewrites language of known language tags", () => { const conversionTable = { "nginx": "language-text-x-nginx-conf", "diff": "language-text-x-diff", "javascript": "language-application-javascript-env-backend", "css": "language-text-css", "mips": "language-text-x-asm-mips" }; for (const [ input, output ] of Object.entries(conversionTable)) { const result = markdownService.renderToHtml(trimIndentation`\ \`\`\`${input} Hi \`\`\` `, "title"); expect(result).toBe(trimIndentation`\
Hi
`);
}
});
it("rewrites language of unknown language tags", () => {
const result = markdownService.renderToHtml(trimIndentation`\
\`\`\`unknownlanguage
Hi
\`\`\`
`, "title");
expect(result).toBe(trimIndentation`\
Hi
`);
});
it("converts h1 heading", () => {
const result = markdownService.renderToHtml(trimIndentation`\
# Hello
## world
# another one
Hello, world
`, "title");
expect(result).toBe(trimIndentation`\
Hello, world
`); }); it("parses duplicate title with escape correctly", () => { const result = markdownService.renderToHtml(trimIndentation`\ # What's new Hi there `, "What's new") expect(result).toBe(`\nHi there
\n`); }); });