IBM / marked-it-cli

marked-it-cli
MIT License
5 stars 15 forks source link

Add support for highlight.js terraform syntax highlighting #13

Closed cjcarpen closed 3 years ago

cjcarpen commented 3 years ago

Extend the highlight.js syntax highlighting by adding support for the terraform package: https://github.com/highlightjs/highlightjs-terraform

grant-g commented 3 years ago

Unfortunately it's not available in npmjs, so baking the support in would require shipping the highlightjs-terraform. Not sure if this is a problem or not, but would prefer to avoid doing this.

So for now at least the solution is to add support for this via an extension like the one attached here. So just unzip this somewhere and add a --extension-file command-line arg that points at its terraformExt.js. terraform.zip

grant-g commented 3 years ago

The solution in my previous comment doesn't work in the case of the extension not residing within marked-it-cli's directory hierarchy. I've fixed this case by defining a proper extension point in marked-it-cli for extensions to provide syntax styling functions.

To make this work, get the marked-it-cli 0.23.0 release, and replace the content of the previous comment's terraformExt.js file with:

var definition = require("./terraform").definer;

function getAdditionalLanguages() {
    return {terraform: definition};
}

module.exports.styling = {code: {syntax: {getAdditionalLanguages: getAdditionalLanguages}}};
module.exports.id = "terraform";