Skip to content

YAML issues #12

Closed
Closed

Description

@RedCMD

redundant rule type-inner and invalid include #simple-type

Image

"type-inner": {
"patterns": [
{
"include": "#simple-type"
}
]
},


num and boolnull rules are incompatible with TextMate 2.0 and Github-Linguist
Image

"num": {
"name": "constant.numeric.yaml",
"match": "(?<!![\\t ]+)(?:[+-]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN)|0x[0-9a-fA-F]+|0o[0-7]+|[+-]?(?:\\.[0-9]+|[0-9]+(?:\\.[0-9]*)?)(?:[eE][+-]?[0-9]+)?)(?=[\\t ]+#|[\\t ]*(?:[\\r\\n,\\[\\]{}]|:(?:[\\s,\\[\\]{}]|$))|$)"
},
"boolnull": {
"name": "constant.language.yaml",
"match": "(?<!![\\t ]+)(?:true|True|TRUE|false|False|FALSE|null|Null|NULL|~)(?=[\\t ]+#|[\\t ]*(?:[\\r\\n,\\[\\]{}]|:(?:[\\s,\\[\\]{}]|$))|$)"
},


--- is incorrectly detected as string instead of document

Image

block scalar string incorrectly detected as comment

- >
 
  
  # detected
Image

anchors not correct detected

? &a a
: &b b
: *a
Image

explicit multiline sequence map key not detected

?
- a
- b
:
- c
- d
Image

escape chars in double quoted block key not detected
"foo\nbar:baz\tx \\$%^&*()x": 23
Image


block scalar ended prematurely

>

 folded
 line

 next
 line
   * bullet

   * list
   * lines
Image

incorrect punctuation detected

block:	|
  void main() {
  	printf("Hello, world!\n");
  }
Image

'keyword.control.flow.block-scalar' should be added to litString
as this will bump the official grammar from 92.4% to 99.5% (and 99.7% after a few simple bug fixes)
for some reason adding meta.scalar does not work?

[R.litString]: { tier: 'strict', desc: 'string literal', exact: ['string'], family: ['punctuation.definition.string', 'punctuation'] },

Activity

  1. RedCMD commented on Jun 7, 2026

    @RedCMD
    Author

    @johnsoncodehk

    , inside a ns-global-tag-prefix is incorrectly detected as flow.punct
    https://yaml.org/spec/1.2.2/#rule-ns-global-tag-prefix

    %TAG !e! tag:example.com,2000:app/
    #                       ^

    ! inside a comment is incorrectly detected as tag.type

      # Use the ! handle for presenting

    invalid.illegal.keyword.other.directive.yaml not classified as directive
    test file SF5V.yaml
    the second %YAML 1.2 is an error as defined by fail: true
    technically this should still be highlighted normally
    and the error come from an LSP
    but it was easy to implement
    https://yaml.org/spec/1.2.2/#681-yaml-directives

    ---
    - name: Duplicate YAML directive
      from: '@perlpunk'
      tags: directive error
      fail: true
      yaml: |
        %YAML 1.2
        %YAML 1.2
        ---
      tree: |
        +STR

    %YAML 1.2 foo incorrectly highlighted as nothing and unquoted string
    Image


    escape not highlighted in string
    double: "quoted \' scalar"
    Image


    !"#$%&'()*+ incorrectly detected as tag

    safe: a!"#$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}~
         !"#$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}~
    Image

    42 incorrectly detected as unquoted string numeric

    ? a
      true
    : null
      d
    ? e
      42
    Image

    #... incorrectly detected as comment
    %YAML 1.1#...
    Image


    %YAML 1.2 incorrectly detected as directive

    ---
    scalar
    %YAML 1.2
    Image

    # string 5 incorrectly detected as comment

    |5
          # string 6
         # string 5
        #comment 4
       #comment 3
    
    ---
    
    abc: |5
          # string 6
         # string 5
        #comment 4
       #comment 3
    Image
  2. RedCMD commented on Jun 10, 2026

    @RedCMD
    Author

    comment incorrectly highlighted as string

    -  -  abc:  |2  #comment
        
             # string 9
            # string 8
           #comment 7
          #comment 6
         #comment 5
        #comment 4
       #comment 3
      #comment 2
     #comment 1
    #comment 0
    Image

    test file M5DY.yaml fails
    but Monogram still claims 100%
    - in - Chicago cubs should be punctuation, not string

    ? - Detroit Tigers
      - Chicago cubs
    :
      - 2001-07-23
    ? [ New York Yankees,
        Atlanta Braves ]
    : [ 2001-07-02, 2001-08-12,
        2001-08-14 ]
    Image

    [ incorrectly highlighted as string instead of flow

    ... # 6CA3.yaml: Tab indented top flow
    
    	[
    	]
    Image
    --- # AB8U.yaml: Sequence entry that looks like two with wrong indentation
    
    - single multiline
     - sequence entry
    Image
    Image

    should be string not comment

     | # comment
    # string
    Image
  3. johnsoncodehk commented on Jun 16, 2026

    @johnsoncodehk
    Owner

    Hi! My original intention for creating this project was simply to replace the unmaintained TextMate repositories. If you are still willing to maintain https://github.com/RedCMD/YAML-Syntax-Highlighter, would you consider porting https://github.com/johnsoncodehk/monogram/blob/master/yaml.ts into your project? So that we can remove the built-in YAML from Monogram.

    If you're open to this, you can refer to the approach used in vuejs/language-tools#6085.

    By the way, the level of completeness of https://github.com/RedCMD/YAML-Syntax-Highlighter is amazing!

  4. RedCMD commented on Jun 17, 2026

    @RedCMD
    Author

    Hello allo
    It was my intention to maintain the yaml grmmar myself
    since it has been unmaintained for years
    I have a bunch of fixes queued up to commit at some point
    my grammar also supports yaml 1.0 and 1.1 aswell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions