Skip to content

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

Closed

Description

@gdolle

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;

Activity

  1. azu commented on May 8, 2016

    @azu
    Owner

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

    • export function lookupLanguageByExtension(ext) {
      let aceMode;
      Object.keys(language_map).some(langKey => {
      const extensions = language_map[langKey]["extensions"];
      /* TODO: These lang has not extensions
      Ant Build System
      Isabelle ROOT
      Maven POMAnt Build System
      */
      if (!extensions) {
      return false;
      }
      return extensions.some(extension => {
      if (ext === extension) {
      aceMode = language_map[langKey]["aceMode"];
      }
      });
      });
      return aceMode;
      }
      look up the aceMode.

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

  2. gdolle commented on May 8, 2016

    @gdolle
    ContributorAuthor

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

  3. gdolle commented on May 8, 2016

    @gdolle
    ContributorAuthor

    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 ?

  4. azu commented on May 8, 2016

    @azu
    Owner

    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.

  5. azu commented on May 8, 2016

    @azu
    Owner

    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.

  6. gdolle commented on May 8, 2016

    @gdolle
    ContributorAuthor

    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

  7. added a commit that references this issue on Jan 5, 2017
  8. added a commit that references this issue on Jan 6, 2017
  9. azu commented on Jan 6, 2017

    @azu
    Owner

    This is resolved by 2.2.0 and close it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions