GithubHelp home page GithubHelp logo

Comments (4)

TokenPayId avatar TokenPayId commented on June 2, 2024

Describe the issue

Integer literals in C++ may be written as 1'000'000'000 instead of 1000000000 for greater readability. When this is used inside a #define, if breaks highlighting which treats the rest of the code as being inside a string.

Which language seems to have the issue?

cpp

Are you using highlight or highlightAuto?

highlight

Sample Code to Reproduce


#include <iostream>

#define INF 1'000'000'000



int main() {

	int a = INF;

    return 0;

}

image

Expected behavior

The token 1'000'000'000 should be highlighted as a number, and the following code should also be highlighted normally, instead of as if it is inside a string:

image

Additional context

The snippet below seems to be highlighted fine, so the issue is likely the interplay between quote-separated literals and defines.


#include <iostream>



int f(int x) { return f(2'000); }



int main() {

	int a = 1'000'000'000;

    int b = f(1'000);

    return null;

}

from highlight.js.

TokenPayId avatar TokenPayId commented on June 2, 2024

Describe the issue

Integer literals in C++ may be written as 1'000'000'000 instead of 1000000000 for greater readability. When this is used inside a #define, if breaks highlighting which treats the rest of the code as being inside a string.

Which language seems to have the issue?

cpp

Are you using highlight or highlightAuto?

highlight

Sample Code to Reproduce


#include <iostream>

#define INF 1'000'000'000



int main() {

	int a = INF;

    return 0;

}

image

Expected behavior

The token 1'000'000'000 should be highlighted as a number, and the following code should also be highlighted normally, instead of as if it is inside a string:

image

Additional context

The snippet below seems to be highlighted fine, so the issue is likely the interplay between quote-separated literals and defines.


#include <iostream>



int f(int x) { return f(2'000); }



int main() {

	int a = 1'000'000'000;

    int b = f(1'000);

    return null;

}

from highlight.js.

joshgoebel avatar joshgoebel commented on June 2, 2024

Can you confirm a fix: #3930

from highlight.js.

jureslak avatar jureslak commented on June 2, 2024

Looks great, thanks!

Before:

image

After:

image

from highlight.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.