diff --git a/lib/rouge/lexers/yaml.rb b/lib/rouge/lexers/yaml.rb index f33748a76c..3adee1f774 100644 --- a/lib/rouge/lexers/yaml.rb +++ b/lib/rouge/lexers/yaml.rb @@ -328,7 +328,7 @@ def set_indent(match, opts={}) state :plain_scalar_in_block_context do # the : indicator ends a scalar rule %r/[ ]*(?=:[ \n]|:$)/, Text, :pop! - rule %r/[ ]*:/, Str + rule %r/[ ]*:\S+/, Str rule %r/[ ]+(?=#)/, Text, :pop! rule %r/[ ]+$/, Text # check for new documents or dedents at the new line @@ -339,6 +339,8 @@ def set_indent(match, opts={}) rule %r/[ ]+/, Str rule SPECIAL_VALUES, Name::Constant + rule %r/\d+(?:\.\d+)?(?=(\r?\n)| +#)/, Literal::Number, :pop! + # regular non-whitespace characters rule %r/[^\s:]+/, Str end diff --git a/spec/visual/samples/yaml b/spec/visual/samples/yaml index c7606a8d88..7342099166 100644 --- a/spec/visual/samples/yaml +++ b/spec/visual/samples/yaml @@ -32,6 +32,7 @@ national: name: Mark McGwire hr: 65 avg: 0.278 + addr: B 221 Block - name: Sammy Sosa hr: 63