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

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

Open
rxliuli opened this issue Feb 3, 2020 · 21 comments
Open

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

rxliuli opened this issue Feb 3, 2020 · 21 comments

Comments

@rxliuli
Copy link
Contributor

rxliuli commented Feb 3, 2020

图解

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
Copy link
Contributor Author

rxliuli commented Feb 3, 2020

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

image

@blinkfox
Copy link
Owner

blinkfox commented Feb 4, 2020

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

@rxliuli
Copy link
Contributor Author

rxliuli commented Feb 4, 2020

下面这段代码

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
Copy link
Contributor Author

rxliuli commented Feb 4, 2020

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

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

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

@rxliuli
Copy link
Contributor Author

rxliuli commented Feb 4, 2020

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

@rxliuli
Copy link
Contributor Author

rxliuli commented Feb 4, 2020

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

image

@blinkfox
Copy link
Owner

blinkfox commented Feb 4, 2020

嗯,是有这个问题

@rxliuli
Copy link
Contributor Author

rxliuli commented Feb 4, 2020

嗯,是有这个问题

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

@AnthonySun256
Copy link

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

@rxliuli
Copy link
Contributor Author

rxliuli commented Feb 9, 2020

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

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

超级截屏_20200209_085654

@cszhengyh
Copy link

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

@rxliuli
Copy link
Contributor Author

rxliuli commented May 26, 2020

没,改成 jsx 了

@cszhengyh
Copy link

没,改成 jsx 了

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

@rxliuli
Copy link
Contributor Author

rxliuli commented May 26, 2020 via email

@cszhengyh
Copy link

就是改成 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
Copy link

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

@tianyichuxin
Copy link

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

@rxliuli
Copy link
Contributor Author

rxliuli commented Jun 4, 2020 via email

@tianyichuxin
Copy link

不支持 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
Copy link

不支持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
Copy link
Contributor Author

rxliuli commented Jun 4, 2020 via email

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

5 participants