"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/redmine/syntax_highlighting.rb" between
redmine-4.0.3.tar.gz and redmine-4.0.4.tar.gz

About: Redmine is a flexible project management and bug-tracking web application (using the Ruby on Rails framework). It supports also project wikis and forums, documents management, and multiple version control systems.

syntax_highlighting.rb  (redmine-4.0.3):syntax_highlighting.rb  (redmine-4.0.4)
skipping to change at line 53 skipping to change at line 53
def language_supported?(language) def language_supported?(language)
if highlighter.respond_to? :language_supported? if highlighter.respond_to? :language_supported?
highlighter.language_supported? language highlighter.language_supported? language
else else
true true
end end
rescue rescue
false false
end end
def filename_supported?(filename)
if highlighter.respond_to? :filename_supported?
highlighter.filename_supported? filename
else
false
end
end
end end
module Rouge module Rouge
require 'rouge' require 'rouge'
# Customized formatter based on Rouge::Formatters::HTMLLinewise # Customized formatter based on Rouge::Formatters::HTMLLinewise
# Syntax highlighting is completed within each line. # Syntax highlighting is completed within each line.
class CustomHTMLLinewise < ::Rouge::Formatter class CustomHTMLLinewise < ::Rouge::Formatter
def initialize(formatter) def initialize(formatter)
@formatter = formatter @formatter = formatter
skipping to change at line 86 skipping to change at line 94
# Highlights +text+ as the content of +filename+ # Highlights +text+ as the content of +filename+
# Should not return line numbers nor outer pre tag # Should not return line numbers nor outer pre tag
def highlight_by_filename(text, filename) def highlight_by_filename(text, filename)
# TODO: Delete the following workaround for #30434 and # TODO: Delete the following workaround for #30434 and
# test_syntax_highlight_should_normalize_line_endings in # test_syntax_highlight_should_normalize_line_endings in
# application_helper_test.rb when Rouge is improved to # application_helper_test.rb when Rouge is improved to
# handle CRLF properly. # handle CRLF properly.
# See also: https://github.com/jneen/rouge/pull/1078 # See also: https://github.com/jneen/rouge/pull/1078
text = text.gsub(/\r\n?/, "\n") text = text.gsub(/\r\n?/, "\n")
lexer =::Rouge::Lexer.guess_by_filename(filename) lexer =::Rouge::Lexer.guess(:source => text, :filename => filename)
formatter = ::Rouge::Formatters::HTML.new formatter = ::Rouge::Formatters::HTML.new
::Rouge.highlight(text, lexer, CustomHTMLLinewise.new(formatter)) ::Rouge.highlight(text, lexer, CustomHTMLLinewise.new(formatter))
end end
# Highlights +text+ using +language+ syntax # Highlights +text+ using +language+ syntax
# Should not return outer pre tag # Should not return outer pre tag
def highlight_by_language(text, language) def highlight_by_language(text, language)
lexer = lexer =
find_lexer(language.to_s.downcase) || ::Rouge::Lexers::PlainText find_lexer(language.to_s.downcase) || ::Rouge::Lexers::PlainText
::Rouge.highlight(text, lexer, ::Rouge::Formatters::HTML) ::Rouge.highlight(text, lexer, ::Rouge::Formatters::HTML)
end end
def language_supported?(language) def language_supported?(language)
find_lexer(language.to_s.downcase) ? true : false find_lexer(language.to_s.downcase) ? true : false
end end
def filename_supported?(filename)
!::Rouge::Lexer.guesses(:filename => filename).empty?
end
private private
# Alias names used by CodeRay and not supported by Rouge # Alias names used by CodeRay and not supported by Rouge
LANG_ALIASES = { LANG_ALIASES = {
'delphi' => 'pascal', 'delphi' => 'pascal',
'cplusplus' => 'cpp', 'cplusplus' => 'cpp',
'ecmascript' => 'javascript', 'ecmascript' => 'javascript',
'ecma_script' => 'javascript', 'ecma_script' => 'javascript',
'java_script' => 'javascript', 'java_script' => 'javascript',
'xhtml' => 'html' 'xhtml' => 'html'
} }
 End of changes. 3 change blocks. 
1 lines changed or deleted 13 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)