1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
# bq.rb $Revision: 1.2 $
#
# bq: blockquoteȤäѤ
# ѥ:
# src: Ѥƥ
# title: ѸΥȥ
# url: ѸURL
#
# Ѹȥޤɽˤϡ륷Ȥp.source
# ɬפޤ:
#
# p.source {
# margin-top: 0.3em;
# text-align: right;
# font-size: 90%;
# }
#
# Copyright (C) 2002 by s.sawada <http://mwave.sppd.ne.jp/diary/>
#
=begin ChangeLog
2002-04-15 TADA Tadashi <http://sho.tdiary.net/>
* omit title or url.
* sarround with <p>...</p> by each lines in src.
2002-04-15 s.sawada
* create.
=end
def bq( src, title = nil, url = nil )
if url then
result = %Q[<blockquote cite="#{url}" title="#{title}">\n]
elsif title
result = %Q[<blockquote title="#{title}">\n]
else
result = %Q[<blockquote>\n]
end
result << %Q[<p>#{src.gsub( /\n/, "</p>\n<p>" )}</p>\n].sub( %r[<p></p>], '' )
result << %Q[</blockquote>\n]
if url then
result << %Q[<p class="source">[<cite><a href="#{url}" title="#{title}">#{title}</a></cite>]</p>\n]
elsif title
result << %Q[<p class="source">[<cite>#{title}</cite>]</p>\n]
end
result
end
|