WebAssembly Code Coloring

We strongly recommend you to search the forum with possible keywords before making a new feature request. If your request is very similar to an existing one, consider liking it and/or making a comment rather than making a new one. Once you’ve searched and determined that this is a new request, delete this line.

^^ Before the whitenoise person from “bugs” comes in raging, I searched below:
– WebAssembly
– WebAssembly code blocks
– WebAssembly code coloring
– WebAssembly feature requests
And there was no results in any for any of these items. THUS, I am submitting the request now.

Use case or problem

WebAssembly is growing in popularity, and since most other languages have some color-coding to signify key-terms, etc. It would be nice to have WebAssembly, be added in there. Well mainly WAT (WebAssembly Text Format). I mean after all if JSON gets its own coloring scheme, why not WAT? XD.

Proposed solution

Implementation is pretty easy, unlike other programming languages out there with a bunch of syntax-sugar, the WAT format is pretty simple.

  • If the word follows a “(” character it should be highlighted. As well as if a the word is attached to this word through (.) similar to a method syntax in other languages.
  • Anything in quotes, colored like in other languages.
  • Anything declared with a $ as its a variable declaration.
  • Any of the types should also be highlighted, i.e. (i32, i64, f32, f64).

There is probably more, but just at least, would give it some “pop” to stand out and make it less of a bore on the page when writing documentation.

Here is some example code for visual reference, if you have not seen it yet:

	(global $import_integer_32 (import "env" "import_i32") i32)
	(global $import_float_32 (import "env" "import_f32") f32)
	(global $import_float_64 (import "env" "import_f64") f64)
	(import "js" "log_i32" (func $log_i32 (param i32)))
	(import "js" "log_f32" (func $log_f32 (param f32)))
	(import "js" "log_f64" (func $log_f64 (param f64)))
	(func (export "globaltest")
		(call $log_i32 (global.get $import_integer_32))
		(call $log_f32 (global.get $import_float_32))
		(call $log_f64 (global.get $import_float_64))

Lols, above its partially colored, but in the actual Obsidian code blocks it is not.