gaearon / gitbook-plugin-prism

Gitbook plugin for Prism highlighting
Apache License 2.0
88 stars 26 forks source link

Failed to load prism syntax: objc #22

Closed prescottprue closed 7 years ago

prescottprue commented 7 years ago

Running v2.2.0 I receive the following error:

screen shot 2017-06-21 at 2 05 46 pm

I am in no way using or attempting to load objective c syntax highlighting. Is there a way to silence the warnings or not include objc?

robmcguinness commented 7 years ago

The error is being generated from this snippet:

      // Try and find the language definition in components folder
      if (!languages[lang]) {
        try {
          requireSyntax(lang);
        } catch (e) {
          console.warn('Failed to load prism syntax: ' + lang);
          console.warn(e);
        }
      }

Something is tripping up Gitbook where it's passing the wrong value in block.kwargs.language. Can you share a repo with the issue so that I can run?

prescottprue commented 7 years ago

The docs of react-redux-firebase are generated using gitbook, and it is where I am seeing the error.

If you pull and run npm run docs:build after npm installing, then you should see the error (where the picture I posted came from).

robmcguinness commented 7 years ago

I just cloned the repo and i see the following in docs/recipes/react-native.md:

  ```objc
  // add this line before @implementation AppDelegate
  #import <RNGoogleSignin/RNGoogleSignin.h>

  // add this method before @end
  - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
    sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {

    return [RNGoogleSignin application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
  }

Switching to objectivec fixes the issue. If you really want to use objc to highlight the code then create a map in the options:

pluginsConfig": {
  "prism": {
    "lang": {
      "objc": "objectivec"
    }
  }
}
prescottprue commented 7 years ago

Wow, I didn't even notice that in there 😑

Great to know about the lang mapping.

Thanks! Apologies for the false issue.

robmcguinness commented 7 years ago

No worries 😁