Skip to content

Conversation

haltman-at
Copy link

This pull request is intended to address issue #8 that I opened recently. Apologies if this is not how you'd prefer to solve the problem, but this is the way that I'm currently using in my forked copy.

This PR adds a visible hljs member to the chromafi object; chromafi is no longer just a function, now it's an object with an hljs member. By modifying this member, one can use chromafi with languages other than the ones it natively supports. For instance, here's an example from my own code, using the highlightjs-solidity package:

var chromafi = require("chromafi");
var hljsDefineSolidity = require("highlightjs-solidity");
hljsDefineSolidity(chromafi.hljs);

Now chromafi will be able to colorize Solidity. I then use this later:

    let options = {
      lang: "solidity",
      lineNumbers: false,
      stripIndent: false,
      codePad: 0
    };
    return chromafi(code, options);

And, tada, we've used chromafi to colorize Solidity despite it not being natively supported! And this could just as well be used with any number of other languages that are not part of the hljs base package but have had external highlightjs language definitions written for them.

Again, if you'd prefer to solve this some other way, I understand, but I thought I should at least PR my own solution to this problem. Thank you!

@coveralls
Copy link

Pull Request Test Coverage Report for Build 41

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.001%) to 99.636%

Totals Coverage Status
Change from base Build 37: 0.001%
Covered Lines: 188
Relevant Lines: 188

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants