Open rapatel0 opened 2 years ago
My primary use case for this at the moment is looking at source files. In particular, scripts that are used in obsidian (see obsidian-customjs plugin) would be really nice to be able to view these with syntax highlighting and other code relate views
I'm working on version 1.0.0 now. The editor has been switched from CM5 to CM6, which has allowed me to get syntax highlights working for various languages (already implemented). I'm closing this issue when I push the new codebase!
I was just coming to this issue list to add a feature request to allow for codeblock viewing of the source files. In my head it would be just perfect if I could use the editing mode to actually change my various code snippets, mainly in javascript, css (and possibly python eventually), and then see them in all their glory (with syntax highlighting) in preview mode.
So please keep on working on this feature, it'll be used!
Looking forward to this! Thanks for your work.
Update: it is easy to statically add syntax highlighting to a file, but I cannot figure out how to do it in a dynamic way that avoids having to write a switch statement with a million cases for the million programming languages that exist.
The current code has a non-functional idea of dispatching the language using CM6 Compartments, but honestly I have no clue what I'm doing so guidance is appreciated :)
I'm not sure whether the list of available languages are known from your plugin or not, but if they are would it be an option just to check the extension against that list, and if there is a match, then use that language?
Alternatively if the file extension is not the same as the language name, then have a simple conversion list with the plugin settings to correlate the file extension to the language. This way, the end user can customise to their needs, and the main code of the plugin has a simple task of using the file extension to first check in the custom list for a language to use, or use directly as the language if found in the main list of languages available for syntax highlighting.
My primary use case for this at the moment is looking at source files. In particular, scripts that are used in obsidian (see obsidian-customjs plugin) would be really nice to be able to view these with syntax highlighting and other code relate views