HolyC Syntax Highlighting? #10270

Closed
opened 2025-11-02 09:02:44 -06:00 by GiteaMirror · 14 comments
Owner

Originally created by @ghost on GitHub (Feb 14, 2023).

Feature Description

Would it be possible to get HolyC syntax highlighting for Gitea? I am working on a Git site dedicated around the language, but the fact that there is no syntax highlighting really takes away from the general aesthetic.

HolyC is really similar to C in terms of syntax except for really variables and function names. Below is a screenshot of said implementation on GitHub.

I understand this may be a very niche topic, and likely may not be added, however in that case, could I atleast be provided with documentation on writing the syntax highlighting manually? Thanks.

Screenshots

Screenshot_2023-02-14-04-34-09_1920x1080

Originally created by @ghost on GitHub (Feb 14, 2023). ### Feature Description Would it be possible to get HolyC syntax highlighting for Gitea? I am working on a Git site dedicated around the language, but the fact that there is no syntax highlighting really takes away from the general aesthetic. HolyC is really similar to C in terms of syntax except for really variables and function names. Below is a screenshot of said implementation on GitHub. I understand this may be a very niche topic, and likely may not be added, however in that case, could I atleast be provided with documentation on writing the syntax highlighting manually? Thanks. ### Screenshots ![Screenshot_2023-02-14-04-34-09_1920x1080](https://user-images.githubusercontent.com/96399844/218648555-94a1cf29-5d9d-47ef-9194-b26538c4afce.png)
GiteaMirror added the type/proposaltype/upstream labels 2025-11-02 09:02:44 -06:00
Author
Owner

@JakobDev commented on GitHub (Feb 14, 2023):

You might want to create a Issue for Chroma, which is the Syntax Highlighter used by Gitea. If you want it to do yourself, you can find the Lexer for C here. If you have good knowledge of the Syntax, you can create a Lexer for HolyC based on this and make a PR.

@JakobDev commented on GitHub (Feb 14, 2023): You might want to create a Issue for [Chroma](https://github.com/alecthomas/chroma), which is the Syntax Highlighter used by Gitea. If you want it to do yourself, you can find the Lexer for C [here](https://github.com/alecthomas/chroma/blob/1d0ed7f62a731c55beca0e609d4b0b28ad39e240/lexers/embedded/c.xml). If you have good knowledge of the Syntax, you can create a Lexer for HolyC based on this and make a PR.
Author
Owner

@wxiaoguang commented on GitHub (Feb 14, 2023):

Workaround: or use gitattributes to tell the highlighter that some files are C code. Like this one:

@wxiaoguang commented on GitHub (Feb 14, 2023): Workaround: or use gitattributes to tell the highlighter that some files are C code. Like this one: * https://github.com/go-gitea/gitea/issues/21970#issuecomment-1424879041
Author
Owner

@ghost commented on GitHub (Feb 14, 2023):

You might want to create a Issue for Chroma, which is the Syntax Highlighter used by Gitea. If you want it to do yourself, you can find the Lexer for C here. If you have good knowledge of the Syntax, you can create a Lexer for HolyC based on this and make a PR.

Ah my nightmare, Regex. I knew I'd have to learn it eventually. Honestly though, thank you so much for this, I don't think HolyC will be that hard to manufacture using this. Appreciate it.

@ghost commented on GitHub (Feb 14, 2023): > You might want to create a Issue for [Chroma](https://github.com/alecthomas/chroma), which is the Syntax Highlighter used by Gitea. If you want it to do yourself, you can find the Lexer for C [here](https://github.com/alecthomas/chroma/blob/1d0ed7f62a731c55beca0e609d4b0b28ad39e240/lexers/embedded/c.xml). If you have good knowledge of the Syntax, you can create a Lexer for HolyC based on this and make a PR. Ah my nightmare, Regex. I knew I'd have to learn it eventually. Honestly though, thank you so much for this, I don't think HolyC will be that hard to manufacture using this. Appreciate it.
Author
Owner

@silverwind commented on GitHub (Feb 14, 2023):

If it works with c syntax, you could contribute the addition of the file extension (assuming it has a unique one) to chroma's c lexer and gitea will then automatically pick it up based on the file extension after we update chroma.

@silverwind commented on GitHub (Feb 14, 2023): If it works with `c` syntax, you could contribute the addition of the file extension (assuming it has a unique one) to chroma's [`c lexer`](https://github.com/alecthomas/chroma/blob/master/lexers/embedded/c.xml) and gitea will then automatically pick it up based on the file extension after we update chroma.
Author
Owner

@silverwind commented on GitHub (Feb 14, 2023):

As per https://github.com/github/linguist/pull/4512, Github does match it based on the .hc extension, so unless this extension is already in use at Chroma somewhere else, it should be possible to get it added.

@silverwind commented on GitHub (Feb 14, 2023): As per https://github.com/github/linguist/pull/4512, Github does match it based on the `.hc` extension, so unless this extension is already in use at Chroma somewhere else, it should be possible to get it added.
Author
Owner

@ghost commented on GitHub (Feb 14, 2023):

Realistically, this looks like it should be a breeze to do considering it seems that the GitHub format is very similar to Chroma. From what @silverwind linked, I found this: https://github.com/codingdandy/holyc.tmbundle which should be sufficient.

@ghost commented on GitHub (Feb 14, 2023): Realistically, this looks like it should be a breeze to do considering it seems that the GitHub format is very similar to Chroma. From what @silverwind linked, I found this: [https://github.com/codingdandy/holyc.tmbundle]( https://github.com/codingdandy/holyc.tmbundle ) which should be sufficient.
Author
Owner

@silverwind commented on GitHub (Feb 14, 2023):

Yeah, so the job is to start with https://github.com/alecthomas/chroma/blob/master/lexers/embedded/c.xml and adapt the individual rules based on https://github.com/codingdandy/holyc.tmbundle/blob/master/Syntaxes/HolyC.tmLanguage to create the chroma lexer.

My earlier idea of just adding an alias to the C lexer is not right, the language is too different from C to be considered an alias.

@silverwind commented on GitHub (Feb 14, 2023): Yeah, so the job is to start with https://github.com/alecthomas/chroma/blob/master/lexers/embedded/c.xml and adapt the individual rules based on https://github.com/codingdandy/holyc.tmbundle/blob/master/Syntaxes/HolyC.tmLanguage to create the chroma lexer. My earlier idea of just adding an alias to the C lexer is not right, the language is too different from C to be considered an alias.
Author
Owner

@ghost commented on GitHub (Feb 15, 2023):

I've gone ahead and made a pull request for this on Chroma: https://github.com/alecthomas/chroma/pull/750

@ghost commented on GitHub (Feb 15, 2023): I've gone ahead and made a pull request for this on Chroma: [https://github.com/alecthomas/chroma/pull/750](https://github.com/alecthomas/chroma/pull/750)
Author
Owner

@silverwind commented on GitHub (Feb 15, 2023):

Thanks, so we just need to wait until next chroma release and then update it.

@silverwind commented on GitHub (Feb 15, 2023): Thanks, so we just need to wait until next chroma release and then update it.
Author
Owner

@ghost commented on GitHub (Feb 15, 2023):

Is that it @silverwind? I thought I had to edit "go-enry" or something

@ghost commented on GitHub (Feb 15, 2023): Is that it @silverwind? I thought I had to edit "go-enry" or something
Author
Owner

@silverwind commented on GitHub (Feb 16, 2023):

For the syntax highlighting, chroma is enough.

https://github.com/go-enry/go-enry is used for the language stats bar, but it may be that they already support HolyC given that they source some data from linguist, but if you like, please double-check.

@silverwind commented on GitHub (Feb 16, 2023): For the syntax highlighting, chroma is enough. https://github.com/go-enry/go-enry is used for the language stats bar, but it may be that they already support HolyC given that they source some data from linguist, but if you like, please double-check.
Author
Owner

@ghost commented on GitHub (Feb 17, 2023):

For the syntax highlighting, chroma is enough.

https://github.com/go-enry/go-enry is used for the language stats bar, but it may be that they already support HolyC given that they source some data from linguist, but if you like, please double-check.
Alrighty, looks like HolyC is already there. Is there any way to force my gitea build to use the latest of Chroma, not the latest version since my PR wasn't packaged but instead the branch?

Well I'm not sure if that worked, I figured I could do:

go get -u github.com/alecthomas/chroma
go mod tidy
TAGS="bindata sqlite sqlite_unlock_notify" make build

However on a repo it's still recoginzed as "PlainText":
Git
I'm not sure if I was unable to get the latest commit, or if my additions dont work.

@ghost commented on GitHub (Feb 17, 2023): > For the syntax highlighting, chroma is enough. > > https://github.com/go-enry/go-enry is used for the language stats bar, but it may be that they already support HolyC given that they source some data from linguist, but if you like, please double-check. Alrighty, looks like HolyC is already there. Is there any way to force my gitea build to use the latest of Chroma, not the latest version since my PR wasn't packaged but instead the branch? Well I'm not sure if that worked, I figured I could do: ``` go get -u github.com/alecthomas/chroma go mod tidy TAGS="bindata sqlite sqlite_unlock_notify" make build ``` However on a repo it's still recoginzed as "PlainText": ![Git](https://i.imgur.com/Eu8asy8.png) I'm not sure if I was unable to get the latest commit, or if my additions dont work.
Author
Owner

@silverwind commented on GitHub (Feb 17, 2023):

Try:

go get -u github.com/alecthomas/chroma/v2@3ac94eea73f5de1bf6c864b9a7f4089514415090
@silverwind commented on GitHub (Feb 17, 2023): Try: ``` go get -u github.com/alecthomas/chroma/v2@3ac94eea73f5de1bf6c864b9a7f4089514415090 ```
Author
Owner

@ghost commented on GitHub (Feb 19, 2023):

That worked! Thanks all!

@ghost commented on GitHub (Feb 19, 2023): That worked! Thanks all!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#10270