Highlight HashiCorp configuration language (HCL) with highlight.js. You can use this library to highlight Terraform, OpenTofu, and Packer.
You can see the highlight results here.
Using npm to download the library.
npm install highlight.js highlight-hclTo use the HCL definition with highlight.js, you have two options for importing:
Load only the language definitions you need.
// import core hljs api and required languages
import hljs from 'highlight.js/lib/core';
import hcl from 'highlight-hcl';
// register language definition
hljs.registerLanguage('hcl', hcl);Load all languages of highlight.js, please note that this generates a large file.
import hljs from 'highlight.js';
import hcl from 'highlight-hcl';
hljs.registerLanguage('hcl', hcl);More information about importing highlight.js library, please refer to here.