refactor: remove as= override and render data-spark at runtime
- Drop resolveBlockAs and the as= attribute; scanDoc now switches directly on role and warns on unknown roles instead of silently stripping - md-table derives data-spark from its loaded CSV via parseSparkTableCsv; delete injectSparkDirectives and the second registry pass so pathIndex is exactly scanDoc output - Align spark-table dice header regex with isSparkTableHeader
This commit is contained in:
@@ -28,7 +28,7 @@ jest.mock("github-slugger", () => {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
import { parseDeclareCsv } from "./declare-parser";
|
||||
import { parseBlockAttrs, resolveBlockAs } from "./block-scanner";
|
||||
import { parseBlockAttrs } from "./block-scanner";
|
||||
import { evaluateExpression, exprValueToString } from "../../components/journal/variable-expression";
|
||||
import {
|
||||
initReactivity,
|
||||
@@ -220,10 +220,9 @@ describe("parseBlockAttrs", () => {
|
||||
// parseBlockAttrs receives the info string AFTER the lang.
|
||||
// The lang is extracted from the fenced block regex capture group
|
||||
// and applied separately in content-registry.
|
||||
const attrs = parseBlockAttrs("id=stats role=declare as=none");
|
||||
const attrs = parseBlockAttrs("id=stats role=declare");
|
||||
expect(attrs.id).toBe("stats");
|
||||
expect(attrs.role).toBe("declare");
|
||||
expect(attrs.as).toBe("none");
|
||||
});
|
||||
|
||||
test("parses quoted values", () => {
|
||||
@@ -242,7 +241,6 @@ describe("parseBlockAttrs", () => {
|
||||
expect(attrs.lang).toBe("");
|
||||
expect(attrs.id).toBeUndefined();
|
||||
expect(attrs.role).toBeUndefined();
|
||||
expect(attrs.as).toBeUndefined();
|
||||
});
|
||||
|
||||
test("handles empty info string (lang extracted separately)", () => {
|
||||
@@ -252,28 +250,8 @@ describe("parseBlockAttrs", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveBlockAs", () => {
|
||||
test("returns explicit as value", () => {
|
||||
expect(resolveBlockAs("declare", "codeblock")).toBe("codeblock");
|
||||
});
|
||||
|
||||
test("defaults to none when role is set", () => {
|
||||
expect(resolveBlockAs("declare", undefined)).toBe("none");
|
||||
expect(resolveBlockAs("file", undefined)).toBe("none");
|
||||
});
|
||||
|
||||
test("defaults to md-table for spark-table role", () => {
|
||||
expect(resolveBlockAs("spark-table", undefined)).toBe("md-table");
|
||||
});
|
||||
|
||||
test("defaults to codeblock for tag role", () => {
|
||||
expect(resolveBlockAs("tag", undefined)).toBe("codeblock");
|
||||
});
|
||||
|
||||
test("defaults to codeblock when no role and no as", () => {
|
||||
expect(resolveBlockAs(undefined, undefined)).toBe("codeblock");
|
||||
});
|
||||
});
|
||||
// Role behavior is covered by the scanDoc tests in
|
||||
// src/cli/content-registry.test.ts.
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// variable-expression
|
||||
|
||||
Reference in New Issue
Block a user