I am trying out Swift's DocC to write tutorials because I love the section/step setup and the automatic code diffing and previews!
The issue is that I'm trying to write tutorials using Haskell. I can't find a way to tell @Code to use a certain syntax highlighter in the first place, and this page seems to say that Haskell syntax highlighting isn't supported in DocC at all, not just in tutorials?
Is there a way for me to use DocC as a framework for my Haskell tutorials?
The syntax highlighting is handled by Swift-DocC-Render, which looks like it defers to highlight.js. Looking through the source code it seems like you could set the environment variable VUE_APP_HLJS_LANGUAGES to a comma-separated list of tokens to recognize, which it should then hand off to hljs. Highlight.js's docs say it recognizes the haskell token, so you should be able to set VUE_APP_HLJS_LANGUAGES=haskell when running DocC, if the syntax definition hasn't been minified away.
/cc @marcus_ortiz in case i'm misunderstanding the workflow here
EDIT: Upon reading more closely, i think this might only work when building the renderer, not when building docs - it looks like the version of Swift-DocC-Render we ship with Xcode only includes language files for the ones we list in the docs you linked. Still, if you're fine with loading NPM on your system you could build Swift-DocC-Render yourself to get the Haskell language definition loaded.
Correct. The VUE_APP_HLJS_LANGUAGES can be used for this, but it is a build-time configuration and not a runtime configuration, so a custom build of Swift-DocC-Render would need to be used for this.
There is a brief note on the usage of that flag here.
The reason that not all hljs supported languages are not included by default is due to our attempt to balance the size of the bundled JavaScript size with the flexibility of having many supported languages for highlighting code listings.
Haskell is a popular enough language, that we would probably consider taking a PR to include it with the default set of supported languages in Swift-DocC-Render, although it will add an additional JS file to every default build of the renderer, so it's something that needs to be given some careful consideration.
And the reason that we split up the language JS files in the actual build is so that we can dynamically load only the necessary JS for the languages in the code listings on any given page (so if there are only Swift code listings on a page for example, we don't need to fetch any of the JS for highlighting any other languages, etc).