-
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, I searched around and couldn’t really find anything. Just wanted to confirm with the community. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
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! |
Beta Was this translation helpful? Give feedback.
-
For anyone stumbling upon this topic in future, I found a chrome-extension to redirect code files automatically to Github. |
Beta Was this translation helpful? Give feedback.
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!