Glad to help:
1) “Seems like both prism.js and highlight.js support Scala, why then this plugin doesn’t support it?”
Because including plugin support for each supported language would require massive amounts of time, and the resulting plugin size would be huge. To prevent this, I try to include only the most common/requested languages. Thanks to your feedback, I will try to add Scala in a future update.
@specialk Why would it require a massive amount of time?
Looks like the prism part of the plugin already follows the “file-per-language” structure, so it’s basically only a manner of adding the language’s file to lib/prism/js and including it in inc/resources-enqueue.js.
I can tell that the plugin doesn’t automatically load dependency languages (for instance, for Scala that would be Java) and each language file must inline the code of the dependency language as well. I’m not a php / javascript programmer, but I would imagine it is possible to make the plugin automatically load the dependency languages; otherwise, it is possible to make a helper script that transforms the original language files to ones with the dependency languages inlined.
As for the plugin size – does it really matter if the plugin would weigh an extra MB? Obviously the plugin should not serve the entire language-set for every page, but only the relevant language-files. It already does so with prism.js, but with highlight.js it seems that the structure is different and includes all of the languages in one big file (lib/highlight/js/highlight-core.js). I guess it’s possible to transform this part of the plugin to work with “file-per-language” structure as well?
-
This reply was modified 7 years, 3 months ago by
eyalroth.
1) “Why would it require a massive amount of time?”
Maybe “massive” overstates it. Suffice it to say that the amount of time required is directly proportional to the number of languages and functionality. But don’t worry at all, as stated I will go ahead add Scala like I said in a future update.
2) “does it really matter if the plugin would weigh an extra MB?”
Not at all.
3) “I guess it’s possible to transform this part of the plugin to work with “file-per-language” structure as well?”
It’s a possibility, thanks for the idea.
@specialk Here’s a python script which generates all the lang-x.js files from a given directory of prism-x.js files (as they are in the prism.js repository). It also generates the “array” parts to be pasted in the resources-enqueue.php file:
https://gist.github.com/eyalroth/20421d5ea04795db47a00f2837228ff9
Thanks will check it out.