文字化けを回避する一つの方法として、PHPソースをJavaScriptとして認識させる。
環境
- Redmine 2.2.0
変更ソース
*** syntax_highlighting.rb.default 2012-12-18 22:07:43.000000000 +0900
--- syntax_highlighting.rb 2013-07-31 16:59:23.599810790 +0900
***************
*** 40,51 ****
--- 40,53 ----
# Should not return line numbers nor outer pre tag
def highlight_by_filename(text, filename)
language = ::CodeRay::FileType[filename]
+ language = :java_script if language == 'php' || language == :php
language ? ::CodeRay.scan(text, language).html(:break_lines => true) : ERB::Util.h(text)
end
# Highlights +text+ using +language+ syntax
# Should not return outer pre tag
def highlight_by_language(text, language)
+ language = :java_script if language == 'php' || language == :php
::CodeRay.scan(text, language).html(:wrap => :span)
end
end