Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Is there C-Language support ? #2460

Closed
hiromi3 opened this issue Mar 16, 2020 · 6 comments
Closed

Is there C-Language support ? #2460

hiromi3 opened this issue Mar 16, 2020 · 6 comments
Labels
enhancement An enhancement or new feature

Comments

@hiromi3
Copy link

hiromi3 commented Mar 16, 2020

Hello,
The highlight.js is very useful.
There is C++ support.
But, I want to use C-Language.
Do you have any plan to support it ?

@hiromi3 hiromi3 added the enhancement An enhancement or new feature label Mar 16, 2020
@joshgoebel
Copy link
Member

joshgoebel commented Mar 17, 2020

We're open to contributions here. The core team doesn't typically develop languages - that's left to the community (who often know the languages much better in any case). C is already built-in (as part of our C++ support)... but we're open to it be improved to be C specific, but someone would need to step forward to do the work, write the tests, etc.

Closing as a duplicate of #2146

Also worth noting, for many snippets the C++ highlighting works "just fine" when used on C code.

@joshgoebel
Copy link
Member

This is made more complex because preferably we'd like C and C++ to share a common foundation (they seem very similar parsing wise) where that make sense. So that takes some planning and thought. We don't just need a wholly separate C grammar.

@hiromi3
Copy link
Author

hiromi3 commented Mar 17, 2020

Thank you for your reply.
I could understand the situation.
So, I want to request you to add 'C-Language' class, but it acts same as 'cpp' class.
Currently, I can do as below.
<code class="cpp hljs">
But, in addition, I want to do as below.
<code class="C-language hljs">

The reason I want 'C-Language' class name is, I am using the class name string like 'cpp' in my JavaScript code.
When highlight.js detect the code as 'cpp', I am using the 'cpp' to add the title 'This is C++ sample code' above the code area.
But, hightlight.js has no 'C-Language' class, I can not distinguish C++ and C-Language.
Or, are there any other good solution?
I would appreciate your advice.

@joshgoebel
Copy link
Member

joshgoebel commented Mar 17, 2020

Our C language is just named c and already exists, but it has the exact same behavior as cpp. Auto-detect will always detect C code as C++ code though as there are currently no differences between them we let C++ win.

<code class="c hljs">

@hiromi3
Copy link
Author

hiromi3 commented Mar 17, 2020

Really?
It is a good news.
I will test it.

@hiromi3
Copy link
Author

hiromi3 commented Mar 17, 2020

It worked fine!
Thank you.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement An enhancement or new feature
Projects
None yet
Development

No branches or pull requests

2 participants