';
const lines = termaText.split('\n');
let inList = false;
for (let i = 0; i < lines.length; i++) {
const line = lines[i].trim();
if (!line) {
if (inList) {
html += '';
inList = false;
}
continue;
}
// Заголовок H1
if (i === 0) {
html += '
';
html += `
${line}
`;
continue;
}
// Дата обновления
if (line.includes('Последнее обновление')) {
html += `
${line}
`;
html += '
';
continue;
}
// Основные разделы (начинаются с цифры и точки без подразделов)
if (/^\d+\.\s+[А-Яа-я]/.test(line)) {
if (inList) {
html += '';
inList = false;
}
const text = line.replace(/^\d+\.\s+/, '');
html += `
${line}
`;
continue;
}
// Подразделы (например, 2.1., 3.2.)
if (/^\d+\.\d+\.\s+/.test(line)) {
if (inList) {
html += '';
inList = false;
}
html += `
${line}
`;
continue;
}
// Списки (начинаются с заглавной буквы или содержат "—")
if (line.includes('—') || (i > 0 && lines[i-1].includes('через:')) || (i > 0 && lines[i-1].includes('обязуется:')) || (i > 0 && lines[i-1].includes('собирает:')) || (i > 0 && lines[i-1].includes('ответственности за:'))) {
if (!inList) {
html += '
';
inList = true;
}
// Обработка ссылок
let processedLine = line
.replace(/https?:\/\/[^\s,)]+/g, (url) => {
const cleanUrl = url.replace(/\s*,?\s*$/, '');
return `${cleanUrl}`;
})
.replace(/([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})/g,
'$1');
html += `- ${processedLine}
`;
continue;
}
// Обычные параграфы
if (inList && !line.includes('—')) {
html += '
';
inList = false;
}
// Обработка жирного текста и ссылок
let processedLine = line
.replace(/\*\*([^*]+)\*\*/g, '
$1')
.replace(/https?:\/\/[^\s,)]+/g, (url) => {
const cleanUrl = url.replace(/\s*,?\s*$/, '');
return `
${cleanUrl}`;
})
.replace(/([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})/g,
'
$1');
html += `
${processedLine}
`;
}
if (inList) {
html += '';
}
// Footer
html += '
';
html += '
© 2025 BROJS.RU. Все права защищены.
';
html += '