LeaVerou/prism — pull request #45 by buymeasoda (2012-10-21 10:07:21+00:00)
Title: Standalone node version

Hi Lea,

Thought I'd try one final idea for a node solution :)

With this implementation, I've made a standalone version of prism.js for node, which keeps the original version free of any cross environment logic.

I did also have a look at the plugin and hooks option, but I can't see a solution using either of those approaches because of the browser / DOM centric portions contained in the core that cause runtime issues with node.

If you diff between this new file and the original file for prism.js (the one in the root folder of your repo), the changes are as follows:

* Removed `highlightAll` and `highlightElement` methods
* Removed `worker` / `script` tag block
* Removed use of `self`
* Moved function wrapper from around core to around entire code base
* Added `module.exports`

Other than the deletion of the DOM centric sections, the changes required were quite minimal.

I'm still hoping to see the node variant land somewhere in the main repo, as it would be great to have it created programatically so that it remains up to date, rather than manually maintained.

But automating that process would require some tweaks to how the prism base is constructed, to facilitate generating the separate browser and node versions.

If you're really not keen to go down that path, we still have the option to add it to the main repo and manage it manually. But if that's not appealing either, I can create a separate repo for a node version and publish it to npm from there.

Cheers,

Ian