Ремонт: свести кухню в один файл (диваны/столы/техника), убрать старый Интерьер кухня.md
All checks were successful
Deploy Remont Site / deploy (push) Successful in 17s
All checks were successful
Deploy Remont Site / deploy (push) Successful in 17s
- Гостиная-кухня.md: добавлены обновлённые столы (Ozon, табуреты) и секция «Варианты техники» - генератор: карточки только для таблиц с фото; прочие прайс-таблицы → таблица; URL → компактные ссылки Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -123,6 +123,12 @@ function parseTable(rows) {
|
||||
function tableIsPriced(tbl) {
|
||||
return tbl.headers.some((h) => /цена|price|₽|руб/i.test(h));
|
||||
}
|
||||
function tableHasPhoto(tbl) {
|
||||
return tbl.headers.some((h) => /фото|photo|картин|image/i.test(h))
|
||||
|| tbl.rows.some((r) => r.some((c) => parseWiki(c)));
|
||||
}
|
||||
// карточки — только для «прайс + фото» (диваны, столы); прочие прайс-таблицы (техника) → обычная таблица
|
||||
function tableIsCards(tbl) { return tableIsPriced(tbl) && tableHasPhoto(tbl); }
|
||||
function colIndex(headers, re) { return headers.findIndex((h) => re.test(h)); }
|
||||
|
||||
function renderCards(tbl) {
|
||||
@@ -157,12 +163,18 @@ function renderCards(tbl) {
|
||||
return `<div class="options">${cards}</div>`;
|
||||
}
|
||||
|
||||
function tableCell(c) {
|
||||
const w = parseWiki(c);
|
||||
if (w) return `<img src="${imgSrc(w)}" alt="" loading="lazy">`;
|
||||
if (/^https?:\/\/\S+$/.test(c)) return `<a href="${esc(c)}" target="_blank" rel="noopener" class="tlink">Открыть <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M7 17 17 7M8 7h9v9"/></svg></a>`;
|
||||
return inline(c);
|
||||
}
|
||||
function renderTable(tbl) {
|
||||
const head = tbl.headers.map((h) => `<th>${inline(h)}</th>`).join('');
|
||||
const body = tbl.rows.map((r) =>
|
||||
`<tr>${r.map((c) => `<td>${parseWiki(c) ? `<img src="${imgSrc(parseWiki(c))}" alt="" loading="lazy">` : inline(c)}</td>`).join('')}</tr>`
|
||||
`<tr>${r.map((c) => `<td>${tableCell(c)}</td>`).join('')}</tr>`
|
||||
).join('\n');
|
||||
return `<div class="table-wrap"><table><thead><tr>${head}</tr></thead><tbody>${body}</tbody></table></div>`;
|
||||
return `<div class="table-wrap reveal"><table><thead><tr>${head}</tr></thead><tbody>${body}</tbody></table></div>`;
|
||||
}
|
||||
|
||||
function renderImages(imgs) {
|
||||
@@ -225,7 +237,7 @@ function renderSection(sec) {
|
||||
if (b.t === 'h') {
|
||||
let count = null;
|
||||
if (next) {
|
||||
if (next.t === 'table' && tableIsPriced(next)) count = next.rows.length;
|
||||
if (next.t === 'table' && tableIsCards(next)) count = next.rows.length;
|
||||
else if (next.t === 'list') count = next.items.length;
|
||||
else if (next.t === 'images' && body[i + 2] && body[i + 2].t === 'list') count = body[i + 2].items.length;
|
||||
}
|
||||
@@ -238,7 +250,7 @@ function renderSection(sec) {
|
||||
out.push(renderImages(b.imgs));
|
||||
}
|
||||
} else if (b.t === 'table') {
|
||||
out.push(tableIsPriced(b) ? renderCards(b) : renderTable(b));
|
||||
out.push(tableIsCards(b) ? renderCards(b) : renderTable(b));
|
||||
} else if (b.t === 'list') {
|
||||
out.push(renderVariants(b.items));
|
||||
} else if (b.t === 'quote') {
|
||||
|
||||
Reference in New Issue
Block a user