File: escape_spec.rb

package info (click to toggle)
ruby-rouge 4.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,844 kB
  • sloc: ruby: 38,489; sed: 2,071; perl: 152; makefile: 8
file content (29 lines) | stat: -rw-r--r-- 678 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
describe Rouge::Lexers::Escape do
  let(:lexer) { Rouge::Lexers::Escape.new(lang: 'json') }
  let(:text) { '{ "foo": <!<bar>!> }' }
  let(:result) {
    Rouge::Formatter.with_escape do
      formatter.format(lexer.lex(text))
    end
  }

  describe 'html' do
    let(:formatter) { Rouge::Formatters::HTML.new }

    it 'unescapes' do
      assert { result =~ /<bar>/ }
    end
  end

  describe 'terminal256' do
    let(:formatter) { Rouge::Formatters::Terminal256.new }
    let(:text) { %({ "foo": \n <!\e123!> }) }

    it 'unescapes' do
      assert { result =~ /\e123/ }

      # shouldn't escape the term codes around \n
      assert { result =~ /\n\e/ }
    end
  end
end