blinkfox / hexo-theme-matery

A beautiful hexo blog theme with material design and responsive design.一个基于材料设计和响应式设计而成的全面、美观的Hexo主题。国内访问:http://blinkfox.com
https://blinkfox.github.io/
Apache License 2.0
5.23k stars 1.25k forks source link

代码高亮行号与代码分成了两栏 #304

Open rxliuli opened 4 years ago

rxliuli commented 4 years ago

图解

image

发生问题的仓库: https://github.com/rxliuli/blog

配置项

highlight:
  enable: false
  line_number: true
  auto_detect: false
  tab_replace:

# 替换 hexo 默认的代码高亮
prism_plugin:
  mode: 'preprocess' # realtime/preprocess
  theme: 'tomorrow'
  line_number: true # default false
  custom_css:

不知道发生了什么,有什么解决方案么?

rxliuli commented 4 years ago

实测了一下,是因为不支持 tsx 的语法高亮时默认将之当成了普通的 markdown 中的 HTML(默认不应该当作文本么?)

image

blinkfox commented 4 years ago

不应该吧,我看看你的文档中的代码怎么写的。

rxliuli commented 4 years ago

下面这段代码

import React, { Component } from 'react'

class HelloWorld extends Component {
  logMsg = () => {
    console.log('msg')
  }
  render() {
    return (
      <div>
        <h1>hello world</h1>
        <button onClick={this.logMsg}>打印</button>
      </div>
    )
  }
}

export default HelloWorld

将语言标识修改为 tsx 就可以看到问题了

rxliuli commented 4 years ago

不应该吧,我看看你的文档中的代码怎么写的。

现在吾辈是修改为 jsx 标识并且去掉了行号才看来其没有问题的。。。

具体文章:https://blog.rxliuli.com/p/b6a3c3df/

rxliuli commented 4 years ago

prism 本身确认支持 tsx,但插件是两年前最后一次更新的,所以。。。#无语

rxliuli commented 4 years ago

而且因为被当成 HTML 渲染行号也对不上。。。

image

blinkfox commented 4 years ago

嗯,是有这个问题

rxliuli commented 4 years ago

嗯,是有这个问题

我看那个库也只有一个文件,如果作者一直不修复的话,可以直接内嵌到这个项目里

AnthonySun256 commented 4 years ago

https://godweiyang.com/2018/04/13/hexo-blog/#toc-heading-14 这篇文章后半部分有解决方法

rxliuli commented 4 years ago

https://godweiyang.com/2018/04/13/hexo-blog/#toc-heading-14 这篇文章后半部分有解决方法

很遗憾,这个博客的代码高亮本身就有问题

超级截屏_20200209_085654

cszhengyh commented 4 years ago

请问您解决这个问题了吗 我也遇到了

rxliuli commented 4 years ago

没,改成 jsx 了

cszhengyh commented 4 years ago

没,改成 jsx 了

这个怎么改的 您写了博客记录吗?

rxliuli commented 4 years ago

就是改成 jsx 语言标识了啊,在 markdown 源文件里

swust-zyh notifications@github.com 于 2020年5月26日周二 下午12:31写道:

没,改成 jsx 了

这个怎么改的 您写了博客记录吗?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/blinkfox/hexo-theme-matery/issues/304#issuecomment-633802152, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF3MF4FKMPU4464GU2TDBXTRTNA37ANCNFSM4KPFZCTQ .

cszhengyh commented 4 years ago

就是改成 jsx 语言标识了啊,在 markdown 源文件里 swust-zyh notifications@github.com 于 2020年5月26日周二 下午12:31写道: 没,改成 jsx 了 这个怎么改的 您写了博客记录吗? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#304 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF3MF4FKMPU4464GU2TDBXTRTNA37ANCNFSM4KPFZCTQ .

就是改成 jsx 语言标识了啊,在 markdown 源文件里 swust-zyh notifications@github.com 于 2020年5月26日周二 下午12:31写道: 没,改成 jsx 了 这个怎么改的 您写了博客记录吗? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#304 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF3MF4FKMPU4464GU2TDBXTRTNA37ANCNFSM4KPFZCTQ .

ok

cszhengyh commented 4 years ago

https://godweiyang.com/2018/04/13/hexo-blog/#toc-heading-14 这篇文章后半部分有解决方法 解决不了我 尝试了

tianyichuxin commented 4 years ago

我一开始的情况和楼主一样,后来我在源码里添加了jsx,正常了,去掉jsx,也正常了,我懵逼了,不是缓存的问题

rxliuli commented 4 years ago

不支持 tsx

tianyichuxin notifications@github.com 于 2020年6月4日周四 下午6:14写道:

我一开始的情况和楼主一样,后来我在源码里添加了jsx,正常了,去掉jsx,也正常了,我懵逼了,不是缓存的问题

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/blinkfox/hexo-theme-matery/issues/304#issuecomment-638757482, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF3MF4AHE6XQEY5OLUCUWO3RU5XYZANCNFSM4KPFZCTQ .

tianyichuxin commented 4 years ago

不支持 tsx tianyichuxin notifications@github.com 于 2020年6月4日周四 下午6:14写道: 我一开始的情况和楼主一样,后来我在源码里添加了jsx,正常了,去掉jsx,也正常了,我懵逼了,不是缓存的问题 — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#304 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF3MF4AHE6XQEY5OLUCUWO3RU5XYZANCNFSM4KPFZCTQ .

我内容里一开始只是js,后来把js改完jsx,就没问题了,重点来了,我又改为js,没有用tsx,而且正常了,而且是所有有问题的页面都正常了

tianyichuxin commented 4 years ago

不支持tsx tianyichuxin notifications@github.com 于2020年6月4日周四下午6:14写道: 我一开始的情况和楼主一样,后来我在源码里添加了jsx,正常了,去掉jsx,也正常了,我懵逼了,不是缓存的问题— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub < #304 (comment) >, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AF3MF4AHE6XQEY5OLUCUWO3RU5XYZANCNFSM4KPFZCTQ > .

还有一个问题,就是你的右上角的关闭和复制有没有问题?我这边不能复制和关闭

rxliuli commented 4 years ago

这个倒没有

tianyichuxin notifications@github.com 于 2020年6月5日周五 上午12:23写道:

不支持tsx tianyichuxin notifications@github.com 于2020年6月4日周四下午6:14写道: … <#m2711425554499153291> 我一开始的情况和楼主一样,后来我在源码里添加了jsx,正常了,去掉jsx,也正常了,我懵逼了,不是缓存的问题— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub < #304 (comment) https://github.com/blinkfox/hexo-theme-matery/issues/304#issuecomment-638757482

, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AF3MF4AHE6XQEY5OLUCUWO3RU5XYZANCNFSM4KPFZCTQ .

还有一个问题,就是你的右上角的关闭和复制有没有问题?我这边不能复制和关闭

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/blinkfox/hexo-theme-matery/issues/304#issuecomment-638962461, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF3MF4D5OOUUUFJJLR5RM5LRU7C65ANCNFSM4KPFZCTQ .