Skip to content

See if we can re-use tree-sitter-tact for syntax highlighting in code snippets #1158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
anton-trunov opened this issue Apr 24, 2024 · 5 comments
Labels
kind: docs Documentation for docs.tact-lang.org kept in docs folder

Comments

@anton-trunov
Copy link
Member

anton-trunov commented Apr 24, 2024

It should be in principle possible, since GitHub uses it in Linguist.

No more regex-based highlighting! :)

This would make things like tact-lang/tact-docs#183 much easier

@novusnota
Copy link
Member

It is possible, but would require some workarounds to fix contexts.

For example, the following is how tree-sitter tries to parse a small snippet of a single statement. Notice, that it fails because of lack of proper context:

image

And here's when we add more context to the statement, such as the body of a global static function fun _(). Now, tree-sitter is able to parse everything correctly:

image

This workaround will make many code snippets a tad more verbose, so there are other approaches trying to pre-process code blocks as if they were encapsulated in global static function bodies in the first place.

Moreover, the TextMate grammar docs are using needs to exist in order for VSCode extension and Sublime Text package to work. So, after a discussion with @anton-trunov we figured, that it's best to improve the current TextMate grammar and make a single upstream source of it, such that tact-docs, tact-vscode, upcoming Sublime Text package, Nujan IDE and others can consume it to get decent syntax highlighting.

Closing this issue as wontfix, at least for the foreseeable future :)

@novusnota novusnota closed this as not planned Won't fix, can't repro, duplicate, stale Apr 24, 2024
@anton-trunov
Copy link
Member Author

Closing this issue as wontfix, at least for the foreseeable future :)

Maybe not today or next month, but in a year. Admittedly, we don't the manpower to work on this now. But what if someone from the TON community comes along and gets excited to work on something like this. Especially because we have a grants and bounties program to support community members.

@novusnota
Copy link
Member

would require some workarounds to fix contexts

We may try to do something like the expandable/collapsible code blocks, as seen in Kotlin docs:

Collapsed code block

Expanded code block

Additionally, and this is well out of scope of this issue, we may try to bring Blueprint test runner (or some other approach) into docs to support running Tact's code blocks directly in docs.

@anton-trunov anton-trunov transferred this issue from tact-lang/tact-docs Dec 12, 2024
@anton-trunov anton-trunov added the kind: docs Documentation for docs.tact-lang.org kept in docs folder label Dec 12, 2024
@anton-trunov
Copy link
Member Author

@i582 What are your thoughts on this? Should we close this?

@i582
Copy link
Member

i582 commented Feb 23, 2025

I think TextMate's grammar is sufficient for highlighting for GitHub and documentation :)
In editors like VS Code or Sublime we have no other options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: docs Documentation for docs.tact-lang.org kept in docs folder
Projects
None yet
Development

No branches or pull requests

3 participants