BoostIO / BoostNote-Legacy

This repository is outdated and new Boost Note app is available! We've launched a new Boost Note app which supports real-time collaborative writing. https://github.com/BoostIO/BoostNote-App
Other
17.07k stars 1.47k forks source link

Auto-detect code language for code blocks #3341

Open grandslammer opened 4 years ago

grandslammer commented 4 years ago

I have no syntax highlighting within my code blocks (see screenshot). All my settings seem to be correct.

Screenshot_1 Screenshot_2

Flexo013 commented 4 years ago

You need to tell markdown what language it should use for syntax highlighting: image image

grandslammer commented 4 years ago

Thanks, is there any kind of shortcut or auto detect feature for this? The editor has an auto detect feature. Perhaps it could be incorporated into code blocks also?

Flexo013 commented 4 years ago

Currently that is not possible for code blocks. Auto-detecting it for code blocks could maybe work. It should only be triggered on a specific shortcut though.

I don't think such a feature would be in high demand as just typing out the few characters does not take a lot of time, and there are no possible interpretation mistakes if it is done manually. Cause I could easily imagine the auto-detect going wrong with tiny code snippets.

That being said, this is an OSS project, so if somebody feels like implementing this feature, then don't let me stop you.

nammn commented 4 years ago

This sounds like a useful feature to me. I could take a look at this in the future. Maybe either with the help of the library as a dependency https://github.com/highlightjs/highlight.js/blob/master/src/highlight.js or inspiration from there.

Flexo013 commented 4 years ago

@nammn That looks like a good library to use. If we could only use the autodetecting part of the library, then that would be preferable, as we already have CodeMirror to take care of highlighting.