Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Fix multiline strings and add document end marker support #74

Merged
merged 3 commits into from
Mar 3, 2017

Conversation

winstliu
Copy link
Contributor

@winstliu winstliu commented Mar 1, 2017

Requirements

  • Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
  • All new code requires tests to ensure against regressions

Description of the Change

YAML is tricky because it supports multiline strings using regular tags. As long as the next line is indented more than the tag, it'll be counted as part of the string. In previous PRs I implemented the multiline support, but without the indentation requirement. This PR properly implements indentation checks so that we don't attempt to tokenize everything until the next tag as scalar content. This fixes embedding (valid) YAML in other grammars, such as GFM.

In addition, the end document marker ... has been added.

Alternate Designs

None.

Benefits

The immediate benefits provided by this PR won't necessarily be evident to people who solely edit YAML because most non-tagged lines will be tokenized as a string anyway. However, it'll be extremely beneficial to grammars that allow for the embedding of YAML.

Possible Drawbacks

Not necessarily a drawback, but people don't get any indication that they're writing invalid YAML, even with this pull request. That is because all lines fall back to being tokenized a string if there are no other matches. That also makes it extremely hard to test, because the tags don't get an overarching scope name. So I've had to settle for a document end marker test, which will fail without indentation checks. This may be something that I'll try to fix for the future.

Applicable Issues

Fixes #72
Fixes #73

/cc @lierdakil

@lierdakil
Copy link

Thank you!

I can confirm that this fixes both issues.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

... is not tokenized Leaks scope when embedded in other grammars
2 participants