lib/rouge/lexers/yaml.rb in rouge-3.20.0 vs lib/rouge/lexers/yaml.rb in rouge-3.21.0
- old
+ new
@@ -9,10 +9,12 @@
mimetypes 'text/x-yaml'
tag 'yaml'
aliases 'yml'
filenames '*.yaml', '*.yml'
+ # Documentation: https://yaml.org/spec/1.2/spec.html
+
def self.detect?(text)
# look for the %YAML directive
return true if text =~ /\A\s*%YAML/m
end
@@ -163,18 +165,18 @@
(?:![\w-]+)? # handle
!(?:[\w;/?:@&=+$,.!~*\'()\[\]%-]*) # suffix
)x, Keyword::Type
# an anchor
- rule %r/&[\w-]+/, Name::Label
+ rule %r/&[\p{L}\p{Nl}\p{Nd}_-]+/, Name::Label
# an alias
- rule %r/\*[\w-]+/, Name::Variable
+ rule %r/\*[\p{L}\p{Nl}\p{Nd}_-]+/, Name::Variable
end
state :block_nodes do
# implicit key
- rule %r/((?:\w[\w -]*)?)(:)(?=\s|$)/ do |m|
+ rule %r/((?:[\p{L}\p{Nl}\p{Nd}_][\p{L}\p{Nl}\p{Nd}\p{Blank}_-]*)?)(:)(?=\s|$)/ do |m|
groups Name::Attribute, Punctuation::Indicator
set_indent m[0], :implicit => true
end
# literal and folded scalars