A recent commit to my repository makes the code for one of the .m files look like regular plain text (snippet image below) – no colored keywords or anything. The other .m files previews look normal though. I can't see any noticeable difference between the file with the non colored preview and the other ones. This is kind of inconvenient as scanning the code preview on GitHub is less efficient without the colors. I tried making pushing again and it's the same. Is there a way to fix this?
Go to any GitHub repository and then press the dot key on your keyboard. Visual Studio Code will appear in your browser. It will load your entire repository and you can open any file from it. You have your entire source code with syntax highlighting and coloring.
Press Y to permalink to a file in a specific commit This will permanently link to the exact version of the file in that commit. For example: https://github.com/github/codeql/blob/b212af08a6cffbb434f3c8a2795a579e092792fd/README.md.
This is most likely caused by linguist (the software used on GitHub to guess the code's language to use for highlighting) miss-guessing the language for this file.
The .m
extension is used by various other languages besides MATLAB (Mathematica and ObjectiveC, I believe). If linguist guesses wrong, then the highlighting used is wrong.
To tell GitHub what language your code is, add a .gitattributes
file to the root of your repository, and in this file add a line like this:
src/*.m linguist-language=matlab
(replace src/*.m
with whatever you need to match the names of your MATLAB M-files).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With