Skip to content

Commit

Permalink
Fix block chomping syntax in YAML lexer (#1234)
Browse files Browse the repository at this point in the history
YAML supports several types of 'block chomping' syntax for block
strings. This commit lexes that syntax correctly and updates the visual
sample to include examples.
  • Loading branch information
ashmaroli authored and pyrmont committed Jul 2, 2019
1 parent 28f484e commit 241b60e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rouge/lexers/yaml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def set_indent(match, opts={})
end

# literal and folded scalars
rule %r/[\|>]/ do
rule %r/[\|>][+-]?/ do
token Punctuation::Indicator
push :block_scalar_content
push :block_scalar_header
Expand Down
43 changes: 43 additions & 0 deletions spec/visual/samples/yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,49 @@ stats: |
65 Home Runs
0.278 Batting Average

# Multi-line block chomping

## No newlines at end of folded block
---
desc: >-
This is just a dummy text intended to
test this lexer. The following whitespace
until "label" is intentional.


label: lipsum

## Allow all newlines at end of folded block
---
desc: >+
This is just a dummy text intended to
test this lexer. The following whitespace
until "label" is intentional.


label: lipsum

## No newlines at end of literal block
---
desc: |-
This is just a dummy text intended to
test this lexer. The following whitespace
until "label" is intentional.


label: lipsum

## Allow all newlines at end of literal block
---
desc: |+
This is just a dummy text intended to
test this lexer. The following whitespace
until "label" is intentional.


label: lipsum
...

# Quoted scalars
---
unicode: "Sosa did fine.\u263A"
Expand Down

0 comments on commit 241b60e

Please sign in to comment.