Open Porco24 opened 7 months ago
Theoretically it could, but writing the grammar for syntax highlighting is very (and I mean really) complicated. It could take a lot of time to write the grammar for a single language, if you are not familiar with it. And I am not. If you want to write the grammar, I am happy to include it in the plugin.
@Porco24 Did you mean editing mode or reading mode? Or both? During the development of the current release, I had to something with syntax highlighting. If reading mode would be enough for you, that could probably be solved. But editing mode is really challenging. I will take a look, maybe there is a "relatively" easy way.
@mugiwara85 Hi, I mean Both, If this feature is implemented, it would be very helpful to me. I hope to be able to download some highlight rule from the internet and import it into Obsidian.
@mugiwara85 Hi mate, I also had the problem of not being able to highlight Makefile code today, I spent all day trying to solve this problem but still failed.Is any method to solve it?๐ฅ
Hi @StarkSkywalker, Some basics :)
CodeMirror 6
, and in reading mode it uses Prism.js
-> This is the reason that the syntax highlighting differs in editor mode and reading mode.Prism.js
supports the makefile
language that is why it works in reading mode as shown below:
And this is also the reason why it doesn't work in editor mode, because CodeMirror 6
does not support it.
It is possible to create and add syntax highlighting for new languages in CodeMirror 6
, but it is very complicated. You basically, have to write for every language the grammar, and that is complicated and time consuming.
But! You are in luck! For MakeFile
there is a package, I can add. I'll check it out and contact you later.
Hi @StarkSkywalker, Some basics :)
- The plugin does not add syntax highlighting to code blocks
- Obsidian uses two separate methods for providing syntax highlighting. In editor mode, it uses
CodeMirror 6
, and in reading mode it usesPrism.js
-> This is the reason that the syntax highlighting differs in editor mode and reading mode.
Prism.js
supports themakefile
language that is why it works in reading mode as shown below: And this is also the reason why it doesn't work in editor mode, becauseCodeMirror 6
does not support it.It is possible to create and add syntax highlighting for new languages in
CodeMirror 6
, but it is very complicated. You basically, have to write for every language the grammar, and that is complicated and time consuming.But! You are in luck! For
MakeFile
there is a package, I can add. I'll check it out and contact you later.
@mugiwara85 Oh! Thank you so much, my friend! Your kindness knows no bounds.(My English is a little terrible, but this is the first time I've interacted with a webmaster on Github! The joy is beyond words!Long live the spirit of the Internet!)
I actually learned the basics first through your reply before I tried it, and it turned out just like you said it would in reading mode.
Hi @StarkSkywalker, Some basics :)
- The plugin does not add syntax highlighting to code blocks
- Obsidian uses two separate methods for providing syntax highlighting. In editor mode, it uses
CodeMirror 6
, and in reading mode it usesPrism.js
-> This is the reason that the syntax highlighting differs in editor mode and reading mode.
Prism.js
supports themakefile
language that is why it works in reading mode as shown below: And this is also the reason why it doesn't work in editor mode, becauseCodeMirror 6
does not support it. It is possible to create and add syntax highlighting for new languages inCodeMirror 6
, but it is very complicated. You basically, have to write for every language the grammar, and that is complicated and time consuming. But! You are in luck! ForMakeFile
there is a package, I can add. I'll check it out and contact you later.@mugiwara85 Oh! Thank you so much, my friend! Your kindness knows no bounds.(My English is a little terrible, but this is the first time I've interacted with a webmaster on Github! The joy is beyond words!Long live the spirit of the Internet!)
I actually learned the basics first through your reply before I tried it, and it turned out just like you said it would in reading mode.
Don't worry about your english. It's good (I am also not a native english speaker). I just noticed that the package which adds MakeFile
syntax, supports only basic syntax, but nertheless it's more than nothing. I'll report back later if I find out, how I can add it.
@StarkSkywalker Unfortunately, I have bad news for you. I just tried to install that package I mentioned last time, but that won't work. The reason is, that as it turned out, Obsidian uses CodeMirror 6, but not for everything. Specifically, for syntax highlighting it uses CodeMirror 5 nodes. And the package is written in CodeMirror 6 so it won't work :( As far as I could tell, the package would have only added very basic syntax highlight. Basically, comments and that's it. It is also important to mention, that makefile
is one of the hardest languages apparently, as I couldn't find any grammar for it. Multiple are asking, but there are just some custom implementations. But it is also important to mention, that CodeMirror 5 syntax highlighting might work. And this might is really just a guest. Unfortunately, I couldn't find a list which languages does CodeMirror 6 support, but CodeMirror 5 does support these: https://github.com/codemirror/codemirror5/tree/master/mode
Is here anything interesting for you? I might be able to import that. (No guarantee)
@StarkSkywalker Unfortunately, I have bad news for you. I just tried to install that package I mentioned last time, but that won't work. The reason is, that as it turned out, Obsidian uses CodeMirror 6, but not for everything. Specifically, for syntax highlighting it uses CodeMirror 5 nodes. And the package is written in CodeMirror 6 so it won't work :( As far as I could tell, the package would have only added very basic syntax highlight. Basically, comments and that's it. It is also important to mention, that
makefile
is one of the hardest languages apparently, as I couldn't find any grammar for it. Multiple are asking, but there are just some custom implementations. But it is also important to mention, that CodeMirror 5 syntax highlighting might work. And this might is really just a guest. Unfortunately, I couldn't find a list which languages does CodeMirror 6 support, but CodeMirror 5 does support these: https://github.com/codemirror/codemirror5/tree/master/mode Is here anything interesting for you? I might be able to import that. (No guarantee)
Thanks for your help๐,I think you do your best.And I found that I don't have to own this new change now.๐
I really hope that the plugin can support more syntax highlighting. I have a lot of HLSL code in my notes, but Obsidian does not support highlighting by default. I wonder if this plugin could be expanded to support more syntax in the future, such as supporting all the latest syntax from PrismJS.