File: module.html

package info (click to toggle)
node-katex 0.10.2%2Bdfsg-8
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 10,320 kB
  • sloc: javascript: 21,248; perl: 2,884; python: 390; sh: 329; makefile: 109
file content (42 lines) | stat: -rw-r--r-- 1,480 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<!--To test ECMA modules, run `npm run build` and then `npm start`
    in the root KaTeX directory and then visit with a web browser
    which supports modules: http://localhost:7936/module.html
  -->
<html>
    <head>
        <meta charset="UTF-8">
        <title>KaTeX Test</title>
        <link rel="stylesheet" type="text/css" href="/dist/katex.css">
        <link rel="stylesheet" type="text/css" href="/main.css">
        <script type="module" type="text/javascript">
            import katex from '/dist/katex.mjs';

            const input = document.getElementById("input");
            const math = document.getElementById("math");

            input.addEventListener("input", reprocess, false);
            reprocess();

            function reprocess() {
                try {
                    katex.render(input.value, math, {displayMode: true, throwOnError: false, macros: {}});
                } catch (e) {
                    if (e.__proto__ === katex.ParseError.prototype) {
                        console.error(e);
                    } else {
                        throw e;
                    }
                }
            }
        </script>
    </head>
    <body>
        <textarea id="input" rows="5">
\left( x \right) \left( x^2 \right) % comment
\left( \frac{a}{b} \right) \left( \frac{a^2}{b} \right)
\left( \dfrac{a}{b} \right) \left( \dfrac{a^2}{b} \right)
        </textarea>
        <div id="math"></div>
    </body>
</html>