/* * Markdown in, formatted text out, and back again. * * The notes are Markdown files — that is what the indexer reads, what * `subjectFromHeading` takes a lesson apart with, and what survives this * project. The editor shows them as formatted text anyway, so this module is * the hinge: `markdownToHtml` on the way into the editor, `markdownFromDom` on * the way back out to the file. * * Three properties matter more than completeness, because what passes through * here is the only record of what was said in a lesson: * * - **Round-trip stability.** `fromDom(toHtml(x))` may tidy `x` once — `*a*` * becomes `_a_`, a ragged table lines up — but doing it again must change * nothing. `editor.js` checks exactly that before it opens a note in * formatted mode, and falls back to the Markdown view when it does not hold. * - **Nothing is dropped.** An element this module does not model keeps its * words and loses its tag. A note is better off plain than short. * - **No HTML is trusted.** `markdownToHtml` escapes everything that is not a * construct it produced itself, so a note containing `