1.0.0 • Published 5 months ago
highlight-hcl v1.0.0
Highlight HCL
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.
Installation
Using npm to download the library.
npm install highlight.js highlight-hcl
Importing the Library
To use the HCL definition with highlight.js, you have two options for importing:
Optimized Import (Recommended)
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);
Full Import
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.