test.html 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Screenshotter test</title>
  5. <script src="../../katex.js" type="text/javascript"></script>
  6. <style type="text/css">
  7. #math, #pre, #post {
  8. font-size: 4em;
  9. }
  10. body {
  11. font-family: "DejaVu Serif",serif;
  12. }
  13. @font-face {
  14. font-family: "Mincho";
  15. src: url("/submodules/katex-test-fonts/mincho/font_1_honokamin.ttf") format("truetype");
  16. }
  17. @font-face {
  18. font-family: "Batang";
  19. src: url("/submodules/katex-test-fonts/batang/batang.ttf") format("truetype");
  20. }
  21. .katex .cjk_fallback {
  22. font-family: "Mincho",serif;
  23. }
  24. .katex .hangul_fallback {
  25. font-family: "Batang",serif;
  26. }
  27. </style>
  28. </head>
  29. <body>
  30. <span id="pre"></span>
  31. <span id="math"></span>
  32. <span id="post"></span>
  33. <script type="text/javascript">
  34. function handle_search_string(search, callback) {
  35. var query = {};
  36. var re = /(?:^\?|&)([^&=]+)(?:=([^&]+))?/g;
  37. var match;
  38. while (match = re.exec(search)) {
  39. query[match[1]] = decodeURIComponent(match[2]);
  40. }
  41. var mathNode = document.getElementById("math");
  42. var settings = {
  43. displayMode: !!query["display"],
  44. throwOnError: !query["noThrow"]
  45. };
  46. if (query["errorColor"]) {
  47. settings.errorColor = query["errorColor"];
  48. }
  49. var macros = {};
  50. var macroRegex = /(?:^\?|&)(?:\\|%5[Cc])([A-Za-z]+)=([^&]*)/g;
  51. while ((match = macroRegex.exec(search)) !== null) {
  52. settings.macros = macros;
  53. macros["\\" + match[1]] = decodeURIComponent(match[2]);
  54. }
  55. mathNode.setAttribute("style", query["styles"] || "");
  56. katex.render(query["tex"], mathNode, settings);
  57. document.getElementById("pre").innerHTML = query["pre"] || "";
  58. document.getElementById("post").innerHTML = query["post"] || "";
  59. if (callback && document.fonts && document.fonts.ready) {
  60. document.fonts.ready.then(callback);
  61. } else if (callback) {
  62. callback();
  63. }
  64. }
  65. handle_search_string(window.location.search);
  66. </script>
  67. </body>
  68. </html>