import { expect, test } from "vitest"
import {
toInlineSpans,
toLineIndex,
toMarkdownLines,
} from "./markdownSpans.ts"
/**
* The corpus every invariant below runs over. Deliberately nasty:
* the constructs the editor colours, the ones it does not, and the
* characters that tempt an HTML-escaping implementation.
*/
const CORPUS = [
"",
"\n",
"plain text",
"# Heading one",
"###### Heading six with **bold** and `code`",
"#no-space-is-not-a-heading",
" ## indented heading",
"> quoted line",
">> doubly quoted",
"> ## a heading inside a quote",
"- bullet",
"* star bullet",
"+ plus bullet",
"1. ordered",
"12) ordered with a paren",
"- [ ] unchecked task",
"- [x] checked task",
" - nested bullet",
"---",
"***",
"| a | b |",
"| --- | --- |",
"| `code` | **bold** |",
"text with **bold** and _em_ and ~~struck~~ and `code`",
"an  inline",
"a [link](https://example.test/page) inline",
"escaped \\*not emphasis\\* here",
"`**not bold inside code**`",
"unterminated **bold",
"unterminated `code",
"```ts",
"const x = '**not bold**'",
"```",
"5 * 3 * 2 is arithmetic",
"snake_case_identifier stays plain",
"",
"a < b && c > d",
"& < ' "",
"1 < 2 > 3 bold?",
"trailing spaces ",
"\ttab indented",
].join("\n")
/**
* **The invariant the whole component rests on.**
*
* The painted layer sits behind a real `