haufen sachen

This commit is contained in:
th committed 2026-04-08 22:46:48 +02:00
1 parent 416ca9e854
commit e6243701a3
20 files changed
+1562 -116

No files matched your search

+43 -2
View File
@@ -13,7 +13,7 @@ marked.use({ breaks: true, gfm: true, renderer: {
const purifyConfig = {
ALLOWED_TAGS: ['h1','h2','h3','h4','h5','h6','p','br','hr','ul','ol','li','a','strong','em','del','code','pre','blockquote','table','thead','tbody','tr','th','td','img','input','span','div','audio','source'],
ALLOWED_ATTR: ['href','src','alt','width','height','type','checked','disabled','class','style','data-card-id','title','controls','preload','target','rel'],
ALLOWED_ATTR: ['href','src','alt','width','height','type','checked','disabled','class','style','data-card-id','title','controls','preload','target','rel','align'],
ALLOW_DATA_ATTR: true,
};
@@ -38,7 +38,48 @@ function normalizeListBlock(block) {
}
export function renderMd(src) {
let processed = String(src || '').replace(/\r\n?/g, '\n')
let processed = String(src || '').replace(/\r\n?/g, '\n');
// Convert Unicode box-drawing tables to HTML
processed = processed.replace(/([ \t]*[┌╔][\s\S]*?[┘╝][ \t]*)/g, (block) => {
const lines = block.split('\n').filter(l => l.trim());
const rows = [];
let currentRow = null;
for (const line of lines) {
const trimmed = line.trim();
// Skip border lines (┌─┬─┐, ├─┼─┤, └─┴─┘, ╔═╦═╗, etc.)
if (/^[┌┐└┘├┤┬┴┼─│╔╗╚╝╠╣╦╩╬═║\s]+$/.test(trimmed)) {
if (currentRow) { rows.push(currentRow); currentRow = null; }
continue;
}
// Data row: │ cell │ cell │ or ║ cell ║
if (/^[│║]/.test(trimmed)) {
const cells = trimmed.split(/[│║]/).slice(1, -1).map(c => c.trim());
if (currentRow && currentRow.length === cells.length) {
// Continuation line — append to previous cells
for (let i = 0; i < cells.length; i++) {
if (cells[i]) currentRow[i] = ((currentRow[i] || '') + ' ' + cells[i]).trim();
}
} else {
if (currentRow) rows.push(currentRow);
currentRow = cells;
}
}
}
if (currentRow) rows.push(currentRow);
if (rows.length < 2) return block;
const header = rows[0];
const body = rows.slice(1);
return '\n<table><thead><tr>' +
header.map(c => `<th>${esc(c)}</th>`).join('') +
'</tr></thead><tbody>' +
body.map(r => '<tr>' + r.map(c => `<td>${esc(c)}</td>`).join('') + '</tr>').join('') +
'</tbody></table>\n';
});
processed = processed
// Gallery fenced block: ```gallery
.replace(/```gallery\s*\n([\s\S]*?)(?:```|$)/g, (_, content) => {
const imgs = [];