CodeblockCustomizer icon indicating copy to clipboard operation
CodeblockCustomizer copied to clipboard

No syntax highlight for some languages in editing mode

Open Benji1109 opened this issue 2 months ago • 1 comments

Hello 👋 , There are some cases (like with GraphQL) where I don’t see any syntax highlighting in editing mode — it only appears in reading mode. Do you happen to know why this might happen?

Editing mode: Image

Reading mode: Image

Markdown:

	query OrderQuery {
	  order{
		  lines {
			  sku
		  }
	  }
	}
 int main() {
	 printf("ad");
 }
'result if true'.method() if 1 else result_if_false.property

Benji1109 avatar Nov 04 '25 11:11 Benji1109

Hi,

yes. The editing view and the reading view are 2 completely different things. In editing mode Obsidian uses the editor (called CodeMirror). CodeMirror is what provides syntax highlighting. In reading mode Obsidian uses prism.js for syntax highlighting. In this specific case CodeMirror does not provide any syntax highlighting, but prism.js does. Thats why the syntax highight is different or missing (like in this case). It is possible to write packages for syntax highlighting for CodeMirror, however, that is not very complex. But you might have luck, because I jut saw, that there might be a package for graphql. I will look at later. Maybe I can add that package for you.

mugiwara85 avatar Nov 04 '25 12:11 mugiwara85