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

代码高亮问题 #270

Closed
EnderturtleOrz opened this issue Apr 13, 2020 · 11 comments
Closed

代码高亮问题 #270

EnderturtleOrz opened this issue Apr 13, 2020 · 11 comments
Labels

Comments

@EnderturtleOrz
Copy link

@EnderturtleOrz EnderturtleOrz commented Apr 13, 2020

我原本valine版本1.3.4在评论区代码高亮正常,

现在升级到1.4.4后代码高亮不显示,与hljs冲突。

具体而言1.4.4后html代码如下:

<code class="language-cpp hljs">
     <span style="color: #23AC69">
               <span class="hljs-keyword">
                      <span class="hljs-keyword">int</span>
               </span>
      </span>
</code>

从而代码不高亮,请问一下有没有解决方案。

@xCss
Copy link
Owner

@xCss xCss commented Apr 13, 2020

这是因为你的页面加引入了highlightjs

建议你初始化Valine的时候设置代码高亮关闭试试:

new Valine({
   // ...
   highlight: false
})

@EnderturtleOrz
Copy link
Author

@EnderturtleOrz EnderturtleOrz commented Apr 13, 2020

非常感谢作者大大的回复,我尝试关闭highligt后,渲染框架是正常的,但是这层颜色渲染好像被valine的默认配色覆盖了,仍然没有高亮,请问一下如何解决。(另:我蛮好奇为啥1.3.4版本不会引起冲突

@xCss
Copy link
Owner

@xCss xCss commented Apr 13, 2020

因为在1.3.4的时候,没有正确检测highlightjs,造成渲染失败,所以使用的是Valine自带的高亮模块。

在1.4.x版本更改了检测方式,能够正确检测是否已加载highlightjs


刚刚看了下,颜色被覆盖是属于ValineBug,将在下个版本中修复,感谢你的反馈~~

@xCss xCss added the bug label Apr 13, 2020
@EnderturtleOrz
Copy link
Author

@EnderturtleOrz EnderturtleOrz commented Apr 15, 2020

我发现了新的问题了,不知道是不是和这个一样的问题。我如果一个页面有hljs渲染的代码框,在有valine评论的情况下高亮会消失,就拿我自己的博客举例:

有valine的评论

无valine的评论

@xCss
Copy link
Owner

@xCss xCss commented Apr 16, 2020

@HTC-Group 刚看了下,发现并不是Valine的样式影响,而有点像是受hljs代码块注释样式影响。

目前看来应该是Valine检测并调用hljs造成代码块样式重绘,覆盖了原有正确样式,这个我需要重新测试下,尽量在新版本中解决该问题~

感谢反馈

@EnderturtleOrz
Copy link
Author

@EnderturtleOrz EnderturtleOrz commented Apr 16, 2020

我也觉得是hljs-comment的影响,不知道有没有解决方案,仍然是以前版本的valine不受影响,这个版本我也把highlight改成false了。

@xCss
Copy link
Owner

@xCss xCss commented Apr 21, 2020

@HTC-Group 试下试下,新版发布了,理论上解决了这个问题~

@EnderturtleOrz
Copy link
Author

@EnderturtleOrz EnderturtleOrz commented Apr 21, 2020

@xCss 啊,非常感谢作者大大付出,我恰完饭试一下实装

@EnderturtleOrz
Copy link
Author

@EnderturtleOrz EnderturtleOrz commented Apr 21, 2020

@xCss emmm,我实装之后评论区代码高亮已经没有问题了,但还是只要有评论,文章里的高亮还是会消失,请问一下如何解决

@EnderturtleOrz
Copy link
Author

@EnderturtleOrz EnderturtleOrz commented Apr 22, 2020

1.4.6已修好,谢谢作者的肝

@xCss
Copy link
Owner

@xCss xCss commented Apr 22, 2020

image

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

No branches or pull requests

2 participants