LoginSignup
1
1

More than 5 years have passed since last update.

Wiki、リポジトリのPHPコードの日本語が文字化けする

Last updated at Posted at 2013-07-31

文字化けを回避する一つの方法として、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
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1