Kousha Kousha - 1 year ago 121
React JSX Question

GitHub Code highlighting for React file with js extension

If you create a React file but save it with

extension, then GitHub code highlighting breaks when it reaches a single quote in text. Saving the same file in
works fine.

See example on this repo. Both file
have the same content. As you can, the
has wrong syntax highlighting.

Is there anyway to fix this, while still using

Answer Source

A somewhat cumbersome solution based on the Linguist readme is to add a vim or emacs modeline to the file. Appears you can add it within a JS comment to keep your source valid while maintaining correct syntax formatting on GH.


// vim: syntax=JSX
import React from 'react';

export default class MyClass extends React.Component {
  render() {
    return (
      <a href="google.com">Let's head to google.com</a>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download