Files
Rūdolfs Ošiņš c7387ac540 Keep asterisks between spaces in comment previews
"2 * 3 * 4" read as emphasis and lost its asterisks. Markdown doesn't
treat a marker with a space just inside it as emphasis.
2026-10-01 18:20:24 +02:00

32 lines
893 B
TypeScript

import { expect, test } from "vitest";
import { plainText } from "@app/lib/markdownPlain";
test.each([
["[the docs](https://example.com)", "the docs"],
["![diagram](a.png) here", "diagram here"],
["run `npm test` now", "run npm test now"],
["~~old~~ new", "old new"],
["**bold** and _italic_", "bold and italic"],
["__strong__ and *em*", "strong and em"],
["# Heading", "Heading"],
["### Deep heading", "Deep heading"],
["> quoted\n> text", "quoted text"],
["- one\n* two\n+ three\n1. four", "one two three four"],
["line one\n\n line two", "line one line two"],
[" padded ", "padded"],
])("%j reads as %j", (markdown, expected) => {
expect(plainText(markdown)).toBe(expected);
});
test.each([
"snake_case_name",
"MAX_SIZE",
"_private",
"see _foo_bar",
"a*b*c",
"2 * 3 * 4",
])("leaves %j alone", text => {
expect(plainText(text)).toBe(text);
});