2006年5月 2日

MovableTypeではてな記法が使えるmt-text-hatena.plプラグインをインストールしてみたのでテストしてみます。

o- はてな記法

ほんぶん

リスト

  • グループ1
    • アイテム1-1
    • アイテム1-2
  • グループ2
    • アイテム2-1
    • グループ2-1
      • アイテム2-1-1

定義リスト

用語1
説明
用語2
説明

テーブル

へっだ ヘッダ

すーぱーpre記法

#!/usr/bin/perl -w
use strict;
print <<END;
<html><body>
  <h1>Hello! World.</h1>
</body></html>
END

お、いい感じ。

と、思って保存しようと思ったらこんなエラーが。

Can't call method "stash" on an undefined value at /home/www/htdocs/mt/plugins/mt-text-hatena.pl line 24.

で、id:tochiyukiさんのコードを参考にパッチ(http://d.hatena.ne.jp/tociyuki/20051022/1130001363)。

--- mt-text-hatena.pl   2006-05-02 00:24:53.000000000 +0900
+++ mt-text-hatena-p1.pl        2006-05-02 00:28:26.396544000 +0900
@@ -21,9 +21,8 @@
     if($text eq ''){
       return "";
     }
-    my $entry = $ctx->stash('entry');
     my $permalink = "";
-    if ($entry && $entry->id) {
+    if (UNIVERSAL::can($ctx, 'stash') and my $entry = $ctx->stash('entry')) {
       $permalink = $entry->permalink;
     }
     my $parser = Text::Hatena->new(

いけたかな?

試したコードはこれです。

*はてな記法
ほんぶん
**リスト
-グループ1
--アイテム1-1
--アイテム1-2
-グループ2
--アイテム2-1
--グループ2-1
---アイテム2-1-1
**定義リスト
:用語1:説明
:用語2:説明
**テーブル
|*へっだ|*ヘッダ|
|あ|う|
**すーぱーpre記法
>||
#!/usr/bin/perl -w
use strict;
print <<END;
<html><body>
  <h1>Hello! World.</h1>
</body></html>
END
 ||<

Comments

トラックバック

トラックバックURL: