Skip to content

Commit

Permalink
Fix tokenization of block strings in YAML lexer (#1235)
Browse files Browse the repository at this point in the history
Block strings are tokenized as `Name::Constant` when they should be
`Str`. This corrects the error.
  • Loading branch information
ashmaroli authored and pyrmont committed Jul 3, 2019
1 parent 5809757 commit 75676e7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/rouge/lexers/yaml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def set_indent(match, opts={})
end
end

rule %r/[^\n\r\f\v]+/, Name::Constant
rule %r/[^\n\r\f\v]+/, Str
end

state :block_scalar_header do
Expand Down
8 changes: 6 additions & 2 deletions spec/visual/samples/yaml
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,12 @@ not a number: .NaN
# Miscellaneous
---
null: ~
true: boolean
false: boolean
bool_true: true
str_true: 'true'
bool_false: false
str_false: "false"
string: '12345'
number: 12345

# Timestamps
---
Expand All @@ -249,6 +252,7 @@ application specific tag: !something |
The semantics of the tag
above may be different for
different documents.
email_regex: !ruby/regexp '/^([\w.%+-]+)@([\w-]+\.)+([\w]{2,})$/i'

# Global tags
%TAG ! tag:clarkevans.com,2002:
Expand Down

0 comments on commit 75676e7

Please sign in to comment.