# Copyright (C) 2003-2005 Kouichirou Eto, All rights reserved.

# This is sample code to make plugin in qwikWeb.
#
# If you want to know how to make plugin, see below url.
# -> http://qwik.jp/HowToMakePlugin.html

module Qwik
  class Action
    def plg_tt(text)
      [:tt, text]
    end

    def plg_quote
      text = yield
      ar = []
      text.each {|line|
	ar << line
	ar << [:br]
      }
      [:blockquote,
	[:p, {:style=>"font-size:smaller;"}, *ar]]
    end
  end
end

if $0 == __FILE__
  $LOAD_PATH << "../../lib" unless $LOAD_PATH.include?("../../lib")
  require "t/test"
  $debug = true
end

if $debug
  class TC_ActSample2 < Test::Unit::TestCase
    include TestSession

    def test_all
      # test plg_tt
      assert_wiki([:tt, "t"], "{{tt(t)}}")

      # test plg_quote
      assert_wiki([:blockquote, [:p, {:style=>"font-size:smaller;"}]],
		  "{{quote}}")
      assert_wiki([:blockquote, [:p, {:style=>"font-size:smaller;"}]],
		  "{{quote\n\n}}")
      assert_wiki([:blockquote, [:p, {:style=>"font-size:smaller;"},
		      "t", [:br]]],
		  "{{quote\nt\n}}")
      assert_wiki([:blockquote, [:p, {:style=>"font-size:smaller;"},
		      "t1\n", [:br],
		      "t2", [:br]]],
		  "{{quote\nt1\nt2\n}}")
    end
  end
end
