Syntax highlighting for relative code files (Not Embedded ones)

Hi, I was just wondering whether there is a workaround to enable syntax highlighting for relative links that point to a code file in the repository.

For example, [foo](bar.cpp) should enable C++ syntax highlighting for bar.

I searched around and couldn’t really find anything. Just wanted to confirm with the community.

Thanks!

Hello @Just-A-Visitor, thanks for joining us.

If you’re talking about displaying code via GitHub Pages, you’re correct, there isn’t any built-in syntax highlighting support for full files. The way you linked to the source code file there, you’re essentially telling the browser to download it as a raw text file. What you could do instead is link to the source code file on GitHub itself via an absolute URL or there may be an extension for Jekyll (or whatever other static website generator you might be using) that would do this syntax highlighting work for you.

I hope that helps!

For anyone stumbling upon this topic in future, I found a chrome-extension to redirect code files automatically to Github.