Skip to content

Commit

Permalink
fix: Correctly tokenize YAML meta tags with non alphabetical characte…
Browse files Browse the repository at this point in the history
…rs after multiline string (#4706)

* fix: Correctly tokenize YAML meta tags with non alphabetical characters after multiline string
* prevent backtracking and spaces in meta tags
  • Loading branch information
andrewnester authored May 20, 2022
1 parent d59c22b commit 0164811
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/ace/mode/_test/text_yaml.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ bill-to: &id001
street: |
123 Tornado Alley
Suite 16
ref-id: id123
city: East Centerville
state: KS

Expand Down
7 changes: 6 additions & 1 deletion lib/ace/mode/_test/tokens_yaml.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,12 @@
],[
"start",
["indent"," "],
["meta.tag","city"],
["meta.tag","ref-id"],
["keyword",":"],
["text"," id123"]
],[
"start",
["meta.tag"," city"],
["keyword",":"],
["text"," East Centerville"]
],[
Expand Down
4 changes: 2 additions & 2 deletions lib/ace/mode/yaml_highlight_rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ var YamlHighlightRules = function() {
regex: "[&\\*][a-zA-Z0-9-_]+"
}, {
token: ["meta.tag", "keyword"],
regex: /^(\s*\w.*?)(:(?=\s|$))/
regex: /^(\s*\w[^\s:]*?)(:(?=\s|$))/
},{
token: ["meta.tag", "keyword"],
regex: /(\w+?)(\s*:(?=\s|$))/
regex: /(\w[^\s:]*?)(\s*:(?=\s|$))/
}, {
token : "keyword.operator",
regex : "<<\\w*:\\w*"
Expand Down

0 comments on commit 0164811

Please sign in to comment.