embeddings-1 #2
File diff suppressed because one or more lines are too long
197478
data/embeddings.json
197478
data/embeddings.json
File diff suppressed because it is too large
Load Diff
@ -497,50 +497,62 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
}
|
||||
|
||||
function formatWorkflowSuggestion(text) {
|
||||
// Improved handling for different list formats
|
||||
const numberedListPattern = /(\d+\.\s)/g;
|
||||
|
||||
if (numberedListPattern.test(text)) {
|
||||
const items = text.split(/\d+\.\s/).filter(item => item.trim().length > 0);
|
||||
// Type safety: ensure text is a string
|
||||
if (!text || typeof text !== 'string') {
|
||||
console.warn('[FORMAT] Invalid text input:', typeof text, text);
|
||||
return `<p style="margin: 0; line-height: 1.6; color: var(--color-text);">Inhalt nicht verfügbar</p>`;
|
||||
}
|
||||
|
||||
if (items.length > 1) {
|
||||
const listItems = items.map(item =>
|
||||
`<li style="margin-bottom: 0.5rem; line-height: 1.6;">${item.trim()}</li>`
|
||||
).join('');
|
||||
|
||||
return `<ol style="margin: 0; padding-left: 1.5rem; color: var(--color-text);">${listItems}</ol>`;
|
||||
// Sanitize and trim the text
|
||||
const cleanText = text.trim();
|
||||
if (cleanText.length === 0) {
|
||||
return `<p style="margin: 0; line-height: 1.6; color: var(--color-text);">Keine Informationen verfügbar</p>`;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle bullet points
|
||||
const bulletPattern = /^[\s]*[-\*•]\s/gm;
|
||||
if (bulletPattern.test(text)) {
|
||||
const items = text.split(/^[\s]*[-\*•]\s/gm).filter(item => item.trim().length > 0);
|
||||
|
||||
if (items.length > 1) {
|
||||
const listItems = items.map(item =>
|
||||
`<li style="margin-bottom: 0.5rem; line-height: 1.6;">${item.trim()}</li>`
|
||||
).join('');
|
||||
// Improved handling for different list formats
|
||||
const numberedListPattern = /(\d+\.\s)/g;
|
||||
|
||||
if (numberedListPattern.test(cleanText)) {
|
||||
const items = cleanText.split(/\d+\.\s/).filter(item => item.trim().length > 0);
|
||||
|
||||
return `<ul style="margin: 0; padding-left: 1.5rem; color: var(--color-text);">${listItems}</ul>`;
|
||||
if (items.length > 1) {
|
||||
const listItems = items.map(item =>
|
||||
`<li style="margin-bottom: 0.5rem; line-height: 1.6;">${sanitizeHTML(item.trim())}</li>`
|
||||
).join('');
|
||||
|
||||
return `<ol style="margin: 0; padding-left: 1.5rem; color: var(--color-text);">${listItems}</ol>`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handle line breaks as lists
|
||||
if (text.includes('\n')) {
|
||||
const lines = text.split('\n').filter(line => line.trim().length > 0);
|
||||
if (lines.length > 1) {
|
||||
const listItems = lines.map(line =>
|
||||
`<li style="margin-bottom: 0.5rem; line-height: 1.6;">${line.trim()}</li>`
|
||||
).join('');
|
||||
|
||||
// Handle bullet points
|
||||
const bulletPattern = /^[\s]*[-\*•]\s/gm;
|
||||
if (bulletPattern.test(cleanText)) {
|
||||
const items = cleanText.split(/^[\s]*[-\*•]\s/gm).filter(item => item.trim().length > 0);
|
||||
|
||||
return `<ul style="margin: 0; padding-left: 1.5rem; color: var(--color-text);">${listItems}</ul>`;
|
||||
if (items.length > 1) {
|
||||
const listItems = items.map(item =>
|
||||
`<li style="margin-bottom: 0.5rem; line-height: 1.6;">${sanitizeHTML(item.trim())}</li>`
|
||||
).join('');
|
||||
|
||||
return `<ul style="margin: 0; padding-left: 1.5rem; color: var(--color-text);">${listItems}</ul>`;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle line breaks as lists
|
||||
if (cleanText.includes('\n')) {
|
||||
const lines = cleanText.split('\n').filter(line => line.trim().length > 0);
|
||||
if (lines.length > 1) {
|
||||
const listItems = lines.map(line =>
|
||||
`<li style="margin-bottom: 0.5rem; line-height: 1.6;">${sanitizeHTML(line.trim())}</li>`
|
||||
).join('');
|
||||
|
||||
return `<ul style="margin: 0; padding-left: 1.5rem; color: var(--color-text);">${listItems}</ul>`;
|
||||
}
|
||||
}
|
||||
|
||||
// Default paragraph formatting
|
||||
return `<p style="margin: 0; line-height: 1.6; color: var(--color-text);">${sanitizeHTML(cleanText)}</p>`;
|
||||
}
|
||||
|
||||
// Default paragraph formatting
|
||||
return `<p style="margin: 0; line-height: 1.6; color: var(--color-text);">${text}</p>`;
|
||||
}
|
||||
|
||||
function renderBackgroundKnowledge(backgroundKnowledge) {
|
||||
if (!backgroundKnowledge || backgroundKnowledge.length === 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user