CodeMovie / meta

Discussions and Bugs
1 stars 0 forks source link

[request] support more languages #2

Closed setop closed 2 months ago

setop commented 3 months ago

I tried with Elixir code but syntax highlighting is not supported making the result a bit disappointing.

SirPepe commented 3 months ago

I should be able to whip up some support for elixir somewhat quickly, but I know literally nothing about the language. Expect the first few iterations to suck a lot :)

setop commented 3 months ago

The language is really nice, just pattern matching and pipe operator are god's gifts. But that's not the topic :)

I don't know the effort for CodeMovie to support a new language. You did not published the generator, only the runtime, did you ? I looks like it is based on tokens and not depending on the language syntax, is it ? Elixir is supported by highlightjs, I don't know if it helps.

SirPepe commented 3 months ago

It roughly works like this:

  1. parse code into a CST using some sort of parser infrastructure (currently mostly lezer)
  2. massage the CST to make step 3 work as good as possible
  3. apply the default logic to handle diffing, CSS generation etc.

In theory a 10 line wrapper around lezer-elixir world add "support" for elixir, but without step 2, it would not be particularly great support. The diffing algorithm works best when the CST is augmented with all sorts of context information, some language-specific magic numbers might need adjusting. Some nodes in the CST even need to be broken down more than any regular parser would normally do (eg. parse natural language inside strings and comments).

We'll see how it goes. I will take a stab at elixir in the next few days.

SirPepe commented 3 months ago

Progress report: I worked my way through most of the documentation and should have most syntax working properly. The next step is to extract more context info for the diffing algorithm, but that should not take too long, given what I now know about Elixir and the parse tree. Expect a release (extremely buggy) in a few days.

Screenshot from my test bench:

Bildschirmfoto vom 2024-07-04 21-49-30

SirPepe commented 2 months ago

This is as far as I got without really trying to build some animations (and actually learning elixir in the process). Probably not perfect, but maybe okay for a first release. Expect that in a few days, once the playground and the docs have been updated.

Bildschirmfoto vom 2024-07-08 13-27-19

setop commented 2 months ago

lovely

SirPepe commented 2 months ago

https://code.movie/blog/elixir-support-and-improved-stability-in-0.0.14.html :sparkles:

LMK if you find any bugs, strange behavior, missing syntax etc.

setop commented 2 months ago

I tested with a more larger code snippet. It is beautiful :)