YarnSpinnerTool / VSCodeExtension

The Visual Studio Code extension for Yarn Spinner.
MIT License
29 stars 14 forks source link

Added proper escape support + highlighting XML tags #25

Closed heygleeson closed 1 year ago

heygleeson commented 2 years ago

16_20-44_Code

(Using tests/input/Escaping.yarn)

Previously, syntax highlighting broke when trying to escape special characters. Matches now do a negative lookbehind to check if they're not being escaped.

Included support for XML/TextMeshPro-style angle brace tags. This isn't explicitly part of the syntax, but it's a nice QOL addition that targets the common use case of people writing in Yarn and using TextMeshPro.

desplesda commented 2 years ago

I feel like the specific feature of highlighting TMP tags (<color>) should be handled in the language server via semantic highlighting, rather than in the syntax highlighter.

The reason for this is that TMP tags only exist in Unity, and the XML-style tags otherwise don't relate to the Yarn language itself. If we added syntax highlighting to the syntax definition, we'd be highlighting stuff in a way that may not apply to your project. However, if the highlighting is moved to the language server, we can do per-project highlighting that's responsive to the current project's needs.

(Completely agreed on handling highlighting escapes; what I'll do here is push changes to this PR that remove XML highlighting, add the corresponding feature to the language server, and then merge this PR.)

Thank you very much for the contribution!

heygleeson commented 2 years ago

I'd point out that XML-style tags do exist for the other YarnSpinner targets (Web -> HTML, Unreal -> UMG Rich Text Blocks), though I know YS is still in dev for them so whether XML-tags are supported or not may not (yet) be explicitly stated.

Would opting for project-detection syntax highlighting be a similar process for these other targets?