stencila / encoda

↔️ A format converter for Stencila documents
https://stencila.github.io/encoda/
Apache License 2.0
35 stars 9 forks source link

Add ability to detect programming languages #85

Open alex-ketch opened 5 years ago

alex-ketch commented 5 years ago

This is desirable for providing a pleasant syntax highlighting user experience. PrismJS, our choice of syntax highlighting library,b does not support automatic language detection.

This means that if a code block in a markdown file is not annotated with a language, no syntax highlighting will be applied, leading to a poor experience.

We propose trying to detect the language when parsing code blocks if they haven't already been annotate with one.

Additionally,

Because we want to bring in some of the language analysis stuff into encoda anyway. e.g in dockta we scan R and Python code for package import statements so we can work out what to put into the Dockerfile I want to move that to encoda so that it is also available to nixta ... and for compiling other meta data So bringing a js language detection library into encoda makes a lot of sense and filling in language property if it is not there — Nokome Bentley, May 31 17:44

Some relevant links include:

beneboy commented 5 years ago

I think https://github.com/dachev/node-cld is for detecting actual languages not programming languages.