highlightjs / highlightjs-structured-text

Highlightjs Structured Text language support IEC 61131-3
BSD 3-Clause "New" or "Revised" License
20 stars 6 forks source link

Making it work without NodeJS #14

Closed philippn closed 3 years ago

philippn commented 3 years ago

Hi there,

correct me if I'm wrong, but it seems to me that this language can only be installed when using HighlightJS with NodeJS :-( Is there some specific reason for this?

I looked into this a bit more and here is a Gist containing a version that works with the vanilla JS version of HighlightJS: https://gist.github.com/philippn/0c45ef5eab20d90dffd9612f6d295c1d

Maybe you will find this useful or consider this for integration.

Thanks and kind regards, Philipp

Serhioromano commented 3 years ago

True, in order for it to work with HighlightJS I had to change the way it export itself. Change this

module.exports = function(hljs) {
    hljs.registerLanguage("iecst", hljsDefineIECST);
};

to this

module.exports.definer = hljsDefineIECST;

I do not know why it happens, probably @marcoscaceres can explain. Because I whished that ST language support will be installed by default with any HJS distribution but it turned out it even does not work out of the box, even if installed manually.

module.exports = hljsDefineIECST;

joshgoebel commented 3 years ago

See the answer on the other thread. The "preferred" way to do this is that your language simply exports only the builder function (see any language in the core library). Then build highlight.js once with your repo inside extra... and then commit the generated dist (distributable) folder which will contain a "CDN module" ready to go.

Another example:

joshgoebel commented 3 years ago

@Serhioromano

@marcoscaceres Isn't really involved with the project too much anymore. You'd have better luck CCing me as I'm the current maintainer. I also [as of just now] follow ALL the repositories in our organization so hopefully I will miss less in the future. :)