petites erreurs

This commit is contained in:
nicoboy
2026-01-04 10:43:37 +01:00
parent 017cb697ba
commit 8c74a843b2
2 changed files with 26 additions and 45 deletions

View File

@ -271,41 +271,9 @@ async loadHelpRemaining() {
// NOUVELLE MÉTHODE : Formater le texte avec support maths
formatMathText(texte) {
// Convertir les retours à la ligne en <br>
let html = texte.replace(/\n/g, '<br>');
// Détecter et convertir les fractions communes
// 1/2 → $\frac{1}{2}$
html = html.replace(/(\d+)\/(\d+)/g, '$\\frac{$1}{$2}$');
// Convertir les puissances
// x^2 → $x^2$
html = html.replace(/([a-z0-9]+)\^([0-9]+)/gi, '$$$1^{$2}$$');
// Convertir les indices
// x_1 → $x_1$
html = html.replace(/([a-z0-9]+)_([0-9]+)/gi, '$$$1_{$2}$$');
// Symboles mathématiques courants
const symbols = {
'×': '\\times',
'÷': '\\div',
'≤': '\\leq',
'≥': '\\geq',
'≠': '\\neq',
'≈': '\\approx',
'∞': '\\infty',
'√': '\\sqrt',
'π': '\\pi',
'∑': '\\sum',
'∫': '\\int'
};
for (let [symbol, latex] of Object.entries(symbols)) {
html = html.replace(new RegExp(symbol, 'g'), '$' + latex + '$');
}
return html;
// Juste convertir \n en <br>
// Le reste (LaTeX) est géré par KaTeX
return texte.replace(/\n/g, '<br>');
}
afficherTypingIndicator() {