TalonCommunity / Wiki

Community maintained wiki for Talon Voice
https://talon.wiki
83 stars 81 forks source link

Talon syntax highlighting #255

Open C-Loftus opened 8 months ago

C-Loftus commented 8 months ago

If someone is good at regex it would greatly help us and make the wiki nicer if we could port vscode format from https://github.com/mrob95/vscode-TalonScript/blob/master/syntaxes/talon.tmLanguage.json into the prism syntax.

All the highlighting just goes within the prism-talon.js file and uses the syntax as defined by https://prismjs.com/extending.html

Since Prism uses a different syntax unfortunately most content from the vscode addon has to be edited a little bit. However, the vscode addon is a very good start.

If anyone is good at regex and wants to help, that would be super helpful. Ping me if you have any questions and want to help.

Nova38 commented 5 months ago

There might also be the potential to use the vscode theme directly via shikjs https://github.com/shikijs which uses the same render as vscode. It might need a little work to get it to work, but it does have a official rehype plugin I think.

It's uses is also discussed here: https://github.com/facebook/docusaurus/issues/9122

C-Loftus commented 4 months ago

Looks cool, not sure how much bandwidth that will take. We have most of the logic for syntax highlighting so I am thinking it might just be easier to port the existing regexes to the prism syntax. But definitely good to know and if someone does want to tackle this at some point, certainly fine with whatever is easier.

Nova38 commented 4 months ago

Fair enough, I will take a shot at it here in a week or two. I'm settling into a new job. I am also am gonna be finishing up an addition to the talondoc repo to use the treesitter bindings she made to get syntax highlighting working with pygments and sphinx.bIts mostly done from a year or so. After that I can probably give this a shot.

Nova38 commented 5 days ago

I have been playing around with getting the prism.js language definition to work, but I am not sure that it will be anywhere near as good as the textmate Grammer due to the limitations of the prisms.js parser. To make it I ended up modifying the existing python Grammer, it uses JavaScript Regex as apposed to the one used by the textmate which have a lot of drawbacks. Most importantly it doesn't handle the context header part of the document well. The textmate Grammer that we have is also a lot better at handling parseing the Regex expressions.

I am working on trying to get the shiki library to work. It is looking promising. There is a small bug upstream in docusouras with they way they are loading modules with jiti that is being worked on in the issue I mentioned above. Ones that is done it should be mostly working. Someone else got it working here https://lachieh.github.io/docusaurus-with-shiki-rehype/docs/intro.

Also I have gotten the textmate gramer included in the shiki repo where they have the included languages. It was pretty easy as I had already gotten it included in GitHub's linquist a year and a half ago or so.

They also recently added a feature to colorizez brackets like in vscode so that it is easier to see the pairs of them. I think that would be expesially helpful when it comes to the brackets used in TalonScript for the rules. https://shiki.style/packages/colorized-brackets