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

Bug: Indentation indicator after chomping indicator is not recognized, appearing as illegal #41

Open
Tracked by #1
geekley opened this issue Jun 18, 2022 · 0 comments

Comments

@geekley
Copy link

geekley commented Jun 18, 2022

The YAML spec says that in block scalars, both indicators can appear in any order.
This is the case since YAML 1.0: https://yaml.org/spec/1.0/index.html#id2566934

# Modifiers may be combined in any order.
indented and chomped: |2-
    This has no newline.

also written as: |-2
    This has no newline.

both are equal to: "  This has no newline."

Also on latest YAML 1.2.2: https://yaml.org/spec/1.2.2/#rule-c-b-block-header

[162] c-b-block-header(t) ::=
  (
      (
        c-indentation-indicator
        c-chomping-indicator(t)
      )
    | (
        c-chomping-indicator(t)
        c-indentation-indicator
      )
  )
  s-b-comment

But the grammar only allows the number before the chomping indicator:
https://github.com/textmate/yaml.tmbundle/blob/master/Syntaxes/YAML.tmLanguage#L217
(?:(\|)|(>))([1-9])?([-+])?(.*\n?)

Example:

should-work1: |+2
  string
should-work2: >+2
  string
should-work3: |-2
  string
should-work4: >-2
  string
works1: |2+
  string
works2: >2+
  string
works3: |2-
  string
works4: >2-
  string
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

No branches or pull requests

1 participant