bartc
bartc

Reputation: 324

Getting github to syntax highlight my files

github automaticall syntax highlights any code files such as those with .c extensions. And there seems plenty of information about controlling highlighting from within 'markdown' or .md files.

But how can I get it to highlight code files that it doesn't know about?

I can't even get the tabbing right - if I say 4-spaces tabs while editing, it goes back to 8-space ones when I've finished.

I don't care what highlighting style it uses even if it's the wrong language; it must be better than the plain text appearance which looks really flat. Oddly, when editing it uses some sort of highlighting, which again disappears when I've finished.

The files aren't in any well-known language so the highlighting won't be perfect; I just want a bit of colour. But I'd rather not change file extensions as that could be confusing.

Upvotes: 5

Views: 2154

Answers (1)

VonC
VonC

Reputation: 1323115

The tabbing is done through a ?t=4 parameter added to the GitHub url.

But the syntax highlighting (using Rouge on GitHub pages for instance) itself is either:


But how can I get it to highlight code files that it doesn't know about?

Update Feb. 2021 (5 years later)

Nat Friedman (CEO of GitHub) announces it on Twitter:

Another tiny but nice improvement we just shipped to GitHub – syntax highlighting now works on new files without the need to commit first.

Syntax Highlighting

Upvotes: 2

Related Questions