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

if set hljs to true in hexo config, it will cause some Tag Plugins no rendering #4317

Closed
5 tasks done
jerryc127 opened this issue May 17, 2020 · 5 comments · Fixed by #4358
Closed
5 tasks done

if set hljs to true in hexo config, it will cause some Tag Plugins no rendering #4317

jerryc127 opened this issue May 17, 2020 · 5 comments · Fixed by #4358
Labels
bug Something isn't working
Milestone

Comments

@jerryc127
Copy link

Check List

Please check followings before submitting a new issue.

  • I have already read Docs page & Troubleshooting page
  • I have already searched existing issues and they are not help to me
  • I examined error or warning messages and it's difficult to solve
  • Using the latest version of Hexo (run hexo version to check)
  • Node.js is higher than 8.6.0

Expected behavior

Actual behavior

How to reproduce?

  • Step1
  • Step2
  • etc...

Environment & Settings

Node.js & npm version

Your site _config.yml (Optional)

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

Your theme _config.yml (Optional)

Hexo and Plugin version(npm ls --depth 0)

+-- @babel/core@7.9.6
+-- @babel/preset-env@7.9.6
+-- eslint@6.8.0
+-- eslint-config-standard@14.1.1
+-- eslint-plugin-import@2.20.2
+-- eslint-plugin-node@11.1.0
+-- eslint-plugin-promise@4.2.1
+-- eslint-plugin-standard@4.0.1
+-- gulp@4.0.2
+-- gulp-babel@8.0.0
+-- gulp-clean-css@4.3.0
+-- gulp-htmlclean@2.7.22
+-- gulp-htmlmin@5.0.1
+-- gulp-imagemin@7.1.0
+-- gulp-uglify@3.0.2
+-- hexo@4.2.0
+-- hexo-abbrlink@2.0.5
+-- hexo-deployer-git@2.1.0
+-- hexo-douban@1.1.3
+-- hexo-generator-archive@1.0.0
+-- hexo-generator-category@1.0.0
+-- hexo-generator-feed@2.2.0
+-- hexo-generator-index@1.0.0
+-- hexo-generator-search@2.4.0
+-- hexo-generator-tag@1.0.0
+-- hexo-renderer-ejs@1.0.0
+-- hexo-renderer-marked@2.0.0
+-- hexo-renderer-pug@1.0.0
+-- hexo-renderer-stylus@1.1.0
+-- hexo-server@1.0.0
+-- hexo-tag-aplayer@3.0.4
+-- hexo-wordcount@6.0.1
`-- terser@4.6.11

Your package.json package.json

Others

When set hljs to false , it will show correct

image

but when set it to true
image

markdown

 ```markdown
<div class="btn-center">
{% btn 'http://www.jerryc.me',JerryC,far fa-hand-point-right,larger %}
{% btn 'http://www.jerryc.me',JerryC,far fa-hand-point-right,blue larger %}
{% btn 'http://www.jerryc.me',JerryC,far fa-hand-point-right,pink larger %}
{% btn 'http://www.jerryc.me',JerryC,far fa-hand-point-right,red larger %}
{% btn 'http://www.jerryc.me',JerryC,far fa-hand-point-right,purple larger %}
{% btn 'http://www.jerryc.me',JerryC,far fa-hand-point-right,orange larger %}
{% btn 'http://www.jerryc.me',JerryC,far fa-hand-point-right,green larger %}
</div>
  ```

<div class="btn-center">
{% btn 'http://www.jerryc.me',JerryC,far fa-hand-point-right,larger %}
{% btn 'http://www.jerryc.me',JerryC,far fa-hand-point-right,blue larger %}
{% btn 'http://www.jerryc.me',JerryC,far fa-hand-point-right,pink larger %}
{% btn 'http://www.jerryc.me',JerryC,far fa-hand-point-right,red larger %}
{% btn 'http://www.jerryc.me',JerryC,far fa-hand-point-right,purple larger %}
{% btn 'http://www.jerryc.me',JerryC,far fa-hand-point-right,orange larger %}
{% btn 'http://www.jerryc.me',JerryC,far fa-hand-point-right,green larger %}
</div>

```markdown
<div class="btn-center">
{% btn 'http://www.jerryc.me',JerryC,far fa-hand-point-right,outline larger %}
{% btn 'http://www.jerryc.me',JerryC,far fa-hand-point-right,outline blue larger %}
{% btn 'http://www.jerryc.me',JerryC,far fa-hand-point-right,outline pink larger %}
{% btn 'http://www.jerryc.me',JerryC,far fa-hand-point-right,outline red larger %}
{% btn 'http://www.jerryc.me',JerryC,far fa-hand-point-right,outline purple larger %}
{% btn 'http://www.jerryc.me',JerryC,far fa-hand-point-right,outline orange larger %}
{% btn 'http://www.jerryc.me',JerryC,far fa-hand-point-right,outline green larger %}
</div>
```

<div class="btn-center">
{% btn 'http://www.jerryc.me',JerryC,far fa-hand-point-right,outline larger %}
{% btn 'http://www.jerryc.me',JerryC,far fa-hand-point-right,outline blue larger %}
{% btn 'http://www.jerryc.me',JerryC,far fa-hand-point-right,outline pink larger %}
{% btn 'http://www.jerryc.me',JerryC,far fa-hand-point-right,outline red larger %}
{% btn 'http://www.jerryc.me',JerryC,far fa-hand-point-right,outline purple larger %}
{% btn 'http://www.jerryc.me',JerryC,far fa-hand-point-right,outline orange larger %}
{% btn 'http://www.jerryc.me',JerryC,far fa-hand-point-right,outline green larger %}
</div>

button.js

/**
 * Button
 * {% btn url text icon option %}
 * option: color outline center block larger
 * color : default/blue/pink/red/purple/orange/green
 */

'use strict'

const urlFor = require('hexo-util').url_for.bind(hexo)

function btn (args) {
  args = args.join(' ').split(',')
  var url = args[0] || ''
  var text = args[1] || ''
  var icon = args[2] || ''
  var option = args[3] || ''

  url = url.trim()
  text = text.trim()
  icon = icon.trim()
  option = option.trim()

  return `<a class="btn-beautify button--primary button--animated ${option}" href="${urlFor(url)}" title="${text}">
  ${icon.length > 0 ? `<i class="${icon} fa-fw"></i>` : ''} ${text} </a>`
}

hexo.extend.tag.register('btn', btn, { ends: false })
@SukkaW
Copy link
Member

SukkaW commented May 18, 2020

It appears to be fixed in #4161 by @stevenjoezhang

I will add a test case to confirm if the issue has been fixed in coming hexo@5.

@stevenjoezhang
Copy link
Member

The rendering result is affected by highlight.enable option

Test cases:

```sh
echo "Hi"
```

{% post_link 'Hello World' "custom text here" %}

```sh
echo "Hi"
```

{% post_link 'Hello World' "custom text here" %}

```sh
echo "Hi"
```

@jerryc127
Copy link
Author

不知問題 修復了沒
今天把hljs设为true之后,发现报错了
image

定位到是一篇文章md有问题
然而我查了也没发现问题在哪
因为当hljs设为false时,这篇文章是能正常编译的。。

@SukkaW
Copy link
Member

SukkaW commented Jun 15, 2020

@jerryc127 Could be fixed in coming hexo@5.

The replated test case will be added.


Update

@jerryc127 The bug is now confirmed. Will be fixed by #4358.

SukkaW added a commit to SukkaW/hexo that referenced this issue Jun 15, 2020
@SukkaW SukkaW added bug Something isn't working and removed need-investigation labels Jun 15, 2020
@jerryc127
Copy link
Author

我把你改的那句正则复制到我的hexo对应的位置
运行不会报错了。。

good job

SukkaW added a commit that referenced this issue Jun 15, 2020
* fix(#4317): non-greedy regexp for tag escape
* test(post): reset highlight status
@SukkaW SukkaW added this to the 5.0.0 milestone Jun 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants