I would like to add support for a new language allowing syntax coloring within Inkdrop code blocks. What would be the best way to do this?
Write a CodeMirror mode for the language, get it accepted into the CodeMirror project, and then wait for this support to eventually makes its way into Inkdrop?
Hack Inkdrop locally (if possible) to add the necessary CodeMirror support to my local instance. Then, once the new language support looks good, submit to CodeMirror.
Write an Inkdrop plug-in to do the syntax highlighting I’m looking for.
What method do you propose I use? I’m excited about using Inkdrop but I don’t want to wait too long before I have the language syntax highlighting support I want. If the second option above is possible, please let me know where these JS files exist on the local Inkdrop app package and how I could add/hack in a new language.
Thank you for the question.
I’m happy to help you make a plugin.
The answer is 2 and 3.
These two options are ultimately same because plugin is only way to hack Inkdrop locally.
You have to write a mode for CodeMirror and load it via plugin.
Thank you for your feedback! I have now created a plugin that adds a new CodeMirror mode. The syntax highlighting for my new plugin is only working when the document is in “edit” mode however. When the document is is preview mode, no highlighting is taking place.
The markdown renderer retrieves mode info by following code:
const mode = CodeMirror.findModeByName(lang)
But in this case the mode is undefined.
This is because spl is not registered in CodeMirror.modeInfo as so are other languages in meta.js.
You can register it as below: