はてなダイアリーからはてなブログに移行

今更ながらはてなダイアリーからはてなブログに移行してみた。
Super pre 記法で syntax highlight できないみたいだったので、Google code prettify を使うようにしてみた。

やり方は、はてブロ設定のデザイン -> ヘッダー の所に以下を設定しておいて、

__GooglePrettify__
<script type="text/JavaScript" src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js?autoload=false&amp;skin=desert"></script>
<script type="text/JavaScript">
$(function () {
    $("pre:contains('__GooglePrettify__')").addClass("prettyprint").each(function (i, elm) {
        elm.innerHTML = elm.innerHTML.replace(/^.*?__GooglePrettify__.*?\n/, "");
    });
    prettyPrint();
});
</script>

ハイライトしたいコードブロックの先頭に __GooglePrettify__ と書き込むだけ。

__GooglePrettify__
object FizzBuzz {
  def main(args: Array[String]) {
    List.range(1, 101) map (x => (x, "")) map
      (x => (x._1, x._2 + (if (x._1 % 3 == 0) "fizz" else ""))) map
      (x => (x._1, x._2 + (if (x._1 % 5 == 0) "buzz" else ""))) map
      (x => if (x._2 == "") x._1 else x._2) foreach println
  }
}

↑初 ScalaFizzBuzz. ちょっと勉強してきた↓

__GooglePrettify__
object FizzBuzz {
  def main(args: Array[String]) {
    1 to 100 map {
      case x if x % 15 == 0 => "FizzBuzz"
      case x if x % 3 == 0 => "Fizz"
      case x if x % 5 == 0 => "Buzz"
      case x => x
    } foreach println
  }
}