Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +19 -14
templates/index.html
CHANGED
@@ -8,6 +8,7 @@
|
|
8 |
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
|
9 |
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
10 |
<script src="https://cdn.tailwindcss.com"></script>
|
|
|
11 |
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
|
12 |
<style>
|
13 |
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
|
@@ -50,23 +51,28 @@
|
|
50 |
.math-content .MathJax {
|
51 |
overflow-x: auto;
|
52 |
overflow-y: hidden;
|
53 |
-
|
54 |
-
padding: 0.5rem 0; /* Ajoute un peu d'espace */
|
55 |
}
|
56 |
|
57 |
-
/* Ajustement pour les petits écrans */
|
58 |
@media (max-width: 640px) {
|
59 |
.math-content .MathJax {
|
60 |
-
font-size: 0.9em;
|
61 |
}
|
62 |
}
|
63 |
|
64 |
-
/* Classe pour masquer le contenu pendant que MathJax n'a pas traité */
|
65 |
.math-hidden {
|
66 |
visibility: hidden;
|
67 |
}
|
68 |
</style>
|
69 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
MathJax = {
|
71 |
tex: {
|
72 |
inlineMath: [['$', '$'], ['\\(', '\\)']],
|
@@ -84,8 +90,8 @@
|
|
84 |
},
|
85 |
options: {
|
86 |
renderActions: {
|
87 |
-
addMenu: [],
|
88 |
-
checkLoading: [150, (doc) => {
|
89 |
document.querySelectorAll('.math-content').forEach(el => {
|
90 |
el.classList.remove('math-hidden');
|
91 |
});
|
@@ -168,7 +174,7 @@
|
|
168 |
// Show loading
|
169 |
document.getElementById('loading').classList.remove('hidden');
|
170 |
document.getElementById('result-container').classList.add('hidden');
|
171 |
-
document.getElementById('result').classList.add('math-hidden');
|
172 |
|
173 |
try {
|
174 |
const formData = new FormData();
|
@@ -186,23 +192,22 @@
|
|
186 |
|
187 |
// Show result
|
188 |
document.getElementById('result-container').classList.remove('hidden');
|
189 |
-
|
|
|
190 |
|
191 |
// Rendre les maths avec MathJax
|
192 |
-
MathJax.typesetPromise([document.getElementById('result')])
|
|
|
193 |
document.getElementById('result').classList.remove('math-hidden');
|
194 |
})
|
195 |
.catch((err) => {
|
196 |
console.error('Erreur MathJax:', err);
|
197 |
-
// Gérer l'erreur MathJax, par exemple afficher un message d'erreur
|
198 |
document.getElementById('result').innerHTML = "Erreur lors du rendu des mathématiques.";
|
199 |
-
document.getElementById('result').classList.remove('math-hidden');
|
200 |
-
|
201 |
});
|
202 |
|
203 |
} catch (error) {
|
204 |
console.error('Erreur:', error);
|
205 |
-
// Hide loading
|
206 |
document.getElementById('loading').classList.add('hidden');
|
207 |
alert('Une erreur est survenue lors du traitement de l\'image.');
|
208 |
}
|
|
|
8 |
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
|
9 |
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
10 |
<script src="https://cdn.tailwindcss.com"></script>
|
11 |
+
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
12 |
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
|
13 |
<style>
|
14 |
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
|
|
|
51 |
.math-content .MathJax {
|
52 |
overflow-x: auto;
|
53 |
overflow-y: hidden;
|
54 |
+
padding: 0.5rem 0;
|
|
|
55 |
}
|
56 |
|
|
|
57 |
@media (max-width: 640px) {
|
58 |
.math-content .MathJax {
|
59 |
+
font-size: 0.9em;
|
60 |
}
|
61 |
}
|
62 |
|
|
|
63 |
.math-hidden {
|
64 |
visibility: hidden;
|
65 |
}
|
66 |
</style>
|
67 |
<script>
|
68 |
+
// Configuration de marked
|
69 |
+
marked.setOptions({
|
70 |
+
breaks: true,
|
71 |
+
gfm: true,
|
72 |
+
headerIds: false
|
73 |
+
});
|
74 |
+
|
75 |
+
// Configuration de MathJax
|
76 |
MathJax = {
|
77 |
tex: {
|
78 |
inlineMath: [['$', '$'], ['\\(', '\\)']],
|
|
|
90 |
},
|
91 |
options: {
|
92 |
renderActions: {
|
93 |
+
addMenu: [],
|
94 |
+
checkLoading: [150, (doc) => {
|
95 |
document.querySelectorAll('.math-content').forEach(el => {
|
96 |
el.classList.remove('math-hidden');
|
97 |
});
|
|
|
174 |
// Show loading
|
175 |
document.getElementById('loading').classList.remove('hidden');
|
176 |
document.getElementById('result-container').classList.add('hidden');
|
177 |
+
document.getElementById('result').classList.add('math-hidden');
|
178 |
|
179 |
try {
|
180 |
const formData = new FormData();
|
|
|
192 |
|
193 |
// Show result
|
194 |
document.getElementById('result-container').classList.remove('hidden');
|
195 |
+
// Utiliser marked pour convertir le markdown en HTML
|
196 |
+
document.getElementById('result').innerHTML = marked.parse(data.result);
|
197 |
|
198 |
// Rendre les maths avec MathJax
|
199 |
+
MathJax.typesetPromise([document.getElementById('result')])
|
200 |
+
.then(() => {
|
201 |
document.getElementById('result').classList.remove('math-hidden');
|
202 |
})
|
203 |
.catch((err) => {
|
204 |
console.error('Erreur MathJax:', err);
|
|
|
205 |
document.getElementById('result').innerHTML = "Erreur lors du rendu des mathématiques.";
|
206 |
+
document.getElementById('result').classList.remove('math-hidden');
|
|
|
207 |
});
|
208 |
|
209 |
} catch (error) {
|
210 |
console.error('Erreur:', error);
|
|
|
211 |
document.getElementById('loading').classList.add('hidden');
|
212 |
alert('Une erreur est survenue lors du traitement de l\'image.');
|
213 |
}
|