// Добавьте этот код в раздел "Дополнительный HTML" или в футер
document.addEventListener('DOMContentLoaded', function() {
const textContainers = document.querySelectorAll('.t-text, .t-rich-text, p, h1, h2, h3, h4, h5, h6');
const hangingPrepositions = ['в', 'на', 'о', 'об', 'обо', 'с', 'со', 'у', 'к', 'ко', 'от', 'до', 'по', 'под', 'из', 'за', 'над', 'про', 'перед', 'при'];
textContainers.forEach(container => {
let html = container.innerHTML;
hangingPrepositions.forEach(preposition => {
// Регулярное выражение для поиска висячих предлогов
const regex = new RegExp(`\\s${preposition}\\s+[^<>\\.\\!\\?]{1,15}[\\.,\\!\\?]?(?:<\\/p>|
|$)`, 'gi');
html = html.replace(regex, (match) => {
// Подсветка проблемных мест
return match.replace(
new RegExp(`\\s(${preposition})\\s`, 'gi'),
' $1 '
);
});
});
container.innerHTML = html;
});
});