Skip to content
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

Add syntax highlighting for placeholders and tags #2879

Merged
merged 2 commits into from
Jun 19, 2023

Conversation

eemeli
Copy link
Member

@eemeli eemeli commented Jun 16, 2023

Fixes part of #2180

These use a a CodeMirror 5-style stream parser or tokenizer, as that seemed like the easiest solution for the level of complexity we need. As these have a slightly different shape than our other parsers, and as our current regexps are somewhat suboptimal as identified in mozilla/react-content-marker#23, I wrote new ones for use here. Fluent patterns are handled specially, while all others are parsed for printf and Python-style variables. HTML-ish tags are identified in both.

Happy to take instruction on the CSS styles used by the highlighter.

Some examples:

Screenshot 2023-06-16 at 21 44 50 Screenshot 2023-06-16 at 21 45 24 Screenshot 2023-06-16 at 21 46 31 Screenshot 2023-06-16 at 21 47 05 Screenshot 2023-06-16 at 21 48 17 Screenshot 2023-06-16 at 21 49 44 Screenshot 2023-06-16 at 21 50 53

@eemeli eemeli requested a review from mathjazz June 16, 2023 19:07
Copy link
Collaborator

@mathjazz mathjazz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fan-tas-tic! Brilliant work!

I would only make the highlight colors a bit brighter.

Co-authored-by: Matjaž Horvat <matjaz.horvat@gmail.com>
@mathjazz mathjazz merged commit 9220827 into mozilla:master Jun 19, 2023
@eemeli eemeli deleted the highlight branch June 19, 2023 14:13
mathjazz added a commit to mathjazz/pontoon that referenced this pull request Jun 20, 2023
mathjazz added a commit to mathjazz/pontoon that referenced this pull request Jun 22, 2023
mathjazz added a commit that referenced this pull request Jun 22, 2023
* Revert "Re-enable spellchecker in translation editor (#2884)"

This reverts commit efa6859.

* Revert "Add syntax highlighting for placeholders and tags (#2879)"

This reverts commit 9220827.

* Revert "Replace editor `<textarea>` with CodeMirror v6 (#2866)"

This reverts commit 9a1ee55.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants