Skip to content
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

本地页面重载后白屏&关于katex的小疑惑 #308

Closed
3 tasks done
lkyu-ly opened this issue Dec 22, 2023 · 6 comments
Closed
3 tasks done

本地页面重载后白屏&关于katex的小疑惑 #308

lkyu-ly opened this issue Dec 22, 2023 · 6 comments
Labels
enhancement New feature or request

Comments

@lkyu-ly
Copy link

lkyu-ly commented Dec 22, 2023

Describe the bug

在本地终端运行 valaxy 命令生成的 preview 页面中,有时点击打开一篇文章后终端会提示

11:23:12 [vite] ✨ new dependencies optimized: valaxy-addon-twikoo, valaxy-addon-twikoo/client/styles/index.scss, valaxy-addon-waline
11:23:12 [vite] ✨ optimized dependencies changed. reloading

浏览器页面就会白屏,刷新以及重载都无用,只能终止终端并重新执行 valaxy 命令,下次点击同篇文章就不会有上述现象了。
下面是一次完整的运行终端输出:

PS E:\lkyu-blog-valaxy> valaxy
◐ Resolve valaxy config...                                                                                                                                    11:22:50
The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.
✔ Resolve userValaxyConfig from E:/lkyu-blog-valaxy/valaxy.config.ts                                                                                         11:22:53
✔ Resolve siteConfig from E:/lkyu-blog-valaxy/site.config.ts                                                                                                 11:22:54
✔ Resolve valaxy.config.ts from theme(yun)                                                                                                                   11:22:55
✔ Resolve addons from E:/lkyu-blog-valaxy
  ├─ valaxy-addon-waline https://github.com/YunYouJun/valaxy/tree/main/packages/valaxy-addon-waline                                                           11:22:55
  └─ valaxy-addon-components https://github.com/YunYouJun/valaxy/tree/main/packages/valaxy-addon-components                                                   11:22:55

  🌌 Valaxy  v0.15.14

  🪐 theme   > yun
  📁 E:\lkyu-blog-valaxy

  Preview    > http://localhost:4859/
  Network    > http://198.18.0.1:4859/
  Network    > http://26.57.123.184:4859/
  Network    > http://172.20.158.31:4859/
  Network    > http://172.21.176.1:4859/

  shortcuts  > restart | open | qr | edit

LaTeX-incompatible input and strict mode is set to 'warn': In LaTeX, \\ or \newline does nothing in display mode [newLineInDisplayMode]
11:23:12 [vite] ✨ new dependencies optimized: valaxy-addon-twikoo, valaxy-addon-twikoo/client/styles/index.scss, valaxy-addon-waline
11:23:12 [vite] ✨ optimized dependencies changed. reloading

另外,对于输出中的latex提示,我在搜索后发现是katex的设置中,严格模式的配置导致的,请问有相应设置项可以对此进行调节吗,翻了一下文档似乎没找到。

Reproduction

https://github.com/lkyu-ly/lkyu-blog-valaxy

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (16) x64 12th Gen Intel(R) Core(TM) i5-12500H
    Memory: 4.32 GB / 15.73 GB
  Binaries:
    Node: 20.7.0 - D:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - D:\Program Files\nodejs\yarn.CMD
    npm: 10.2.3 - D:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (120.0.2210.89)
    Internet Explorer: 11.0.22621.1

Used Package Manager

yarn

Validations

  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.
@YunYouJun YunYouJun added the enhancement New feature or request label Dec 22, 2023
@YunYouJun
Copy link
Owner

复现了,好神奇的案例。但似乎与 KaTeX 无关。

$$
i=Im[\sqrt{2}\cdot\dot{I}e^{j\omega t}]\\
u=Im[\sqrt{2}\cdot\dot{U}e^{j\omega t}]
$$

去掉 \\ 后会不再展示警告内容,这个应该时 KaTeX 本身的语法警告,默认不需要添加 \\。保留也没问题。


白屏应该是另外缓存 optimizeDeps 延迟导致的,第二次启动后已经缓存,所以不再有问题,我再排查一下。

@YunYouJun
Copy link
Owner

且仅在 windows 上可复现,macOS 没有这个问题。

@lkyu-ly
Copy link
Author

lkyu-ly commented Dec 22, 2023

(抱歉邮件不支持md语法,重发一条:)

我之前在查找这个问题的解决方案时,查到了这样的说法:

Clip_231222_2314

链接地址 或是 这个案例

他们似乎都指出是这个 katex 的配置导致了此问题。valaxy 也使用了​ katex,是否可以像上面的案例一样自定义这个 strict​ 的值,从而忽略这个确实无关紧要的提示呢

对于您说的双反斜杠可以去掉的方案,去掉虽然可以消除 \dispalystyle 引发的提示,但似乎就无法正确换行了:

Clip_231222_2314 (1)

Clip_231222_2315

@lkyu-ly
Copy link
Author

lkyu-ly commented Dec 22, 2023

在现有状况下,我能想到的既不出现提示又能保证显示的方法只有拆成两行两个公式来写:

$$
i=Im[\sqrt{2}\cdot\dot{I}e^{j\omega t}]
$$
$$
u=Im[\sqrt{2}\cdot\dot{U}e^{j\omega t}]
$$

另外吐槽一下就是:分两个公式写确实比用换行符写在一个公式块里面美观,写在一个公式里会导致上下两行间距过小,黏连在一起。

Clip_231222_2324分开书写公式

Clip_231222_2326使用 \\ 换行的写法

@YunYouJun
Copy link
Owner

自定义 KaTeX Options 的能力是有的,补了下文档。

https://valaxy.site/guide/markdown#custom-katex-options

// valaxy.config.ts
export default defineValaxyConfig({
  markdown: {
    /**
     * KaTeX options
     * @see https://katex.org/docs/options.html
     */
    katex: {
      strict: false
    }
  }
})

@YunYouJun
Copy link
Owner

optimizeDeps 白屏的问题也解了,更新了下加载顺序。

Released in v0.16.1.

第一次进入重新刷新是正常的,因为 Vite 是按需加载,进入 KaTeX 页面才 optimizeDeps KaTeX,之后就不会了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants