Projekt-Notizen: Markdown-Tabellen; sw v144
Some checks failed
Build and push Docker image / build (push) Successful in 14s
Test / test (push) Successful in 10m17s
Test / e2e (push) Failing after 1m21s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mrwnslz 2026-10-19 20:28:27 +02:00
parent 66dc7a48fd
commit a329eab091
3 changed files with 19 additions and 3 deletions

View file

@ -123,11 +123,12 @@ test('Projekte: a Forschung project, a paper by DOI, a linked book, a note citin
await tab.locator('[data-view="notes"]').click();
await tab.locator('[data-act="new-note"]').click();
await tab.locator('[data-note-title]').fill('These');
await tab.locator('[data-note-body]').fill('# Idee\nIdeologie zeigt sich im Gehirn [@amodio2007neural, S. 3] und bei [@muster0jdas].');
await tab.locator('[data-note-body]').fill('# Idee\nIdeologie zeigt sich im Gehirn [@amodio2007neural, S. 3] und bei [@muster0jdas].\n\n| Text | Zeit |\n|---|---|\n| Cobb | 2,5 h |\nDanach.');
await expect(tab.locator('.prj-saved')).toHaveText('gespeichert', {timeout: 5000});
await tab.locator('[data-act="preview"]').click();
await expect(tab.locator('.prj-md .prj-cite').first()).toHaveText('(Amodio & Jost 2007, S. 3)');
await expect(tab.locator('.prj-refs li').first()).toContainText('Nature Neuroscience');
await expect(tab.locator('.prj-md td')).toHaveText(['Cobb', '2,5 h']);
await tab.locator('[data-view="sources"]').click();
const [dl] = await Promise.all([page.waitForEvent('download'), tab.locator('[data-export="bib"]').click()]);

View file

@ -274,8 +274,13 @@
function markdown(text, cite) {
const lines = String(text || '').replace(/\r/g, '').split('\n');
let out = '', list = null, para = [], quote = [];
let out = '', list = null, para = [], quote = [], table = null;
const flush = () => {
if (table) {
out += '<div class="prj-table"><table>' + table.map((row, n) => '<tr>' + row.map(c =>
(n ? '<td>' : '<th>') + inline(c, cite) + (n ? '</td>' : '</th>')).join('') + '</tr>').join('') + '</table></div>';
table = null;
}
if (para.length) { out += '<p>' + inline(para.join(' '), cite) + '</p>'; para = []; }
if (quote.length) { out += '<blockquote>' + inline(quote.join(' '), cite) + '</blockquote>'; quote = []; }
if (list) { out += '</' + list + '>'; list = null; }
@ -284,6 +289,13 @@
const line = raw.replace(/\s+$/, '');
let m;
if (!line.trim()) { flush(); continue; }
// A table: | a | b |, under its head a | --- | --- | line.
if (/^\s*\|.*\|$/.test(line)) {
if (!table) { flush(); table = []; }
if (!/^\s*\|[\s:|-]+\|$/.test(line)) table.push(line.trim().replace(/^\||\|$/g, '').split('|').map(c => c.trim()));
continue;
}
if (table) flush();
if ((m = /^(#{1,4})\s+(.*)$/.exec(line))) { flush(); out += '<h' + (m[1].length + 2) + '>' + inline(m[2], cite) + '</h' + (m[1].length + 2) + '>'; continue; }
if ((m = /^\s*[-*+]\s+(?:\[( |x)\]\s+)?(.*)$/i.exec(line))) {
if (para.length || quote.length || list !== 'ul') { flush(); out += '<ul>'; list = 'ul'; }
@ -1155,6 +1167,9 @@
'#tab-projekte .prj-md h3 { font-size: 19px; } #tab-projekte .prj-md h4 { font-size: 16px; } #tab-projekte .prj-md h5, #tab-projekte .prj-md h6 { font-size: 15px; }',
'#tab-projekte .prj-md blockquote { margin: 8px 0; padding-left: 12px; border-left: 3px solid var(--border-strong, #444); color: var(--muted, #9a9a9a); }',
'#tab-projekte .prj-md a { color: var(--accent, #e63946); }',
'#tab-projekte .prj-table { overflow-x: auto; margin: 10px 0; }',
'#tab-projekte .prj-table table { border-collapse: collapse; font-size: 14px; }',
'#tab-projekte .prj-table th, #tab-projekte .prj-table td { border: 1px solid var(--border, #2a2a2a); padding: 6px 8px; text-align: left; vertical-align: top; }',
'#tab-projekte .prj-cite { color: var(--accent, #e63946); cursor: pointer; }',
'#tab-projekte .prj-cite-missing { text-decoration: underline wavy; }',
'#tab-projekte .prj-refs { font-size: 13px; line-height: 1.5; padding-left: 20px; overflow-wrap: anywhere; }',

View file

@ -2,7 +2,7 @@
* diora service worker — caches the app shell for offline use.
*/
const CACHE = 'diora-v143';
const CACHE = 'diora-v144';
const SHELL = [
'/static/css/app.css',
'/static/js/app/01-core.js',