File: bq.rb

package info (click to toggle)
tdiary 2.0.2%2B20060303-5
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 8,172 kB
  • ctags: 1,957
  • sloc: ruby: 23,926; lisp: 514; makefile: 87; sh: 71; sql: 32
file content (38 lines) | stat: -rw-r--r-- 1,073 bytes parent folder | download | duplicates (2)
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
# bq.rb $Revision: 1.2.2.1 $
#
# bq: blockquoteȤäѤ
#   ѥ᥿:
#     src:   Ѥƥ
#     title: ѸΥȥ
#     url:   ѸURL
#
#   Ѹȥ򤦤ޤɽˤϡ륷Ȥp.source
#   ɬפޤ:
#
#       p.source {
#          margin-top: 0.3em;
#          text-align: right;
#          font-size: 90%;
#       }
#
# Copyright (C) 2002 s.sawada <moonwave@ba2.so-net.ne.jp>
# You can redistribute it and/or modify it under GPL2.
#
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