azu / gitbook-plugin-include-codeblock

GitBook plugin for including file
Other
40 stars 25 forks source link

Highlight bug in language-detection for C++ codes #21

Closed gdolle closed 7 years ago

gdolle commented 8 years ago

It seems that code highlighting does not work with C++ files.

It seems the parse put c_cpp for lang instead of cpp.

// c_cpp example
int a;
// cpp example
int a;
azu commented 8 years ago

Intesting. https://github.com/blakeembrey/language-map/blob/b72edb8c2cb1b05d098782aa85dd2f573ed96ba3/languages.json#L431-L455 defined that the aceMode of .cpp file is c_cpp.

Which is correct value aliases or searchTerm? I don't know correct way...

gdolle commented 8 years ago

It should be cpp so one or another seems ok :)

gdolle commented 8 years ago

Hum actually, I maybe replied too fast. I'm not sure that aliases or searchTerm are better than aceMode if we look at the map for other languages.

Maybe we could just add a specific test for c++, and parse (remove) the lang like /c_cpp/cpp/g.

What do you think ?

azu commented 8 years ago

We use Linguist to perform language detection and syntax highlighting. You can find out which keywords are valid in the languages YAML file.

via Creating and highlighting code blocks - User Documentation

Maybe, correct algorithm is defined in github/linguist.

azu commented 8 years ago

Maybe we could just add a specific test for c++, and parse (remove) the lang like /c_cpp/cpp/g.

I want to avoid special case, but it is simple solution. I agree with @gdolle's suggestion that does /c_cpp/cpp/g.

gdolle commented 8 years ago

I agree with you @azu that it is just a workaround, it would be better to check github/linguist. It seems that currently, highlight.js is used with gitbook

azu commented 7 years ago

This is resolved by 2.2.0 and close it