tDiary.org[tDiary-devel] Fix stripped_subtitle in wiki_style.rb

< Prev [Date] Next > < Prev [Thread] Next > Index by date Index by thread
YAAです。
こんにちは。

Wiki Style を使用している時に

![tDiary]

のように category だけ付けて section title を付けない場合に
calendar3 で問題が起きるようです。
具体的には以下のような error が出ます。

./tdiary.rb:756:in `clone': can't clone nil (TypeError)

./tdiary.rb:635:in `eval_src'
./tdiary.rb:67:in `join'
./tdiary.rb:67:in `safe'
./tdiary.rb:636:in `eval_src'
./tdiary.rb:880:in `do_eval_rhtml'
./tdiary.rb:830:in `eval_rhtml'
index.rb:81


ちょっと調べてみたところ、doc/HOWTO-make-io.rd には

> ==== stripped_subtitleとstripped_subtitle_to_html
> セクションのタイトルからカテゴリ指定部分を取り除いた文字列を返します。
> タイトルがない場合や、カテゴリ指定部分を取り除いた文字列が空文字("")の場合は
> nilを返します。

とありますが、
wiki_style.rb ではそのようになっていないようです。
以下のようにすることで解決できました。

$ diff -u wiki_style.rb.orig wiki_style.rb
--- wiki_style.rb.orig  Mon Dec 29 14:22:38 2003
+++ wiki_style.rb       Mon Dec 29 14:35:05 2003
@@ -354,7 +354,12 @@
 
                def strip_subtitle
                        return nil unless @subtitle
-                       @subtitle.sub(/^(\[[^\[]+?\])+\s*/,'')
+                       r = @subtitle.sub(/^(\[[^\[]+?\])+\s*/,'')
+                       if r == ""
+                               nil
+                       else
+                               r
+                       end
                end
        end
 

-- 
YAA  =A=
yaa@mail.ne.jp
$$ "You say this is Earl Grey? I'd swear that it was Darjeeling." $$


-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
_______________________________________________
tDiary-devel mailing list
tDiary-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tdiary-devel