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>
This commit is contained in:
ar.badiei
2026-07-12 01:55:50 +03:30
co-authored by Cursor
parent a47ec493c5
commit 6cb9e2aac5
11 changed files with 370 additions and 64 deletions
+24
View File
@@ -0,0 +1,24 @@
import { detectBlockquoteVariant } from "../lib/blockquote-variant";
import { BLOCKQUOTE_VARIANT_FIXTURES } from "../lib/blockquote-variant.fixtures";
const VARIANT_LABEL = {
yellow: "زرد (هشدار)",
green: "سبز (ارزشمند)",
gray: "طوسی (خنثی)",
} as const;
let passed = 0;
for (const [index, fixture] of BLOCKQUOTE_VARIANT_FIXTURES.entries()) {
const detected = detectBlockquoteVariant(fixture.content, fixture.citation);
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}/${BLOCKQUOTE_VARIANT_FIXTURES.length} درست`);
process.exit(passed === BLOCKQUOTE_VARIANT_FIXTURES.length ? 0 : 1);
+58
View File
@@ -0,0 +1,58 @@
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);