-
Notifications
You must be signed in to change notification settings - Fork 16
Bump version of mermaid & katex #86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Summary of ChangesHello @xihale, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on maintaining the project's external dependencies by upgrading the KaTeX and Mermaid libraries to their latest stable versions. This ensures that the rendering of mathematical equations and diagrams benefits from the most recent features, bug fixes, and security improvements provided by these libraries, enhancing the overall stability and functionality of the application. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request updates the versions of the KaTeX and Mermaid.js libraries. The KaTeX update appears correct. However, the major version update for Mermaid.js from v8 to v11 introduces a breaking API change. The current implementation uses mermaid.initialize(), which was removed in v10, and will cause Mermaid diagrams to fail to render. I have added a comment with a suggested fix to use the new mermaid.run() API.
layouts/post.shtml
Outdated
| </ctx> | ||
| <ctx :if="$page.custom.getOr('mermaid', false)"> | ||
| <script defer src="https://mirrors.sustech.edu.cn/cdnjs/ajax/libs/mermaid/8.14.0/mermaid.min.js" integrity="sha512-vLumCjg7NKEQKGM+xAgBYTvQ90DVu6Eo7vS1T/iPf2feNLcrpGxvumuUUmE3CPiCUPgviyKbtpWGDbhnVnmJxg==" crossorigin="anonymous" onload="mermaid.initialize({startOnLoad:true});"></script> | ||
| <script defer src="https://mirrors.sustech.edu.cn/cdnjs/ajax/libs/mermaid/11.12.0/mermaid.min.js" integrity="sha512-5TKaYvhenABhlGIKSxAWLFJBZCSQw7HTV7aL1dJcBokM/+3PNtfgJFlv8E6Us/B1VMlQ4u8sPzjudL9TEQ06ww==" crossorigin="anonymous" onload="mermaid.initialize({startOnLoad:true});"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The major version bump of Mermaid.js from v8 to v11 includes breaking changes. The mermaid.initialize() function was removed in v10 and should be replaced with mermaid.run() to render the diagrams. The startOnLoad option is also no longer needed with the new API.
<script defer src="https://mirrors.sustech.edu.cn/cdnjs/ajax/libs/mermaid/11.12.0/mermaid.min.js" integrity="sha512-5TKaYvhenABhlGIKSxAWLFJBZCSQw7HTV7aL1dJcBokM/+3PNtfgJFlv8E6Us/B1VMlQ4u8sPzjudL9TEQ06ww==" crossorigin="anonymous" onload="mermaid.run();"></script>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request updates the versions of KaTeX and Mermaid libraries. The changes are applied correctly to both the layout file and the corresponding documentation. I've added a couple of suggestions to improve maintainability by centralizing the version information and reducing code duplication, which should make future updates easier.
| <ctx :if="$page.custom.getOr('math', false)"> | ||
| <link href="https://mirrors.sustech.edu.cn/cdnjs/ajax/libs/KaTeX/0.15.2/katex.min.css" integrity="sha512-g1pxMKWnqCJA5bTMwnw0Xwe0KQAfnj47+1pB0oISMqVFjm8Bg1vA3RENj+iGunE9j4zDLPWbau7jirWwJyshdQ==" crossorigin="anonymous" rel="stylesheet"> | ||
| <link href="https://mirrors.sustech.edu.cn/cdnjs/ajax/libs/KaTeX/0.16.9/katex.min.css" integrity="sha512-fHwaWebuwA7NSF5Qg/af4UeDx9XqUpYpOGgubo3yWu+b2IQR4UeQwbb42Ti7gVAjNtVoI/I9TEoYeu9omwcC6g==" crossorigin="anonymous" rel="stylesheet"> | ||
| <script | ||
| defer | ||
| src="https://mirrors.sustech.edu.cn/cdnjs/ajax/libs/KaTeX/0.15.2/katex.min.js" | ||
| integrity="sha512-iegr9Cbvw50rG0agCU/1HUJ0w5GflT+Lsk2SRI1jOjEC15RRgJW9vMLDFxIF3mBxoIDIS41fnENNuSZD+WhIOA==" | ||
| src="https://mirrors.sustech.edu.cn/cdnjs/ajax/libs/KaTeX/0.16.9/katex.min.js" | ||
| integrity="sha512-LQNxIMR5rXv7o+b1l8+N1EZMfhG7iFZ9HhnbJkTp4zjNr5Wvst75AqUeFDxeRUa7l5vEDyUiAip//r+EFLLCyA==" | ||
| crossorigin="anonymous" | ||
| ></script> | ||
| <script defer src="https://mirrors.sustech.edu.cn/cdnjs/ajax/libs/KaTeX/0.15.2/contrib/auto-render.min.js" integrity="sha512-ZA/RPrAo88DlwRnnoNVqKINnQNcWERzRK03PDaA4GIJiVZvGFIWQbdWCsUebMZfkWohnfngsDjXzU6PokO4jGw==" crossorigin="anonymous" onload="renderMathInElement(document.body);"></script> | ||
| <script defer src="https://mirrors.sustech.edu.cn/cdnjs/ajax/libs/KaTeX/0.16.9/contrib/auto-render.min.js" integrity="sha512-iWiuBS5nt6r60fCz26Nd0Zqe0nbk1ZTIQbl3Kv7kYsX+yKMUFHzjaH2+AnM6vp2Xs+gNmaBAVWJjSmuPw76Efg==" crossorigin="anonymous" onload="renderMathInElement(document.body);"></script> | ||
| </ctx> | ||
| <ctx :if="$page.custom.getOr('mermaid', false)"> | ||
| <script defer src="https://mirrors.sustech.edu.cn/cdnjs/ajax/libs/mermaid/8.14.0/mermaid.min.js" integrity="sha512-vLumCjg7NKEQKGM+xAgBYTvQ90DVu6Eo7vS1T/iPf2feNLcrpGxvumuUUmE3CPiCUPgviyKbtpWGDbhnVnmJxg==" crossorigin="anonymous" onload="mermaid.initialize({startOnLoad:true});"></script> | ||
| <script defer src="https://mirrors.sustech.edu.cn/cdnjs/ajax/libs/mermaid/11.12.0/mermaid.min.js" integrity="sha512-5TKaYvhenABhlGIKSxAWLFJBZCSQw7HTV7aL1dJcBokM/+3PNtfgJFlv8E6Us/B1VMlQ4u8sPzjudL9TEQ06ww==" crossorigin="anonymous" onload="mermaid.initialize({startOnLoad:true});"></script> | ||
| </ctx> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To improve maintainability and avoid repeating version numbers and integrity hashes, you could define them as variables in a parent <ctx> block. This centralizes the configuration, making future updates easier and less error-prone. Based on the project's blog post, it seems Scripty supports string interpolation with {$...}, which would make this refactoring possible.
<ctx
katex_version="0.16.9"
katex_css_integrity="sha512-fHwaWebuwA7NSF5Qg/af4UeDx9XqUpYpOGgubo3yWu+b2IQR4UeQwbb42Ti7gVAjNtVoI/I9TEoYeu9omwcC6g=="
katex_js_integrity="sha512-LQNxIMR5rXv7o+b1l8+N1EZMfhG7iFZ9HhnbJkTp4zjNr5Wvst75AqUeFDxeRUa7l5vEDyUiAip//r+EFLLCyA=="
katex_autorender_integrity="sha512-iWiuBS5nt6r60fCz26Nd0Zqe0nbk1ZTIQbl3Kv7kYsX+yKMUFHzjaH2+AnM6vp2Xs+gNmaBAVWJjSmuPw76Efg=="
mermaid_version="11.12.0"
mermaid_js_integrity="sha512-5TKaYvhenABhlGIKSxAWLFJBZCSQw7HTV7aL1dJcBokM/+3PNtfgJFlv8E6Us/B1VMlQ4u8sPzjudL9TEQ06ww=="
>
<ctx :if="$page.custom.getOr('math', false)">
<link href="https://mirrors.sustech.edu.cn/cdnjs/ajax/libs/KaTeX/{$ctx.katex_version}/katex.min.css" integrity="{$ctx.katex_css_integrity}" crossorigin="anonymous" rel="stylesheet">
<script defer src="https://mirrors.sustech.edu.cn/cdnjs/ajax/libs/KaTeX/{$ctx.katex_version}/katex.min.js" integrity="{$ctx.katex_js_integrity}" crossorigin="anonymous"></script>
<script defer src="https://mirrors.sustech.edu.cn/cdnjs/ajax/libs/KaTeX/{$ctx.katex_version}/contrib/auto-render.min.js" integrity="{$ctx.katex_autorender_integrity}" crossorigin="anonymous" onload="renderMathInElement(document.body);"></script>
</ctx>
<ctx :if="$page.custom.getOr('mermaid', false)">
<script defer src="https://mirrors.sustech.edu.cn/cdnjs/ajax/libs/mermaid/{$ctx.mermaid_version}/mermaid.min.js" integrity="{$ctx.mermaid_js_integrity}" crossorigin="anonymous" onload="mermaid.initialize({startOnLoad:true});"></script>
</ctx>
</ctx>
* fix(layout): Add cross-origin prototype for Mermaid renderer import * chore: upgrade mermaid and KaTeX dependencies to latest stable versions * fix: use mermaid.run
No description provided.