Files
aragrp/scripts/table-variant-demo.ts
ar.badieiandCursor 6cb9e2aac5 feat: auto-detect blockquote and table colors from content
Replace manual hashtags and color cycling with content-tone heuristics for blockquotes and tables, and refine blockquote layout with a centered icon, larger sizing, and clearer contrast over background decorations.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-12 01:55:50 +03:30

59 lines
1.7 KiB
TypeScript

import { detectTableVariant } from "../lib/table-content";
const VARIANT_LABEL = {
one: "سبز (one)",
two: "زرد (two)",
} as const;
const FIXTURES = [
{
label: "جدول مزایا (سبز)",
input: {
headers: ["<p>ویژگی</p>", "<p>توضیح</p>"],
rows: [
["<p>سرعت</p>", "<p>اجرای سریع فرآیند</p>"],
["<p>انعطاف</p>", "<p>قابلیت سفارشی‌سازی</p>"],
],
},
expected: "one" as const,
},
{
label: "جدول معایب و محدودیت (زرد)",
input: {
headers: ["<p>محدودیت</p>", "<p>توضیح</p>"],
rows: [
["<p>هزینه</p>", "<p>افزایش هزینه نگهداری</p>"],
["<p>پیچیدگی</p>", "<p>نیاز به آموزش تیم</p>"],
],
},
expected: "two" as const,
},
{
label: "جدول مقایسه خنثی (سبز)",
input: {
headers: ["<p>گزینه</p>", "<p>کاربرد</p>"],
rows: [
["<p>Workflow</p>", "<p>مسیر ثابت</p>"],
["<p>Agent</p>", "<p>تصمیم‌گیری</p>"],
],
},
expected: "one" as const,
},
];
let passed = 0;
for (const [index, fixture] of FIXTURES.entries()) {
const detected = detectTableVariant(fixture.input);
const ok = detected === fixture.expected;
if (ok) passed += 1;
console.log(`--- ${index + 1}. ${fixture.label}`);
console.log(`انتظار: ${VARIANT_LABEL[fixture.expected]}`);
console.log(`تشخیص: ${VARIANT_LABEL[detected]} ${ok ? "OK" : "FAIL"}`);
console.log("");
}
console.log(`نتیجه: ${passed}/${FIXTURES.length} درست`);
process.exit(passed === FIXTURES.length ? 0 : 1);