statiqdev / Statiq.Framework

A flexible and extensible static content generation framework for .NET.
https://statiq.dev/framework
MIT License
426 stars 74 forks source link

Code formatting reports unknown language for `plaintext` #269

Closed girlpunk closed 1 year ago

girlpunk commented 1 year ago

As per highlight.js's supported languages, plaintext is a valid language for highlighting, however Statiq reports a warning when using this

[WARN] Content/PostProcess » RenderContentPostProcessTemplates » ExecuteIf » ExecuteConfig » HighlightCode » Exception while highlighting source code: Error: Unknown language: "text"
   at highlight-all.js:498:7
daveaglick commented 1 year ago

The version of highlight.js Statiq uses for generation-time highlighting is relatively old and required some workarounds to build so it could be run from inside .NET: https://github.com/statiqdev/Statiq.Framework/blob/main/src/extensions/Statiq.Highlight/regenerating-highlight-all.js.md. I took a quick look through the code and sure enough, txt, plaintext, and text are all not current aliases. Those may have been added after our internal copy was produced.

I can see about updating our version of highlight.js.

daveaglick commented 1 year ago

Unfortunately it wasn't as easy as just running the same commands I used initially. As often happens, the npm packages and node ecosystem has moved under us and I'll need to figure out how to regenerate the highlight.js file from scratch. That could take some time.

girlpunk commented 1 year ago

If it helps, it looks like there's a special case to handle plaintext, which should be getting detected at highlight-all.js:623

daveaglick commented 1 year ago

It took a little hacking, but I got this figured out. Highlighting txt should work in the next release of Statiq (probably next week some time).

girlpunk commented 1 year ago

Hi, any chance on a release for this? Thanks

daveaglick commented 1 year ago

A new release just went out! Sorry for the super-long delay. I had thought I released this already and then got swamped (still am, but managed to get a new release out the door).