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

有些代码不能被高亮是什么问题。。 #1710

Closed
netcan opened this issue Jan 10, 2016 · 9 comments
Closed

有些代码不能被高亮是什么问题。。 #1710

netcan opened this issue Jan 10, 2016 · 9 comments
Labels
bug Something isn't working highlight

Comments

@netcan
Copy link

netcan commented Jan 10, 2016

好像是某些特定的代码无法被高亮,我这里上传一个无法高亮的代码,请求测试。
我自己测试是第51行的锅,去掉后能高亮
ll ans = (sum(bit0, b) + b*sum(bit1, b)) - (sum(bit0, a-1) + (a-1)*sum(bit1, a-1));

/*************************************************************************
    > File Name: 3468_3.cpp
      > Author: Netcan
      > Blog: http://www.netcan666.com
      > Mail: [email protected]
      > Created Time: 2016-01-24 日 11:12:19 CST
 ************************************************************************/

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
const int MAXN = 100000+5;
typedef long long ll;
int A[MAXN];
ll bit0[MAXN], bit1[MAXN];
int N, Q;

void add(ll *bit, int i, int x) {
    while(i<=N) {
        bit[i] += x;
        i += i&-i;
    }
}

ll sum(ll *bit, int i) {
    ll res = 0;
    while(i) {
        res += bit[i];
        i -= i&-i;
    }
    return res;
}

void solve() {
    for (int i = 1; i <= N; ++i) add(bit0, i, A[i]);
    char op;
    int a, b, c;
    for (int i = 0; i < Q; ++i) {
        getchar();
        scanf("%c%d%d", &op, &a, &b);
        if(op == 'C') { // [a,b]区间+c
            scanf("%d", &c);
            add(bit0, a, -c*(a-1));
            add(bit1, a, c); // c*a-c*(a-1) = +c
            add(bit0, b+1, c*b);
            add(bit1, b+1, -c);
        }
        else {
            ll ans = (sum(bit0, b) + b*sum(bit1, b)) - (sum(bit0, a-1) + (a-1)*sum(bit1, a-1));
            printf("%lld\n", ans);
        }
    }

}

int main() {
#ifdef Oj
    freopen("3468.in", "r", stdin);
    // freopen("3468_3.out", "w",stdout);
#endif
    scanf("%d%d", &N, &Q);
    for (int i = 1; i <= N; ++i) scanf("%d", &A[i]);
    solve();
    return 0;
}
@tangleithu
Copy link

hexo支持的代码高亮不能解析用 ``` 的单行代码高亮么。

比如 print 'hello world!' inline的代码高亮。

github是支持的 比如这句 print 'hello world!'

@Xuanwo
Copy link
Contributor

Xuanwo commented Jan 28, 2016

单行不支持,这个取决于Hexo使用的渲染插件,目前官方默认的是marked引擎。

@Xuanwo
Copy link
Contributor

Xuanwo commented Jan 28, 2016

@netcan 收到,近期将会进行测试= =

@leesei
Copy link
Member

leesei commented Feb 19, 2016

所以是單行用 ``` 的問題嗎? 是的話就跟#1727 一樣close 掉了

@Xuanwo
Copy link
Contributor

Xuanwo commented Feb 19, 2016

@leesei 不是,这个issues的提出者与评论 #1710 (comment) 不是同一个问题。可能是Highlight.js对某些长句子的处理有BUG或者是Hexo在这个方面有点问题。

@leesei leesei added bug Something isn't working and removed question Needs help in usage labels Mar 7, 2016
@leesei
Copy link
Member

leesei commented Mar 7, 2016

The content of ln 51 is relevant. I think it is a bug of highlight.js
This is the reduced test case.

## Fail

```cpp
typedef long long ll;
ll ans = (sum(bit0, b) + b*sum(bit1, b)) - (sum(bit0, a-1) + (a-1)*sum(bit1, a-1));
```

```cpp
typedef long long ll;
ll ans = (sum(bit0, b) + b*sum(bit1, b));
```

## Success

```cpp
typedef long long ll;
ll ans = sum(bit0, b) + b*sum(bit1, b);
```

@leesei
Copy link
Member

leesei commented Mar 7, 2016

Issue opened highlightjs/highlight.js#1104

@netcan
Copy link
Author

netcan commented Mar 11, 2016

可以考虑换个渲染引擎供用户选择么?。。比如弄成插件形式

@leesei
Copy link
Member

leesei commented Apr 13, 2016

Highlight.js 9.3.0 fixed the original problem.
Clean node_modules and npm install to pick up the latest version.

Discuss using other highlight engine in this issue: #1300

@leesei leesei closed this as completed Apr 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working highlight
Projects
None yet
Development

No branches or pull requests

4 participants