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

build 时Parse Error #295

Closed
3 tasks done
dbinfun opened this issue Nov 17, 2023 · 6 comments
Closed
3 tasks done

build 时Parse Error #295

dbinfun opened this issue Nov 17, 2023 · 6 comments
Assignees
Labels
bug Something isn't working upstream

Comments

@dbinfun
Copy link

dbinfun commented Nov 17, 2023

Describe the bug

当小标题中存在^,$符号时,会导致build时报错:Parse Error,但令人疑惑的是dev 时正常

如:

---
title: Hello, Valaxy!
date: 2022-04-01
updated: 2022-04-01
categories: Valaxy 笔记
tags:
  - valaxy
  - 笔记
top: 1
---

## Valaxy

Next Generation Static Blog Framework.

Write your first post!

## Usage`^`,`$`

Modify `valaxy.config.ts` to custom your blog.

其中 第二个标题中包含$符号导致build时报错,即使使用``将其括起来, 在之前的版本中并不会出现这种情况

具体的报错信息如下:

Error: [vite-ssg] Error on page: /posts/hello-valaxy
Error: Parse Error: <a aria-current="page" href="/posts/hello-valaxy#usage" class="router-link-active router-link-exact-active header-anchor" aria-label="Permalink to &quot;Usage<div 
id=" app">quot;"&gt;<!--[-->​<!--]--></a></h2><p>Modify <code>valaxy.config.ts</code> to custom your blog.</p><!--]--><!--[--><!--]--><!--]--><!----><!----></article></template><!--]-
-><!--[--><!--[--><!--[--><div class="yun-sponsor-container flex-center flex-col" m="t-6"><button class="sponsor-button yun-icon-btn shadow hover:shadow-md" title="我很可爱,请给我钱 
!" text="red-400"><div i-ri-heart-line></div></button><div m="y-4" class="qrcode-container qrcode flex-center flex-col"><div class="sponsor-description" mb="4" text="sm">这是关于赞助
一些描述</div><div class="flex justify-around"><!--[--><a class="flex-center flex-col animate-iteration-1 animate-fade-in" href="https://cdn.yunyoujun.cn/img/donate/alipay-qrcode.jp p
g" target="_blank" style="color:#00A3EE"><img class="sponsor-method-img" border="~ rounded" p="1" loading="lazy" src="https://cdn.yunyoujun.cn/img/donate/alipay-qrcode.jpg" title="支 
付宝"><div text="xl" m="2" class="i-ri-alipay-line"></div></a><a class="flex-center flex-col animate-iteration-1 animate-fade-in" href="https://cdn.yunyoujun.cn/img/donate/qqpay-qrcod
e.png" target="_blank" style="color:#12B7F5"><img class="sponsor-method-img" border="~ rounded" p="1" loading="lazy" src="https://cdn.yunyoujun.cn/img/donate/qqpay-qrcode.png" title="
QQ 支付"><div text="xl" m="2" class="i-ri-qq-line"></div></a><a class="flex-center flex-col animate-iteration-1 animate-fade-in" href="https://cdn.yunyoujun.cn/img/donate/wechatpay-qr
code.jpg" target="_blank" style="color:#2DC100"><img class="sponsor-method-img" border="~ rounded" p="1" loading="lazy" src="https://cdn.yunyoujun.cn/img/donate/wechatpay-qrcode.jpg" 
title="微信支付"><div text="xl" m="2" class="i-ri-wechat-pay-line"></div></a><!--]--></div></div></div><ul class="post-copyright" m="y-4"><li class="post-copyright-author"><strong>本 
文作者:</strong><span>云游君</span></li><li class="post-copyright-link"><strong>本文链接:</strong><a href="https://valaxy.site/posts/hello-valaxy" target="_blank" title="本文链接">h
ttps://valaxy.site/posts/hello-valaxy</a></li><li class="post-copyright-license"><strong>版权声明:</strong><span>本博客所有文章除特别声明外,均默认采用 <a href="https://creativecommo
ns.org/licenses/by-nc-sa/4.0/deed.zh" target="_blank" rel="noopener" title="CC BY-NC-SA 4.0 ">CC BY-NC-SA</a> 许可协议。</span></li></ul><!--]--><!--]--><!--]--></div><!--]--><!----><
/div><!--[--><!--]--><!--[--><div class="post-nav"><div class="post-nav-item"><!----></div><div class="post-nav-item"><!----></div></div><!--]--><!--[--><!--]--><!----><!--[--><!--]--
><footer class="va-footer p-4 text-$va-c-text-light" text="center sm"><div class="beian" m="y-2"><a href="https://beian.miit.gov.cn/" target="_blank" rel="noopener">苏ICP备17038157号<
/a></div><div class="copyright flex justify-center items-center gap-2" p="1"><span> © <!--[-->2016 - <!--]--> 2023</span><a class="animate-pulse inline-flex" href="https://sponsors.yu
nyoujun.cn" target="_blank" title="Sponsor YunYouJun"><div class="i-ri-cloud-line"></div></a><span>云游君</span></div><div class="powered" m="2"><span>由 <a href="https://github.com/Y
unYouJun/valaxy" target="_blank" rel="noopener">Valaxy</a> v0.15.14 驱动</span> | <span>主题 - <a href="https://github.com/YunYouJun/valaxy/tree/main/packages/valaxy-theme-yun" title=
"valaxy-theme-yun" target="_blank">Yun</a> v0.15.14</span></div><!--[--><!--]--></footer><!--[--><!--]--></div><!--]--><!--[--><!--[--><button class="xl:hidden toc-btn shadow fixed yu
n-icon-btn z-350" opacity="75" right="2" bottom="19"><div i-ri-file-list-line></div></button><!----><!--  --><aside class="va-card yun-aside" m="l-4" text="center" overflow="auto"><di
v class="aside-container" flex="~ col"><h2 m="t-6 b-2" font="serif black">文章目录</h2><div style="display:none;" data-v-e110a38c><div class="content" data-v-e110a38c><div class="outl
ine-title" data-v-e110a38c>On this page</div><div class="outline-marker" data-v-e110a38c></div><nav aria-labelledby="doc-outline-aria-label" data-v-e110a38c><span id="doc-outline-aria
-label" class="visually-hidden" data-v-e110a38c> Table of Contents for current page </span><ul class="root va-toc relative z-1 css-i18n-toc" data-v-e110a38c data-v-590b49be><!--[--><!
--]--></ul></nav></div></div><div class="flex-grow"></div><div class="custom-container"><!--[--><!--]--></div></div></aside><!--]--><!--]--></div></main><a href="#" class="back-to-top
 yun-icon-btn"><div w="8" h="8" i-ri-arrow-up-s-line></div><svg class="progress-circle-container" viewBox="0 0 100 100"><circle stroke-dasharray="301.59289474462014 301.59289474462014
" stroke-dashoffset="301.59289474462014" class="progress-circle" cx="50" cy="50" r="48" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg></a><!--]--><!--]--></div>
<script>window.__INITIAL_STATE__="{\"pinia\":{\"app\":{\"showLoading\":true,\"isSidebarOpen\":false,\"isRightSidebarOpen\":false},\"site\":{}}}"</script>




<link rel="stylesheet" href="/assets/post-b195884f.css"><link rel="stylesheet" href="/assets/index-5ded91d4.css"><link rel="stylesheet" href="/assets/ValaxyMain-39dbe081.css"></body></html>
    at new HTMLParser (D:\MyTemp\GIT\valaxy\valaxy-blog\node_modules\.pnpm\[email protected]\node_modules\html-minifier\src\htmlparser.js:244:13)
    at minify (D:\MyTemp\GIT\valaxy\valaxy-blog\node_modules\.pnpm\[email protected]\node_modules\html-minifier\src\htmlminifier.js:980:3)
    at Module.exports.minify (D:\MyTemp\GIT\valaxy\valaxy-blog\node_modules\.pnpm\[email protected]\node_modules\html-minifier\src\htmlminifier.js:1341:16)
    at formatHtml (file:///D:/MyTemp/GIT/valaxy/valaxy-blog/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/vite-ssg/dist/node.mjs:1154:25)
    at async file:///D:/MyTemp/GIT/valaxy/valaxy-blog/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/vite-ssg/dist/node.mjs:1067:27
    at async file:///D:/MyTemp/GIT/valaxy/valaxy-blog/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/vite-ssg/dist/node.mjs:636:36
    at file:///D:/MyTemp/GIT/valaxy/valaxy-blog/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/vite-ssg/dist/node.mjs:1076:15   
    at async file:///D:/MyTemp/GIT/valaxy/valaxy-blog/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/vite-ssg/dist/node.mjs:636:36

Reproduction

如上所述

System Info

node: v16.17.1
system: win11
valaxy: 0.15.14

Used Package Manager

pnpm

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 self-assigned this Nov 18, 2023
@YunYouJun
Copy link
Owner

YunYouJun commented Dec 22, 2023

排查到了是 vite-ssg 的 bug。


renderHTML 中的 appHTML 包含特殊字符 $ 时,indexHTML.replace 会将其作为一种特殊的匹配模式。

`$``($后面跟着一个反引号):插入当前匹配的左边文本。

Specifying a string as the replacement

image

需要将其当作纯文本来替换。

解决方案时变成一个函数返回文本。

image

测试可构建成功。

@YunYouJun
Copy link
Owner

I create a PR for vite-ssg.

antfu-collective/vite-ssg#389

@YunYouJun YunYouJun added upstream bug Something isn't working labels Dec 23, 2023
@dbinfun
Copy link
Author

dbinfun commented Dec 24, 2023

我找到一个特别的解决方案,将半角的$符号使用全角的”$“符号代替就行,在人类看来是没有问题的。
Unicode编号 | U+FF04
HTML代码 | &#65284;

@YunYouJun
Copy link
Owner

可以先作为临时解决方案,等 vite-ssg 合并后,我升级一下依赖再彻底解决。

@MengNianxiaoyao
Copy link
Contributor

pr已经合并了

@YunYouJun
Copy link
Owner

Done. Released in v0.16.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream
Projects
None yet
Development

No branches or pull requests

3 participants