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

代码块中中文符号转译出的html装饰代码无法正确应用 #8

Open
lixiangwuxian opened this issue Apr 27, 2023 · 2 comments

Comments

@lixiangwuxian
Copy link

lixiangwuxian commented Apr 27, 2023

在代码块/行内代码等部分会对其中内容调用 escapeHtml(tokens[idx].content) 函数的部分,使用中文符号会导致转译出的html代码无法正确应用。

例如:原文为

	```
	int a,b;//定义a,b
	```

会变为

<div class="highlight"><pre class="code"><code><span class="hljs-type">int</span> a,b;//定义a&lt;span <span class="hljs-keyword">class</span>=&quot;bd-box&quot;&gt;&lt;h-<span class="hljs-type">char</span> <span class="hljs-keyword">class</span>=&quot;bd bd-beg&quot;&gt;&lt;h-<span class="hljs-keyword">inner</span>&gt;,&lt;/h-<span class="hljs-keyword">inner</span>&gt;&lt;/h-<span class="hljs-type">char</span>&gt;&lt;/span&gt;b
</code></pre></div>

目前个人临时的解决办法是将themes\mashiro\scripts\transpunc.js中关于替换content的部分注释掉,然后hexo clean。但是感觉可能还会有更好的方法

@bill-xia
Copy link
Owner

bill-xia commented May 4, 2023

抱歉,我最近有点忙,一直没有回复。这个地方实现得比较草率,为了标点挤压随便地实现了一下,很多边界条件没考虑到。如果要保持标点挤压,大概就需要重构代码了。

您的处理方法是可以的。也许可以做成主题配置的方式,不需要标点挤压的用户可以通过配置文件关闭这一功能。如果您有兴趣可以做一下,提个PR。

@lixiangwuxian
Copy link
Author

谢谢您的回复,我这边目前也在尝试修复这个功能,不过对hexo的实现还是不太熟,这部分还在摸索之中

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

No branches or pull requests

2 participants