testHighlightPassesAHashWithNoName

tcmts.cli.pages.testHighlightPassesAHashWithNoName · #e32lspme · term

A # with no name after it (JSX text read as code, or code that doesn't parse) is highlighted as itself and the scan goes on: TypeScript's scanner takes no characters for it, which once kept highlight there forever (a forge page that hung its process).

import { highlight } from "#codebase/tcmts/cli/pages";
import assert from "node:assert/strict";

export const testHighlightPassesAHashWithNoName = () => {
  for (const text of ["#", "a # b", "const P = () => <p>#{r.namespace} 😀#</p>;"]) {
    const html = highlight(text, [], new Set());
    const plain = html
      .replace(/<[^>]+>/g, "")
      .replace(/&lt;/g, "<")
      .replace(/&gt;/g, ">")
      .replace(/&quot;/g, '"')
      .replace(/&#39;/g, "'")
      .replace(/&amp;/g, "&");
    assert.equal(plain, text);
  }
}

uses