Project

General

Profile

Defect #30434 » 30434-remove-cr-chars-v3.patch

Go MAEDA, 2019-02-03 07:22

View differences:

lib/redmine/syntax_highlighting.rb
76 76
        # Highlights +text+ as the content of +filename+
77 77
        # Should not return line numbers nor outer pre tag
78 78
        def highlight_by_filename(text, filename)
79
          # TODO: Delete the following workaround for #30434 and
80
          # test_syntax_highlight_should_normalize_line_endings in
81
          # application_helper_test.rb when Rouge is improved to
82
          # handle CRLF properly.
83
          # See also: https://github.com/jneen/rouge/pull/1078
84
          text = text.gsub(/\r\n?/, "\n")
85

  
79 86
          lexer =::Rouge::Lexer.guess_by_filename(filename)
80 87
          formatter = ::Rouge::Formatters::HTML.new
81 88
          ::Rouge.highlight(text, lexer, CustomHTMLLinewise.new(formatter))
test/helpers/application_helper_test.rb
1123 1123
    end
1124 1124
  end
1125 1125

  
1126
  def test_syntax_highlight_should_normalize_line_endings
1127
    assert_equal "line 1\nline 2\n", syntax_highlight("test.txt", "line 1\rline 2\r\n")
1128
  end
1129

  
1126 1130
  def test_to_path_param
1127 1131
    assert_equal 'test1/test2', to_path_param('test1/test2')
1128 1132
    assert_equal 'test1/test2', to_path_param('/test1/test2/')
(4-4/4)