File: bq.rb

package info (click to toggle)
tdiary 2.0.1-1sarge1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 7,220 kB
  • ctags: 1,667
  • sloc: ruby: 20,044; lisp: 476; makefile: 91; sql: 32; sh: 31
file content (46 lines) | stat: -rw-r--r-- 1,198 bytes parent folder | download
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