diff --git a/demo-repository/exercises/demo/descr.html b/demo-repository/exercises/demo/descr.html
index 2daf24660..4733eb805 100644
--- a/demo-repository/exercises/demo/descr.html
+++ b/demo-repository/exercises/demo/descr.html
@@ -78,3 +78,26 @@
The task
So don't worry, you can try and break the system as much as you
want, it should not break anything on our servers.
+
+Displaying Mathematical Formulas
+
+
+ This environment supports mathematical notation using MathJax.
+ To write a mathematical expression, you can use:
+
+
+
+ - For inline math, enclose your expression between single dollar signs:
$...$, or between escaped parentheses: \(...\).
+ - For displayed equations (centered on a new line), use double dollar signs:
$$...$$, or escaped brackets: \[...\].
+
+
+Example:
+
+
+ - Inline formula:
$E = mc^2$ or \(E = mc^2\) → renders as: \(E = mc^2\).
+ - Displayed formula:
$$\sum_{i=1}^{n} i = \frac{n(n+1)}{2}$$ or \[\sum_{i=1}^{n} i = \frac{n(n+1)}{2}\] → renders as:
+ \[
+ \sum_{i=1}^{n} i = \frac{n(n+1)}{2}
+ \]
+
+
diff --git a/src/app/learnocaml_common.ml b/src/app/learnocaml_common.ml
index a5a12d2d6..0c47a70df 100644
--- a/src/app/learnocaml_common.ml
+++ b/src/app/learnocaml_common.ml
@@ -399,7 +399,7 @@ let render_rich_text ?on_runnable_clicked text =
| Image _ :: _ -> assert false
| Math code :: rest ->
render
- (H.txt ("`" ^ code ^ "`") :: acc)
+ (H.txt (" $" ^ code ^ "$ ") :: acc)
rest in
(render [] text
:> [< Html_types.phrasing > `Code `Em `PCDATA ] H.elt list)
@@ -589,18 +589,17 @@ let stars_div stars =
let exercise_text ex_meta exo =
let mathjax_url =
- api_server ^ "/js/mathjax/MathJax.js?delayStartupUntil=configured"
+ api_server ^ "/js/mathjax/es5/tex-chtml.js"
in
let mathjax_config =
- "MathJax.Hub.Config({\n\
- \ jax: [\"input/AsciiMath\", \"output/HTML-CSS\"],\n\
- \ extensions: [],\n\
- \ showMathMenu: false,\n\
- \ showMathMenuMSIE: false,\n\
- \ \"HTML-CSS\": {\n\
- \ imageFont: null\n\
- \ }
- });"
+ "MathJax = {\n\
+ \ tex: {\n\
+ \ inlineMath: [[\"$\", \"$\"], [\"\\\\(\", \"\\\\)\"]]\n\
+ \ },\n\
+ \ svg: {\n\
+ \ fontCache: \"global\"\n\
+ \ }\n\
+ };"
(* the following would allow comma instead of dot for the decimal separator,
but should depend on the language the exercise is in, not the language of the
app
@@ -625,13 +624,12 @@ let exercise_text ex_meta exo =
%s - exercise text\
\
\
-
- \
+
+ \
\
\
%s\
\
- \