astrale-sharp / typstfmt

Apache License 2.0
253 stars 25 forks source link

Implement Math Block Align #115

Closed taooceros closed 1 year ago

taooceros commented 1 year ago

resolve #113

Implement a basic alignment for math block based on the align point. Current rule is:

It scan the syntax twice to retrieve the information (farthest align point). I can't think a way to do it at one pass.

Maybe we can do better for math:

taooceros commented 1 year ago

@astrale-sharp done

astrale-sharp commented 1 year ago

Thanks to these new files I can see the output of your work and it looks really good ! Nice!

You're actually one of the rare person to have edited the formatting code itself and not the tooling, I'm curious, was it difficult?

Most of the examples you chose are quite alike, I think not all of them are necessary although it's not a big deal to leave them as is.

astrale-sharp commented 1 year ago

Thanks again for your nice contribution, we're almost good to go!

taooceros commented 1 year ago

Could you do it for me since I will be afk for a while? Thanks 😃

taooceros commented 1 year ago

I would add a test like this where the linebreak is not there and the formatter adds it.

"$#xx(a,b) &= 1 \ #xx(a,b) &= 1 \$" and then we would be good to go, thanks for this nice contribution !

I feel like the current implementation won't do it. Maybe I can revise it sometimes. Though maybe some user will prefer to not having a line break unless it is too long? Idk

astrale-sharp commented 1 year ago

Just curious, what would be the output of such a test? (It's okay to add the test to verify that it doesn't break or behave weirdly)

astrale-sharp commented 1 year ago

Could you do it for me since I will be afk for a while? Thanks 😃

I didn't see that message,

sure! I'll do/test that soon !

taooceros commented 1 year ago

Could you do it for me since I will be afk for a while? Thanks 😃

I didn't see that message,

sure! I'll do/test that soon !

no worry I can do it now.

taooceros commented 1 year ago

Just curious, what would be the output of such a test? (It's okay to add the test to verify that it doesn't break or behave weirdly)

basically without changing anything.

taooceros commented 1 year ago

@astrale-sharp do you think we should add space around &?

astrale-sharp commented 1 year ago

Just curious, what would be the output of such a test? (It's okay to add the test to verify that it doesn't break or behave weirdly)

basically without changing anything.

I'm not sure, it would help to see an example of what you mean!

astrale-sharp commented 1 year ago

With the new test, everything looks good and we're covered so I would be keen to merge as is, but If you want to try with spaces around, we can see what it looks like!

astrale-sharp commented 1 year ago

One test fails, seems like maybe the snapshot was not registered ?

taooceros commented 1 year ago

Ah I made a mistake there. I will fix it tonight

EDIT by @astrale-sharp night is for sleeping

taooceros commented 1 year ago

Sorry for the delay. Now it should be good.

astrale-sharp commented 1 year ago

No need to apologize! Thanks a lot for this contribution it looks amazing :grin: !