Skip to content

Instantly share code, notes, and snippets.

@mbbroberg
Last active April 29, 2019 22:10
Show Gist options
  • Save mbbroberg/037f8d9d4684d5995bd68eb8e165ccfd to your computer and use it in GitHub Desktop.
Save mbbroberg/037f8d9d4684d5995bd68eb8e165ccfd to your computer and use it in GitHub Desktop.

You can also have language-specific syntax highlighting. Instead of having a code block of black-and-white text, append the language to the first set of backticks to have highlighting enabled:

<html>
<head>
  <meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
</head>
<body>
  <script src='./pkg/my_wasm_library.js'></script>
  <script>
    window.addEventListener('load', async () => {
      // Load the wasm file
      await wasm_bindgen('./pkg/my_wasm_library_bg.wasm');
      // Once it's loaded the `wasm_bindgen` object is populated
      // with the functions defined in our Rust code
      const greeting = wasm_bindgen.excited_greeting("Matt")
      console.log(greeting)
    });
  </script>
</body>
</html>

Nearly all programming languages are supported using this syntax (python, ruby, go, rust, javascript, and java to name a few). See GitHub's documentation for the full list: https://help.github.com/en/articles/creating-and-highlighting-code-blocks#syntax-highlighting

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