Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions docs/assets/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -7202,8 +7202,7 @@ body[data-active-view="ask"] section[data-view="ask"] {
.check-run:hover { filter: brightness(1.08); }
.check-toggle { margin-left: auto; }
.check-output { border-top: 1px solid var(--rule); padding-top: 16px; }
.check-summary { font-size: 16px; margin: 0 0 10px; }
.check-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.check-summary { font-size: 16px; margin: 0 0 14px; }
.ck-pill {
display: inline-block; font-family: var(--mono); font-size: 10px; letter-spacing: 0.05em;
padding: 2px 8px; border-radius: 999px; border: 1px solid var(--rule); background: var(--paper-2); color: var(--ink-2);
Expand Down Expand Up @@ -7243,8 +7242,28 @@ mark.ck ins { color: var(--status-good, #2f6b3a); text-decoration: none; font-st
.ck-raw .dim { font-size: 12px; }
.ck-resolved { margin-top: 6px; font-size: 13px; color: var(--ink-2); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ck-resolved .badge { margin-right: 2px; }
.ck-copy-cite { font: inherit; font-size: 12px; background: none; border: 1px solid var(--rule); border-radius: 2px; padding: 1px 8px; color: var(--garnet); cursor: pointer; }
.ck-copy-cite:hover { background: var(--garnet); color: var(--paper); border-color: var(--garnet); }
/* Row actions: the same three, in the same place, on every resolved row. */
.ck-actions { margin-left: auto; display: inline-flex; gap: 6px; flex-wrap: wrap; }
.ck-act {
font: inherit; font-size: 12px; line-height: 1.5; background: none; border: 1px solid var(--rule); border-radius: 2px;
padding: 1px 8px; color: var(--garnet); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.ck-act:hover, .ck-act:focus-visible { background: var(--garnet); color: var(--paper); border-color: var(--garnet); }
.ck-cand { white-space: nowrap; }
.ck-cand-src { margin-left: 3px; font-size: 11px; color: var(--ink-3, var(--ink-2)); text-decoration: none; }
.ck-cand-src:hover { color: var(--garnet); }
/* Status counts = legend + filter. */
.ck-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ck-filter { font: inherit; font-size: 13px; cursor: pointer; background: none; border: 1px solid var(--rule); border-radius: 999px; padding: 2px 10px; color: var(--ink-2); }
.ck-filter.ck-pill { font-size: 12px; }
.ck-filter.is-on { box-shadow: 0 0 0 2px var(--ink-2) inset; }
.ck-filter:hover { border-color: var(--ink-2); }
.ck-quotes-line { margin: 8px 0 0; font-size: 14px; color: var(--ink-2); }
.ck-more { margin: 6px 0 0; font-size: 12px; color: var(--ink-3, var(--ink-2)); }
.ck-more > summary { cursor: pointer; }
.ck-note-ok .ck-para-summary { color: inherit; }
.ck-notes-more { margin: 4px 0 0; padding-left: 18px; }
@media (max-width: 600px) { .ck-actions { margin-left: 0; width: 100%; } }
.ck-notes { margin: 8px 0 0; padding-left: 18px; font-size: 13px; color: var(--ink-2); }
.ck-note { margin: 3px 0; }
.ck-note-bad { color: var(--status-bad, #8b1e2b); }
Expand Down
96 changes: 72 additions & 24 deletions docs/assets/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5162,7 +5162,7 @@ function checkParaBlock(it) {
const shown = paras.slice(0, CHECK_PARA_CAP);
const url = checkOpenUrl(it);
return `<details class="ck-para">
<summary class="ck-para-summary"><span class="ck-para-caret" aria-hidden="true">▸</span><span class="ck-para-label">Show ${label}</span> <span class="dim">of ${escape(it.doc.signature || formatDocHeadline(it.doc))}</span></summary>
<summary class="ck-para-summary" title="Show the text of ${label}"><span class="ck-para-caret" aria-hidden="true">▸</span>${escape(String(it.pinResult.text).replace(/\.$/, ''))} <span class="ck-para-label">· show text</span></summary>
<div class="ck-para-body serif">
${shown.map(p => {
const n = String(checkParaNumber(p.n) || p.n || '');
Expand All @@ -5175,53 +5175,91 @@ function checkParaBlock(it) {
</div>
</details>`;
}
// One row per citation, Hick's-law layout: the verdict and three fixed actions
// (UNHRDB reader, official UN source, cite) on the first line; the resolved
// document on the second; then only what explains the verdict. Notes on how a
// citation was resolved fold away; a quotation identical to the source shows no diff.
function checkActions(it, i) {
const doc = it.doc;
if (!doc) return '';
const url = checkOpenUrl(it);
const src = officialSourceUrl(doc);
return `<span class="ck-actions">${
url ? `<a class="ck-act" href="${escape(url)}" title="Open ${it.pinResult?.ok ? 'the cited paragraph' : 'the document'} in the UNHRDB reader">Reader</a>` : ''}${
src ? `<a class="ck-act" href="${escape(src)}" target="_blank" rel="noopener" title="Open the official UN document (${escape(doc.signature || 'UN Documents')})">UN source ↗</a>` : ''}${
doc.type !== 'rec' ? `<button type="button" class="ck-act ck-copy-cite" data-ck-cite="${i}" title="Copy the citation in your default format">” Cite</button>` : ''}</span>`;
}
function checkCandidateLinks(ids) {
return ids.slice(0, 6).map(id => {
const d = state.documents.get(id);
if (!d) return escape(id);
const src = officialSourceUrl(d);
return `<span class="ck-cand"><a class="about-link" href="${escape(documentPermalink(d)?.toString() || '#')}" title="${escape(formatDocHeadline(d))} — open in the reader">${escape(d.signature || id)}</a>${
src ? `<a class="ck-cand-src" href="${escape(src)}" target="_blank" rel="noopener" title="Official UN document">↗</a>` : ''}</span>`;
}).join(' · ') + (ids.length > 6 ? ` · +${ids.length - 6}` : '');
}
function checkRenderRows(items) {
return items.map((it, i) => {
const doc = it.doc;
const url = checkOpenUrl(it);
const resolved = doc
? `<div class="ck-resolved">${sourceBadge(doc.type)} <span class="ck-doc">${escape(formatDocHeadline(doc))}</span> · <span class="mono">${escape(doc.signature || '')}</span>${url ? ` · <a class="about-link" href="${escape(url)}">Open ↗</a>` : ''}${doc.type !== 'rec' ? ` · <button type="button" class="ck-copy-cite" data-ck-cite="${i}" title="Copy the citation in your default format">” Cite</button>` : ''}</div>`
? `<div class="ck-resolved">${sourceBadge(doc.type)} <span class="ck-doc">${escape(formatDocHeadline(doc))}</span> · <span class="mono">${escape(doc.signature || '')}</span></div>`
: it.candidates.length
? `<div class="ck-resolved"><span class="dim">Candidates:</span> ${it.candidates.slice(0, 6).map(id => { const d = state.documents.get(id); return d ? `<a class="about-link" href="${escape(documentPermalink(d)?.toString() || '#')}">${escape(d.signature || id)}</a>` : escape(id); }).join(' · ')}${it.candidates.length > 6 ? ` · +${it.candidates.length - 6}` : ''}</div>`
? `<div class="ck-resolved"><span class="dim">Candidates:</span> ${checkCandidateLinks(it.candidates)}</div>`
: (it.mention.kind === 'symbol' ? `<div class="ck-resolved"><a class="about-link" href="${escape(unDocsUrl(it.mention.raw) || '#')}" target="_blank" rel="noopener">Look up ${escape(it.mention.norm)} on UN Documents ↗</a></div>` : '');
const notes = [
...(it.pinResult ? [`<li class="ck-note ck-note-${it.pinResult.ok ? 'ok' : 'bad'}">${escape(it.pinResult.text)}${checkParaBlock(it)}</li>`] : (it.pin && doc ? ['<li class="ck-note dim">Pinpoint not checked.</li>'] : [])),
...it.notes.map(n => `<li class="ck-note">${escape(n)}</li>`),
const main = [
...(it.pinResult ? [`<li class="ck-note ck-note-${it.pinResult.ok ? 'ok' : 'bad'}">${checkParaBlock(it) || escape(it.pinResult.text)}</li>`] : (it.pin && doc ? ['<li class="ck-note dim">Pinpoint not checked.</li>'] : [])),
...it.quotes.map(q => q.result
? `<li class="ck-note ck-note-${q.result.status}">Quotation ${q.result.where ? `(${escape(q.result.where)}) ` : ''}${escape(q.result.text)}.<div class="ck-diff serif">${q.result.html}</div></li>`
? `<li class="ck-note ck-note-${q.result.status}">Quotation ${q.result.where ? `(${escape(q.result.where)}) ` : ''}${escape(q.result.text)}.${/<(del|ins)\b/.test(q.result.html || '') ? `<div class="ck-diff serif">${q.result.html}</div>` : ''}</li>`
: '<li class="ck-note dim">Quotation not checked.</li>'),
];
return `<li class="ck-row ck-${it.status}" id="ck-row-${i}" data-ck-row="${i}">
// How a citation was resolved ("Resolved as …") is background; a problem note is not,
// so on a row that is not ok the problem stays in view and only the background folds.
const isHow = (n) => it.status === 'ok' || /^Resolved as /.test(n);
main.push(...it.notes.filter(n => !isHow(n)).map(n => `<li class="ck-note">${escape(n)}</li>`));
const extra = it.notes.filter(isHow).map(n => `<li class="ck-note">${escape(n)}</li>`);
const more = extra.length
? `<details class="ck-more"><summary>How it was resolved</summary><ul class="ck-notes-more">${extra.join('')}</ul></details>` : '';
return `<li class="ck-row ck-${it.status}" id="ck-row-${i}" data-ck-row="${i}" data-ck-status="${it.status}">
<div class="ck-row-head">
<span class="mono ck-num">№ ${String(i + 1).padStart(2, '0')}</span>
<span class="ck-pill ck-${it.status}" title="${escape(CHECK_STATUS_TITLE[it.status])}">${CHECK_STATUS_LABEL[it.status]}</span>
<span class="ck-raw serif">${escape(it.mention.raw)}${it.pin ? ` <span class="dim">para. ${escape(it.pin.from)}${it.pin.to ? `–${escape(it.pin.to)}` : ''}</span>` : ''}</span>
${checkActions(it, i)}
</div>
${resolved}
${notes.length ? `<ul class="ck-notes">${notes.join('')}</ul>` : ''}
${main.length ? `<ul class="ck-notes">${main.join('')}</ul>` : ''}
${more}
</li>`;
}).join('');
}
// Problems first; zero counts are left out, so the chips are also the legend.
const CHECK_FILTER_ORDER = ['bad', 'warn', 'ambiguous', 'outside', 'ok'];
function checkSummary(items, quoteList) {
const c = { ok: 0, warn: 0, bad: 0, ambiguous: 0, outside: 0 };
const c = {};
for (const it of items) c[it.status] = (c[it.status] || 0) + 1;
const parts = [`<strong>${items.length}</strong> citation${items.length === 1 ? '' : 's'}`];
const bits = [];
if (c.ok) bits.push(`${c.ok} found`);
if (c.warn) bits.push(`${c.warn} to check`);
if (c.bad) bits.push(`<strong>${c.bad} not found</strong>`);
if (c.ambiguous) bits.push(`${c.ambiguous} ambiguous`);
if (c.outside) bits.push(`${c.outside} outside this database`);
if (bits.length) parts.push(bits.join(' · '));
const words = { ok: 'found', warn: 'to check', bad: 'not found', ambiguous: 'ambiguous', outside: 'outside this database' };
const filter = state.check.filter || '';
const chips = [`<button type="button" class="ck-filter${filter ? '' : ' is-on'}" data-ck-filter="" aria-pressed="${!filter}"><strong>${items.length}</strong> citation${items.length === 1 ? '' : 's'}</button>`];
for (const st of CHECK_FILTER_ORDER) {
if (!c[st]) continue;
chips.push(`<button type="button" class="ck-filter ck-pill ck-${st}${filter === st ? ' is-on' : ''}" data-ck-filter="${st}" aria-pressed="${filter === st}" title="${escape(CHECK_STATUS_TITLE[st])} Click to show only these.">${CHECK_STATUS_LABEL[st].split(' ')[0]} ${c[st]} ${words[st]}</button>`);
}
const lines = [`<div class="ck-filters" role="group" aria-label="Show citations by status">${chips.join('')}</div>`];
const qs = quoteList.filter(q => q.owner);
if (qs.length) {
const orphan = quoteList.filter(q => !q.owner).length;
if (qs.length || orphan) {
const q = { ok: 0, warn: 0, bad: 0 };
for (const x of qs) if (x.result) q[x.result.status]++;
parts.push(`<strong>${qs.length}</strong> quotation${qs.length === 1 ? '' : 's'}: ${q.ok} verbatim or near-verbatim · ${q.warn} differ · ${q.bad} not found`);
const qbits = [];
if (qs.length) qbits.push(`<strong>${qs.length}</strong> quotation${qs.length === 1 ? '' : 's'}: ${[q.ok && `${q.ok} verbatim or near-verbatim`, q.warn && `${q.warn} differ`, q.bad && `${q.bad} not found`].filter(Boolean).join(' · ') || 'not checked'}`);
if (orphan) qbits.push(`${orphan} without a nearby resolvable citation`);
lines.push(`<p class="ck-quotes-line">${qbits.join(' — ')}</p>`);
}
const orphan = quoteList.filter(q => !q.owner).length;
if (orphan) parts.push(`${orphan} quotation${orphan === 1 ? '' : 's'} without a nearby resolvable citation`);
return parts.join(' — ');
return lines.join('');
}
function applyCheckFilter() {
const f = state.check.filter || '';
for (const row of document.querySelectorAll('#check-list .ck-row')) row.hidden = !!f && row.dataset.ckStatus !== f;
}
function checkReportMarkdown(items, quoteList) {
const lines = ['| # | As written | Status | Resolved to | Notes |', '|---|---|---|---|---|'];
Expand Down Expand Up @@ -5273,6 +5311,15 @@ function paintCheckView() {
catch { showFeedbackToast({ ok: false, _msg: 'Clipboard write failed', _mark: '⚠' }); }
return;
}
const chip = e.target.closest('[data-ck-filter]');
if (chip) {
const f = chip.dataset.ckFilter;
state.check.filter = state.check.filter === f ? '' : f;
const last = state.check.last;
if (last) $('#check-summary').innerHTML = checkSummary(last.items, last.quotes);
applyCheckFilter();
return;
}
const scopeLink = e.target.closest('a[data-check-scope]');
if (scopeLink) {
e.preventDefault();
Expand All @@ -5287,6 +5334,7 @@ async function runCitationCheck() {
const out = $('#check-output'), status = $('#check-status'), summary = $('#check-summary'), ann = $('#check-annotated'), list = $('#check-list');
if (!out || !summary || !ann || !list) return;
const run = ++state.check.run;
state.check.filter = '';
if (!text.trim()) { if (status) status.textContent = 'Paste some text first.'; return; }
if (status) status.textContent = 'Resolving citations…';
const found = checkDetect(text);
Expand Down
18 changes: 18 additions & 0 deletions docs/assets/i18n-es.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,28 @@ export default {
'Try again in a minute, or use': 'Inténtelo de nuevo dentro de un minuto o use',
'in the meantime.': 'mientras tanto.',
'Ask is not configured for this deploy.': 'La función Preguntar no está configurada en esta instalación.',

// ── Check: actions and status filter ──
'Reader': 'Lector',
'UN source ↗': 'Fuente ONU ↗',
'How it was resolved': 'Cómo se resolvió',
'· show text': '· ver texto',
'citations': 'citas',
'citation': 'cita',
'Show citations by status': 'Mostrar las citas por estado',
'Official UN document': 'Documento oficial de la ONU',
'Open the cited paragraph in the UNHRDB reader': 'Abrir el párrafo citado en el lector de UNHRDB',
'Open the document in the UNHRDB reader': 'Abrir el documento en el lector de UNHRDB',
'Copy the citation in your default format': 'Copiar la cita en su formato predeterminado',
},

// Strings with numbers or a query: [RegExp, replacement]. Tried when the exact table misses.
patterns: [
[/^(✓|⚠|✖|\?|○) (\d+) (found|to check|not found|ambiguous|outside this database)$/, (m, mark, n, w) =>
`${mark} ${n} ${({ found: 'encontradas', 'to check': 'por comprobar', 'not found': 'no encontradas', ambiguous: 'ambiguas', 'outside this database': 'fuera de esta base' })[w]}`],
[/^Paragraph (\S+) exists$/, 'El párrafo $1 existe'],
[/^Paragraphs (\S+) exist$/, 'Los párrafos $1 existen'],
[/^Open the official UN document \((.+)\)$/, 'Abrir el documento oficial de la ONU ($1)'],
[/^Adopted (\d{1,2}) (\w+) (\d{4})$/, (m, d, mo, y) => `Aprobada el ${d} de ${ES_MONTH[mo] || mo} de ${y}`],
[/^Decision adopted (\d{1,2}) (\w+) (\d{4})$/, (m, d, mo, y) => `Decisión adoptada el ${d} de ${ES_MONTH[mo] || mo} de ${y}`],
[/^Issued (\d{1,2}) (\w+) (\d{4})$/, (m, d, mo, y) => `Publicado el ${d} de ${ES_MONTH[mo] || mo} de ${y}`],
Expand Down
13 changes: 3 additions & 10 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@
}
</script>

<link rel="stylesheet" href="assets/tokens.css?v=20261107-opscaps" />
<link rel="stylesheet" href="assets/app.css?v=20261107-opscaps" />
<link rel="stylesheet" href="assets/tokens.css?v=20261108-8c652d8" />
<link rel="stylesheet" href="assets/app.css?v=20261108-8c652d8" />

<!-- Google Analytics 4 is loaded LAZILY, only after the visitor opts in
via the consent banner — see initConsent()/loadAnalytics() in app.js.
Expand Down Expand Up @@ -961,13 +961,6 @@ <h2 class="serif check-title">Check the UN citations in your text</h2>
</div>
<div class="check-output" id="check-output" hidden>
<div class="check-summary serif" id="check-summary"></div>
<div class="check-legend folio">
<span class="ck-pill ck-ok">✓ found</span>
<span class="ck-pill ck-warn">⚠ check</span>
<span class="ck-pill ck-bad">✖ not found</span>
<span class="ck-pill ck-ambiguous">? ambiguous</span>
<span class="ck-pill ck-outside">○ outside this database</span>
</div>
<div class="check-annotated serif" id="check-annotated" aria-label="Your text with the detected citations highlighted"></div>
<ol class="check-list" id="check-list"></ol>
<div class="check-actions">
Expand Down Expand Up @@ -1789,7 +1782,7 @@ <h3 id="report-modal-title" class="report-modal-title">What did you spot?</h3>
<div class="diff-tray" id="diff-tray" hidden></div>
<div class="diff-modal" id="diff-modal" hidden></div>

<script type="module" src="assets/app.js?v=20261107-opscaps"></script>
<script type="module" src="assets/app.js?v=20261108-8c652d8"></script>
<script src="assets/who.js?v=20261013" data-tool="unhrdb" data-endpoint="https://lszoszk.goatcounter.com/count" defer></script>
<script src="assets/service-notice.js?v=20261022" charset="utf-8" data-app="UNHRDB"
data-effect="Until access is restored, the parts of this site that depend on the server, such as search, are unavailable."
Expand Down
14 changes: 13 additions & 1 deletion tests/citation-check.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,16 @@ test('C2. sampleStatuses · the sample text exercises every verdict', async ({ p
await expect(gc36.locator('.ck-note-ok').first()).toContainText('Paragraph 3 exists');
await expect(gc36.locator('.ck-note-ok').nth(1)).toContainText('verbatim');
await expect(gc36.locator('.ck-resolved')).toContainText('CCPR/C/GC/36');
// Three fixed actions: the UNHRDB reader, the official UN document, cite.
await expect(gc36.locator('.ck-act', { hasText: 'Reader' })).toHaveAttribute('href', /p=ccpr-c-gc-36-\d+/);
const src36 = gc36.locator('.ck-act', { hasText: 'UN source' });
await expect(src36).toHaveAttribute('href', /un\.org/);
await expect(src36).toHaveAttribute('target', '_blank');
await expect(gc36.locator('.ck-copy-cite')).toBeVisible();
// The cited paragraph is one click away: collapsed by default, its text and a reader link inside.
const para36 = gc36.locator('details.ck-para');
await expect(para36).toHaveCount(1);
await expect(para36.locator('.ck-para-summary')).toContainText('Show paragraph 3');
await expect(para36.locator('.ck-para-summary')).toContainText('Paragraph 3 exists · show text');
await expect(para36.locator('.ck-para-body')).toBeHidden();
await para36.locator('.ck-para-summary').click();
await expect(para36.locator('.ck-para-body')).toBeVisible();
Expand Down Expand Up @@ -84,6 +90,12 @@ test('C2. sampleStatuses · the sample text exercises every verdict', async ({ p
await expect(page.locator('#check-annotated mark.ck-bad', { hasText: 'CRC/C/GC/99' })).toBeVisible();
await expect(page.locator('#check-annotated mark.ck-cite.ck-ok', { hasText: 'CCPR/C/GC/36' })).toBeVisible();
await expect(page.locator('#check-summary')).toContainText('not found');
// The status counts filter the list; a second click shows everything again.
const total = await page.locator('.ck-row').count();
await page.locator('[data-ck-filter="bad"]').click();
await expect(page.locator('.ck-row:visible')).toHaveCount(await page.locator('.ck-row.ck-bad').count());
await page.locator('[data-ck-filter="bad"]').click();
await expect(page.locator('.ck-row:visible')).toHaveCount(total);
});

test('C3. misquoteRedline · a changed word is struck through and the source word shown', async ({ page }) => {
Expand Down
Loading