fix(alg7 fx): KaTeX-делимитеры $...$ в визуализаторах §12-§13
В alg7-fx.js renderMathInElement() вызывался без опций — KaTeX auto-render по умолчанию узнаёт только \(...\) и \[...\], а не $...$. Поэтому формулы в виз. квадрата суммы и разности квадратов отображались как обычный текст (см. скриншот пользователя). Фикс: общий хелпер ALG7.renderMath(root), который вызывает renderMathInElement с теми же делимитерами, что прописаны в страницах глав ($$, $, \[\], \(\)). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
+17
-2
@@ -21,6 +21,21 @@ ALG7.__installed = true;
|
||||
ALG7.combo = 0;
|
||||
ALG7.maxCombo = 0;
|
||||
|
||||
/* === KATEX HELPER (использует те же делимитеры, что и страницы) === */
|
||||
const _KATEX_OPTS = {
|
||||
delimiters: [
|
||||
{ left:'$$', right:'$$', display:true },
|
||||
{ left:'$', right:'$', display:false },
|
||||
{ left:'\\[', right:'\\]', display:true },
|
||||
{ left:'\\(', right:'\\)', display:false }
|
||||
],
|
||||
throwOnError: false
|
||||
};
|
||||
ALG7.renderMath = function(root){
|
||||
if(!root || !window.renderMathInElement) return;
|
||||
try{ window.renderMathInElement(root, _KATEX_OPTS); }catch(e){}
|
||||
};
|
||||
|
||||
/* === ANIMATIONS === */
|
||||
ALG7.shake = function(el){
|
||||
if(!el) return;
|
||||
@@ -257,7 +272,7 @@ ALG7.buildQuadSumViz = function(container){
|
||||
}
|
||||
}
|
||||
svg.innerHTML = html;
|
||||
if(window.renderMathInElement) try{ window.renderMathInElement(formula); }catch(e){}
|
||||
ALG7.renderMath(formula);
|
||||
|
||||
/* Hover-эффект: при клике подсветить термин */
|
||||
svg.querySelectorAll('rect[data-part]').forEach(r=>{
|
||||
@@ -401,7 +416,7 @@ ALG7.buildDiffSquaresViz = function(container){
|
||||
stepText.textContent = 'Сбросить';
|
||||
}
|
||||
formula.innerHTML = formulaText;
|
||||
if(window.renderMathInElement) try{ window.renderMathInElement(formula); }catch(e){}
|
||||
ALG7.renderMath(formula);
|
||||
}
|
||||
|
||||
stepBtn.addEventListener('click', ()=>{
|
||||
|
||||
Reference in New Issue
Block a user