Closed cryptiklemur closed 4 years ago
Hi, we accept language contributions from the community, but don’t generally write them ourselves. Would this be something the hcl community would be willing to create and maintain?
So far, I've been using the Ruby highlighter for HCL, but a dedicated language would be better of course.
I recently opened a PR (#2076) with a language file for github workflows, which I've just learnt are based upon HCL. I've found a vim syntax file here for HCL, and it seems relatively simple. I could update my PR to cover HCL with workflow
as an alternative name.
If languages are now being split into their own repositories, I'd be happy to maintain this one. Thoughts?
@qubyte, sorry for the delay. That would be amazing. I'll set a repo for gh-workflow for you. We have a terraform language definition in a repo already... is it the same language as this one?
Here is the link to the terraform one: http://github.com/highlightjs/highlight-terraform/ if it's the same, I can add you as a collaborator to that one.
It appears to be the same! I didn't realise this existed :D
heh, that's my fault for not keeping docs up to date 🤪 Added you to that one too. The nice thing about the terraform repo is that is has tests already. You can probably copy/paste what's there and adapt it.
It may be that these can be added as aliases. The terraform one should probably (though I'd need to take a closer look) be called HCL, since HCL is the language whereas terraform, github workflow etc. are use cases.
Could be... I honestly don't know as I've not looked at the languages.
Is the terraform definition currently bundled with highlight.js? How does that work?
Is the terraform definition currently bundled with highlight.js?
No, a consumer needs to npm install
it.
How does that work?
Then they can, for example:
hljs.registerLanguage('customLanguage', customLanguage);
Then they can create a custom build, for example: https://github.com/w3c/respec-hljs
The bundle is great, because it only includes the the languages the project needs.
I see! Is the long-term plan to split all the languages out and always manually include them, or something midway with a set of default languages bundled (just asking out of curiosity now)?
I see! Is the long-term plan to split all the languages out and always manually include them, or something midway with a set of default languages bundled (just asking out of curiosity now)?
We will keep the current "core" set as to not break existing functionality, and split out all new ones.
We will keep the current "core" set as to not break existing functionality, and split out all new ones.
Actually if we thought of a way to package multiple languages you could do something like separate the whole Highlight.js codebase from the languages... and then you just install "highlightjs-core-languages"... and then the core languages are "just another language pack".
Something to think about perhaps once we figure out tooling for all this. :)
In regard to "don't break existing functionality" I think the key concerns are (correct me if I'm mistaken):
I don't think any of those goals necessarily 100% requires the languages live in the same repo as the highlighter itself forever. Just food for thought.
Is HCL still separate and this is still and open request or can this be closed now that we have the teraform repo?
It would be helpful to provide a usage example in the repo on how to apply the syntax.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Test</title>
<script type="text/javascript" src="highlight.pack.js"></script>
<script type="text/javascript" src="highlightjs-terraform/terraform.js"></script>
<script type="text/javascript">
hljs.registerLanguage('terraform', window.hljsDefineTerraform);
hljs.initHighlightingOnLoad();
</script>
</head>
<body>
<pre><code class="tf">provider "azure" {
arm_endpoint = ""
subscription_id = ""
client_id = ""
client_secret = ""
tenant_id = ""
}
</code></pre>
</body>
</html>
The highlighting doesn't work. Can anybody spot the mistake I am making?
Looks decent to me, any errors in console log?
Looks decent to me, any errors in console log?
Not that I can see, I have tried in Firefox and Chrome.
It looks like hightlightjs is working but there is no colour on the html page. 😞
EDIT: I am going to try the process here: https://highlightjs.readthedocs.io/en/latest/building-testing.html#building
Sounds like a css issue.
Sounds like a css issue.
Wow I feel pretty stupid... Added a style.css file and it's working 😆. Thanks!
Any reason why https://github.com/highlightjs/highlightjs-terraform is not available on npm/yarn/etc ?
This project is currently in need of a maintainer.
No one to do it?
https://github.com/hashicorp/hcl