Fix broken source links caused by LLM-generated letter suffixes (e.g. 1383a)
The LLM occasionally generates source references with letter suffixes (e.g. [1383a], [1396b]) despite being instructed not to. This caused broken links because the sources array only contained integer nr values. Backend: Add _sanitize_sources() to strip letter suffixes after parsing and deduplicate, preferring entries with valid URLs. Frontend: Add fallback in citation renderer - when a suffix reference like [1383a] has no matching source with URL, fall back to the base number [1383]. Also cleaned up 99 broken suffix entries and 44 suffix references in the Irankonflikt incident (ID 6) database records. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Dieser Commit ist enthalten in:
@@ -444,10 +444,17 @@ const UI = {
|
||||
html = html.replace(/<\/ul>(<br>)+/g, '</ul>');
|
||||
html = html.replace(/(<br>){2,}/g, '<br>');
|
||||
|
||||
// Inline-Zitate [1], [2] etc. als klickbare Links rendern
|
||||
// Inline-Zitate [1], [2], [1383a] etc. als klickbare Links rendern
|
||||
if (sources.length > 0) {
|
||||
html = html.replace(/\[(\d+[a-z]?)\]/g, (match, num) => {
|
||||
const src = sources.find(s => String(s.nr) === num || Number(s.nr) === Number(num));
|
||||
// Exakte Suche (auch mit Buchstaben-Suffix)
|
||||
let src = sources.find(s => String(s.nr) === num || Number(s.nr) === Number(num));
|
||||
// Fallback: Bei Suffix wie "1383a" auf Basisnummer 1383 zurueckfallen
|
||||
if ((!src || !src.url) && /[a-z]$/.test(num)) {
|
||||
const baseNum = num.replace(/[a-z]$/, '');
|
||||
const baseSrc = sources.find(s => String(s.nr) === baseNum || Number(s.nr) === Number(baseNum));
|
||||
if (baseSrc && baseSrc.url) src = baseSrc;
|
||||
}
|
||||
if (src && src.url) {
|
||||
return `<a href="${this.escape(src.url)}" target="_blank" rel="noopener" class="citation" title="${this.escape(src.name)}">[${num}]</a>`;
|
||||
}
|
||||
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren