mirror of
https://github.com/morluto/rea.git
synced 2026-10-26 17:35:11 +00:00
fix(cli): preserve literal HTML text in Markdown tables (#6932)
This commit is contained in:
1 parent
c298d54e88
commit
2c3568c375
3 files changed
+20
-1
No files matched your search
@@ -44,6 +44,9 @@ const isObjectArray = (value: unknown): value is Record<string, unknown>[] =>
|
||||
|
||||
const escapeTableCell = (value: string): string =>
|
||||
value
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/\\/g, "\\\\")
|
||||
.replace(/\|/g, "\\|")
|
||||
.replace(/\r\n|\r|\n/g, "<br>");
|
||||
|
||||
@@ -26,6 +26,14 @@ describe("CLI output argument boundary", () => {
|
||||
expect(JSON.parse(renderCliDocument(value, "json", false))).toEqual(value);
|
||||
});
|
||||
|
||||
it("preserves literal HTML and entity text in Markdown table headers and cells", () => {
|
||||
const value = [{ "List<T>": "© <br>\r\nnext" }];
|
||||
const markdown = renderCliDocument(value, "md", false);
|
||||
expect(markdown).toContain("List<T>");
|
||||
expect(markdown).toContain("&copy; <br><br>next");
|
||||
expect(JSON.parse(renderCliDocument(value, "json", false))).toEqual(value);
|
||||
});
|
||||
|
||||
it("rejects token windows that would corrupt structured output", () => {
|
||||
for (const format of ["json", "jsonl", "yaml"] as const) {
|
||||
const validation = parseCliOutputArguments([
|
||||
|
||||
@@ -237,7 +237,11 @@ cliTest(
|
||||
async ({ cli }) => {
|
||||
const root = await createTestTempDirectory("rea-evidence-markdown-cells-");
|
||||
const path = join(root, "bundle.json");
|
||||
const result = { text: "left|right\\tail\nnext" };
|
||||
const result = {
|
||||
text: "left|right\\tail\nnext",
|
||||
type: "List<string>",
|
||||
literal: "© <br>",
|
||||
};
|
||||
const record = createEvidence(
|
||||
undefined,
|
||||
{ id: "fixture", name: "Fixture", version: "1" },
|
||||
@@ -257,9 +261,13 @@ cliTest(
|
||||
const json = await cli.run({ arguments: [...base, "--json"] });
|
||||
expect(json.exitCode, json.stderr).toBe(0);
|
||||
expect(json.stdout).toContain(JSON.stringify(result.text));
|
||||
expect(json.stdout).toContain(JSON.stringify(result.type));
|
||||
expect(json.stdout).toContain(JSON.stringify(result.literal));
|
||||
const markdown = await cli.run({ arguments: [...base, "--format", "md"] });
|
||||
expect(markdown.exitCode, markdown.stderr).toBe(0);
|
||||
expect(markdown.stdout).toContain("left\\|right\\\\tail<br>next");
|
||||
expect(markdown.stdout).toContain("List<string>");
|
||||
expect(markdown.stdout).toContain("&copy; <br>");
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
Reference in new issue
Block a user