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

YAML support #84

Closed
ankrgyl opened this issue Jan 27, 2024 · 4 comments · Fixed by #85
Closed

YAML support #84

ankrgyl opened this issue Jan 27, 2024 · 4 comments · Fixed by #85

Comments

@ankrgyl
Copy link

ankrgyl commented Jan 27, 2024

Have you considered adding support for YAML?

@acao
Copy link
Collaborator

acao commented Jan 28, 2024

yes it's on the radar - there isn't a modern cm6 mode for yaml last we checked, but it's still possible with legacy mode i think

@ankrgyl
Copy link
Author

ankrgyl commented Jan 28, 2024

There is now! https://github.com/codemirror/lang-yaml

@imolorhe
Copy link
Collaborator

FYI I've picked this up. Will see how easy it is to add a yaml mode.

@imolorhe
Copy link
Collaborator

Done!
Demo

imolorhe added a commit that referenced this issue Feb 23, 2024
Closes #84 

- Added YAML support
- Also updated the DOM rendering bits to use markdown instead of setting
the HTML directly, which is a safer approach
- Also slightly improved the demo UI (it didn't look good with black
text on black background)
- Also added a bunch of tests

To support YAML (and potentially other formats), I updated the logic to
"resolve" tokens before using them. This is important since the [YAML
grammar/tokens](https://github.com/lezer-parser/yaml/blob/main/src/yaml.grammar)
is different from the [JSON
grammar/tokens](https://github.com/lezer-parser/json/blob/main/src/json.grammar)
(which is very similar to the [JSON5
grammar](https://github.com/dimfeld/lezer-json5/blob/master/src/json5.grammar)).
So we map the tokens from the different grammars to the equivalent token
in the "base" grammar (currently this is the JSON grammar tokens but I
think we can/should map to some other arbitrary token set which will
force us to properly implement the mappings, otherwise additional
changes made may work in JSON mode but without proper testing, may not
work in YAML mode, if the mappings were not added).
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 a pull request may close this issue.

3 participants