From aaff1fc7df7b939e234bcb79fc5eb2d1dd1b95da Mon Sep 17 00:00:00 2001 From: WncFht <2130212584@qq.com> Date: Thu, 5 Dec 2024 00:01:12 +0800 Subject: [PATCH] add cs231n_notes --- docs/js/katex.js | 49 ++++++++++------------------------------------ docs/js/mathjax.js | 16 +++++++++++++++ mkdocs.yml | 20 +++++++++++++------ 3 files changed, 40 insertions(+), 45 deletions(-) create mode 100644 docs/js/mathjax.js diff --git a/docs/js/katex.js b/docs/js/katex.js index 6db56429..7599ad94 100644 --- a/docs/js/katex.js +++ b/docs/js/katex.js @@ -1,39 +1,10 @@ -(function () { - 'use strict'; - - var katexMath = (function () { - var maths = document.querySelectorAll('.arithmatex'), - tex; - - for (var i = 0; i < maths.length; i++) { - tex = maths[i].textContent || maths[i].innerText; - if (tex.startsWith('\\(') && tex.endsWith('\\)')) { - katex.render(tex.slice(2, -2), maths[i], {'displayMode': false}); - } else if (tex.startsWith('\\[') && tex.endsWith('\\]')) { - katex.render(tex.slice(2, -2), maths[i], {'displayMode': true}); - } - } - }); - - (function () { - var onReady = function onReady(fn) { - if (document.addEventListener) { - document.addEventListener("DOMContentLoaded", fn); - } else { - document.attachEvent("onreadystatechange", function () { - if (document.readyState === "interactive") { - fn(); - } - }); - } - }; - - onReady(function () { - if (typeof katex !== "undefined") { - katexMath(); - } - }); - })(); - - }()); - \ No newline at end of file +document$.subscribe(({ body }) => { + renderMathInElement(body, { + delimiters: [ + { left: "$$", right: "$$", display: true }, // Display mode equations + { left: "$", right: "$", display: false }, // Inline equations + { left: "\\(", right: "\\)", display: false }, // Alternative inline + { left: "\\[", right: "\\]", display: true } // Alternative display + ], + }) + }) \ No newline at end of file diff --git a/docs/js/mathjax.js b/docs/js/mathjax.js new file mode 100644 index 00000000..ca943ee3 --- /dev/null +++ b/docs/js/mathjax.js @@ -0,0 +1,16 @@ +window.MathJax = { + tex: { + inlineMath: [["\\(", "\\)"]], // Inline math delimiters + displayMath: [["\\[", "\\]"]], // Display math delimiters + processEscapes: true, // Handle escaped characters + processEnvironments: true // Process LaTeX environments + }, + options: { + ignoreHtmlClass: ".*|", // Ignore all classes by default + processHtmlClass: "arithmatex" // Only process elements with this class + } + }; + + document$.subscribe(() => { + MathJax.typesetPromise() // Render math when document loads + }) \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index db22f995..35f3033b 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -96,6 +96,8 @@ markdown_extensions: custom_checkbox: true - pymdownx.arithmatex: generic: true + + # - markdown.extensions.toc: # slugify: # !!python/object/apply:pymdownx.slugs.slugify { kwds: { case: lower } } @@ -141,8 +143,8 @@ extra: # property: YOUR-ANALYTICS-ID extra_css: - # - https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.7/katex.min.css - - https://cdn.tonycrane.cc/utils/katex.min.css + - https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.9/katex.min.css + # - https://cdn.tonycrane.cc/utils/katex.min.css - https://cdn.tonycrane.cc/jbmono/jetbrainsmono.css - https://cdn.tonycrane.cc/lxgw/lxgwscreen.css - css/custom.css @@ -153,17 +155,23 @@ extra_css: # - css/changelog_extra.css # - css/flod_toc.css # - css/grid cards.css # 好用的但还没用 - # - https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.9/katex.min.css # - css/extra.css # - https://cdn.jsdelivr.net/npm/lxgw-wenkai-webfont@1.1.0/style.css extra_javascript: - js/katex.js - - https://cdn.tonycrane.cc/utils/katex.min.js + - js/mathjax.js + # - https://cdn.tonycrane.cc/utils/katex.min.js - https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js - # - https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.7/katex.min.js - # - https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.7/contrib/auto-render.min.js + # katex + - https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.9/katex.min.js + - https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.9/contrib/auto-render.min.js + # mathjax + - https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.0/es5/tex-mml-chtml.js + - https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.0/es5/tex-chtml.js + - https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.0/es5/tex-chtml-full.js + - https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.0/es5/tex-svg-full.js # - js/custom.js # - js/heti.js # - js/toc.js