From 219e488d7f5cdd065bb42b932287025b04b14fc8 Mon Sep 17 00:00:00 2001 From: Maxim Dolgolyov Date: Thu, 28 May 2026 16:05:21 +0300 Subject: [PATCH] =?UTF-8?q?fix(geom8):=20KaTeX=20=D0=B2=20feedback=20?= =?UTF-8?q?=E2=80=94=20=D1=80=D0=B5=D0=BD=D0=B4=D0=B5=D1=80=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20$...$=20=D0=BF=D0=BE=D1=81=D0=BB=D0=B5=20=D1=83=D1=81?= =?UTF-8?q?=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=BA=D0=B8=20innerHTML?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit В сообщениях feedback (после Проверить) формулы с $...$ показывались как сырой LaTeX-источник, например 'Повтори: $S_1/S_2 = k^2.$'. Причина: feedback() устанавливал innerHTML но не вызывал renderMath() на этом элементе, поэтому KaTeX не обрабатывал формулы. Добавлен try{renderMath(elm);}catch(e){} после установки innerHTML во всех 3 файлах (ch1, ch2, ch3). Co-Authored-By: Claude Opus 4.7 (1M context) --- frontend/textbooks/geometry_8_ch1.html | 2 +- frontend/textbooks/geometry_8_ch2.html | 2 +- frontend/textbooks/geometry_8_ch3.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/textbooks/geometry_8_ch1.html b/frontend/textbooks/geometry_8_ch1.html index 05ec324..33fa11f 100644 --- a/frontend/textbooks/geometry_8_ch1.html +++ b/frontend/textbooks/geometry_8_ch1.html @@ -592,7 +592,7 @@ function renderMath(root){ try{ renderMathInElement(root, {delimiters:[{left:'$$',right:'$$',display:true},{left:'$',right:'$',display:false},{left:'\\[',right:'\\]',display:true},{left:'\\(',right:'\\)',display:false}],throwOnError:false}); }catch(e){} } } -function feedback(elm, ok, text){ if(!elm)return; elm.className = 'feedback ' + (ok ? 'ok' : 'fail'); elm.innerHTML = text || (ok ? '✓ Верно!' : '✗ Неверно'); elm.style.display='block'; } +function feedback(elm, ok, text){ if(!elm)return; elm.className = 'feedback ' + (ok ? 'ok' : 'fail'); elm.innerHTML = text || (ok ? '✓ Верно!' : '✗ Неверно'); elm.style.display='block'; try{renderMath(elm);}catch(e){} } function fmt(n){ if(!isFinite(n)) return '?'; if(Number.isInteger(n)) return String(n); return Math.abs(n - Math.round(n)) < 1e-9 ? String(Math.round(n)) : (+n.toFixed(4)).toString(); } const ICONS = { diff --git a/frontend/textbooks/geometry_8_ch2.html b/frontend/textbooks/geometry_8_ch2.html index 16f1be5..04f0501 100644 --- a/frontend/textbooks/geometry_8_ch2.html +++ b/frontend/textbooks/geometry_8_ch2.html @@ -442,7 +442,7 @@ function buildSidebar(id){ function initTheme(){ const t=localStorage.getItem('geometry8_ch2_theme')||'light'; if(t==='dark') document.documentElement.classList.add('dark'); document.getElementById('theme-lab').textContent=t==='dark'?'Светлая':'Тёмная'; document.getElementById('theme-btn').addEventListener('click',()=>{ document.documentElement.classList.toggle('dark'); const dark=document.documentElement.classList.contains('dark'); localStorage.setItem('geometry8_ch2_theme',dark?'dark':'light'); document.getElementById('theme-lab').textContent=dark?'Светлая':'Тёмная'; }); } function renderMath(root){ if(window.renderMathInElement){ try{renderMathInElement(root,{delimiters:[{left:'$$',right:'$$',display:true},{left:'$',right:'$',display:false},{left:'\\[',right:'\\]',display:true},{left:'\\(',right:'\\)',display:false}],throwOnError:false});}catch(e){} } } -function feedback(elm,ok,text){ if(!elm)return; elm.className='feedback '+(ok?'ok':'fail');elm.innerHTML=text||(ok?'✓ Верно!':'✗ Неверно'); elm.style.display='block'; } +function feedback(elm,ok,text){ if(!elm)return; elm.className='feedback '+(ok?'ok':'fail');elm.innerHTML=text||(ok?'✓ Верно!':'✗ Неверно'); elm.style.display='block'; try{renderMath(elm);}catch(e){} } function fmt(n){ if(!isFinite(n))return '?';if(Number.isInteger(n))return String(n);return Math.abs(n-Math.round(n))<1e-9?String(Math.round(n)):(+n.toFixed(4)).toString(); } const ICONS={repeat:'',theory:'',algo:'',rule:'',example:'',oral:'',class:'',home:''}; function makeCard(kind,title,num,body){ const labels={repeat:'Повторение',theory:'Теория',algo:'Алгоритм',rule:'Правило',example:'Пример',oral:'Устно',class:'Класс',home:'Домашка'}; return `
${ICONS[kind]}
${labels[kind]||''}${title&&title!==labels[kind]?' \xb7 '+title:''}
${num?`
${num}
`:''}
${body}
`; } diff --git a/frontend/textbooks/geometry_8_ch3.html b/frontend/textbooks/geometry_8_ch3.html index efa6160..9d9f8d8 100644 --- a/frontend/textbooks/geometry_8_ch3.html +++ b/frontend/textbooks/geometry_8_ch3.html @@ -372,7 +372,7 @@ function buildSidebar(id){const box=document.getElementById('sidebar-content');c function initTheme(){const t=localStorage.getItem('geometry8_ch3_theme')||'light';if(t==='dark')document.documentElement.classList.add('dark');document.getElementById('theme-lab').textContent=t==='dark'?'Светлая':'Тёмная';document.getElementById('theme-btn').addEventListener('click',()=>{document.documentElement.classList.toggle('dark');const dark=document.documentElement.classList.contains('dark');localStorage.setItem('geometry8_ch3_theme',dark?'dark':'light');document.getElementById('theme-lab').textContent=dark?'Светлая':'Тёмная';});} function renderMath(root){if(window.renderMathInElement){try{renderMathInElement(root,{delimiters:[{left:'$$',right:'$$',display:true},{left:'$',right:'$',display:false},{left:'\\[',right:'\\]',display:true},{left:'\\(',right:'\\)',display:false}],throwOnError:false});}catch(e){}}} -function feedback(elm,ok,text){if(!elm)return;elm.className='feedback '+(ok?'ok':'fail');elm.innerHTML=text||(ok?'✓ Верно!':'✗ Неверно');elm.style.display='block';} +function feedback(elm,ok,text){if(!elm)return;elm.className='feedback '+(ok?'ok':'fail');elm.innerHTML=text||(ok?'✓ Верно!':'✗ Неверно');elm.style.display='block';try{renderMath(elm);}catch(e){}} function fmt(n){if(!isFinite(n))return '?';if(Number.isInteger(n))return String(n);return Math.abs(n-Math.round(n))<1e-9?String(Math.round(n)):(+n.toFixed(4)).toString();} const ICONS={repeat:'',theory:'',algo:'',rule:'',example:'',oral:'',class:'',home:''}; function makeCard(kind,title,num,body){const labels={repeat:'Повторение',theory:'Теория',algo:'Алгоритм',rule:'Правило',example:'Пример',oral:'Устно',class:'Класс',home:'Домашка'};return `
${ICONS[kind]}
${labels[kind]||''}${title&&title!==labels[kind]?' \xb7 '+title:''}
${num?`
${num}
`:''}
${body}
`;}