tdiary-style-emptdiary 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Changelog.md +13 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +674 -0
- data/README.md +50 -0
- data/README.rd +83 -0
- data/README.rd.en +78 -0
- data/Rakefile +6 -0
- data/lib/tdiary-style-emptdiary.rb +1 -0
- data/lib/tdiary/style/emptdiary.rb +158 -0
- data/lib/tdiary/style/emptdiary/version.rb +7 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/tdiary/style/emptdiary_spec.rb +162 -0
- data/tdiary-style-emptdiary.gemspec +26 -0
- metadata +119 -0
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Tdiary::Style::Emptdiary
|
2
|
+
|
3
|
+
This style is an extension to the tDiary style which allows plug-in
|
4
|
+
arguments to have empty lines. In short, this style preserves empty
|
5
|
+
lines between <% and %> when splltting the input into sections.
|
6
|
+
|
7
|
+
The latest version of this file can be downloaded from [http://zunda.freeshell.org/d/misc/style/emptdiary/emptdiary_style.rb](http://zunda.freeshell.org/d/misc/style/emptdiary/emptdiary_style.rb)
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
gem 'tdiary-style-emptdiary'
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install tdiary-style-emptdiary
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
if you want to use this style, add the following line into tdiary.conf:
|
26
|
+
|
27
|
+
@style = 'emptdiary'
|
28
|
+
|
29
|
+
Please see README.rd or README.rd.en for further explanation.
|
30
|
+
|
31
|
+
## Acknowledgements
|
32
|
+
|
33
|
+
This style is realized using TdiarySection and TdiaryDiary as super-classes. I thank the authors of tdiary\_style.rb for providing such flexible classes.
|
34
|
+
|
35
|
+
```EmptdiaryDiary::to_html4``` and ```EmptdiaryDiary::to_chtml``` are copied from tdiary_style.rb and slightly edited as follows:
|
36
|
+
|
37
|
+
* split_unless_plugin() is inserted before each collect()
|
38
|
+
* Regexp is chanegd from ^ to \A
|
39
|
+
|
40
|
+
## Contributing
|
41
|
+
|
42
|
+
1. Fork it
|
43
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
44
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
45
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
46
|
+
5. Create new Pull Request
|
47
|
+
|
48
|
+
## Copyright
|
49
|
+
|
50
|
+
* Copyright 2003 zunda <zunda at freeshell.org>
|
data/README.rd
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
=begin
|
2
|
+
= emptDiaryスタイル((-$Id: README.rd,v 1.6 2008-03-02 09:01:20 kazuhiko Exp $-))
|
3
|
+
|
4
|
+
== 概要
|
5
|
+
((:emptDiaryスタイル:))((-emptDiaryは'empty line permitted tDiary style'
|
6
|
+
を省略したものです。長いねぇ。-))は、((:tDiaryス タイル:))に加えて、プラ
|
7
|
+
グインの引数に空白行を許すスタイルです。このスタイルを使うと、日記をセク
|
8
|
+
ションに分ける際に、<%と%>の間の空白行を無視してもらえます。
|
9
|
+
|
10
|
+
日記にプログラムリストなどを書く場合に、リストが空白行を含むと、
|
11
|
+
((:tDiaryス タイル:))ではリストの途中から次のセクションになってしまいま
|
12
|
+
す。((:emptDiaryスタイル:))では、プラグインの引数の中の空白を無視するの
|
13
|
+
で、例えばpre.rbプラグインのヒアドキュメントとしてプログラムリストを記述
|
14
|
+
することで、プログラムリストに何の変更もなく、日記にリストを書くことがで
|
15
|
+
きます。
|
16
|
+
|
17
|
+
((:emptDiaryスタイル:))の最新版は、
|
18
|
+
((<URL:http://zunda.freeshell.org/d/misc/style/emptdiary/emptdiary_style.rb>))から、
|
19
|
+
このファイルの最新版は、
|
20
|
+
((<URL:http://zunda.freeshell.org/d/misc/style/emptdiary/README.rd>))か
|
21
|
+
ら、 入手できるでしょう。
|
22
|
+
|
23
|
+
また、pre.rbの最新版は、
|
24
|
+
((<URL:http://zunda.freeshell.org/d/plugin/pre.rb>))から入手できるはずで
|
25
|
+
す。
|
26
|
+
|
27
|
+
== Usage
|
28
|
+
このスタイルを使うには、
|
29
|
+
(1) emptdiary_style.rb ファイルを、tdiary/ ディレクトリにコピーしてくだ
|
30
|
+
さい。tdiary/ ディレクトリは、tdiary.rb ファイルのあるトップディレク
|
31
|
+
トリの下にあります。
|
32
|
+
(2) tdiary.confに以下の行を書いてください。
|
33
|
+
@style = 'emptDiary'
|
34
|
+
|
35
|
+
日記は、((:tDiaryスタイル:))とほとんど同じように書くことができます。
|
36
|
+
HOWTO-write-tDiary.htmlに書かれている通り、
|
37
|
+
* 空白無しで始まる行は、((:セクションタイトル:))になります。この行には、
|
38
|
+
((:セクションアンカー:))が付きます。
|
39
|
+
* ((:セクションタイトル:))に続く行は、その((:セクション:))の内容になりま
|
40
|
+
す。
|
41
|
+
* 空白行によって、次の((:セクション:))と分かれます。
|
42
|
+
* ((:セクション:))の最初の行を空白や<で始めることによって、
|
43
|
+
((:セクションタイトル:))の無い((:セクション:))を作ることができます。
|
44
|
+
|
45
|
+
((:emptDiaryスタイル:))では、上記のルールに加えて、
|
46
|
+
* <%と%>に囲まれた空白行は、セクションを分割する際に無視されます。つまり、
|
47
|
+
あるセクションに、<%と%>に囲まれた空白行を含めることができます。
|
48
|
+
* 副作用として、日記には、<%と%>が同数、それぞれペアになって含まれていな
|
49
|
+
いといけません。
|
50
|
+
|
51
|
+
つまり、pre.rbを使って、
|
52
|
+
セクションタイトル
|
53
|
+
<p>セクションの内容</p>
|
54
|
+
<%=pre <<'_PRE'
|
55
|
+
#include <stdio.h>
|
56
|
+
|
57
|
+
/* 上記は空白行 */
|
58
|
+
int
|
59
|
+
main (int argc, char *argv[])
|
60
|
+
{
|
61
|
+
puts ("Hello world.");
|
62
|
+
}
|
63
|
+
_PRE
|
64
|
+
%>
|
65
|
+
などというセクションを作ることができます。不等号やアンパーサンドの実体参
|
66
|
+
照への変換は、pre.rbで行われることに注意してください。
|
67
|
+
|
68
|
+
== 謝辞
|
69
|
+
このスタイルは、((:tDiaryスタイル:))のTdiarySectionとTdiaryDiaryをsuper
|
70
|
+
classとして実装されています。このようなフレキシブルなクラスを提供されて
|
71
|
+
いる、tdiary_style.rbの著者の方々に感謝します。
|
72
|
+
|
73
|
+
== 著作権
|
74
|
+
Copyright 2003 zunda <zunda at freeshell.org>
|
75
|
+
|
76
|
+
Permission is granted for use, copying, modification, distribution,
|
77
|
+
and distribution of modified versions of this work under the terms
|
78
|
+
of GPL version 2 or later.
|
79
|
+
=end
|
80
|
+
=begin ChangeLog
|
81
|
+
* Mon Feb 17, 2003 zunda <zunda at freeshell.org>
|
82
|
+
- first draft
|
83
|
+
=end
|
data/README.rd.en
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
=begin
|
2
|
+
= emptDiary style((-$Id: README.rd.en,v 1.5 2003-11-06 09:43:46 zunda Exp $-))
|
3
|
+
|
4
|
+
== Summary
|
5
|
+
((:emptDiary style:))((-emptDiary is an abbreviation for 'empty line
|
6
|
+
permitted tDiary style'. Very long, isn't it?-)) is an extension to the
|
7
|
+
((:tDiary style:)) which allows plug-in arguments to have empty lines.
|
8
|
+
In short, this style preserves empty lines between <% and %> when
|
9
|
+
splltting the input into sections.
|
10
|
+
|
11
|
+
Sometimes, you would want to include your program list in your diary. In
|
12
|
+
the case, the ((:tDiary style:)) rule gets in the way: an empty line in
|
13
|
+
the program list makes a second section. ((:emptDiary style:)) permits
|
14
|
+
empty lines in the arguments of plug-ins. Thus, using e.g. pre.rb
|
15
|
+
plugin, you can show your program list without modifying your it.
|
16
|
+
|
17
|
+
|
18
|
+
The latest version of this style can be downloaded from
|
19
|
+
((<URL:http://zunda.freeshell.org/d/misc/style/emptdiary/emptdiary_style.rb>)),
|
20
|
+
and the latest version of this document can be downloaded from
|
21
|
+
((<URL:http://zunda.freeshell.org/d/misc/style/emptdiary/README.rd.en>)).
|
22
|
+
|
23
|
+
== Usage
|
24
|
+
If you want to use this style
|
25
|
+
(1) copy the file emptdiary_style.rb into the tdiary/ directory under
|
26
|
+
the top directory where tdiary.rb sits.
|
27
|
+
(2) add the following line into tdiary.conf:
|
28
|
+
@style = 'emptDiary'
|
29
|
+
|
30
|
+
You can write your diaries in almost the same manner as you have done
|
31
|
+
with the tDiary style as described in the file HOWTO-write-tDiary.html.
|
32
|
+
In short:
|
33
|
+
* A line beginning without a space becomes a ((:section title:)) with a
|
34
|
+
((:section anchor:)),
|
35
|
+
* Lines following the ((:section title:)) become the body of the
|
36
|
+
((:section:)),
|
37
|
+
* An empty line changes ((:section:))s, but
|
38
|
+
* You can create a ((:section:)) with a ((:section anchor:)) but a
|
39
|
+
((:section title:)) with the first line beginning with a space.
|
40
|
+
|
41
|
+
((:emptDiary style:)) adds the follwing rules:
|
42
|
+
* Empty lines between <% and %> are ignored when parsing your text into
|
43
|
+
sections. Thus, you can include empty lines between <% and %>.
|
44
|
+
As a side effect
|
45
|
+
* You have to keep <% and %>'s in the pairs.
|
46
|
+
|
47
|
+
Thus, using pre.rb plugin, you can write ((*A*)) section like:
|
48
|
+
title of the section
|
49
|
+
<p>Descriptino of the program</p>
|
50
|
+
<%=pre <<'_PRE'
|
51
|
+
#include <stdio.h>
|
52
|
+
|
53
|
+
/* above is an empty line */
|
54
|
+
int
|
55
|
+
main (int argc, char *argv[])
|
56
|
+
{
|
57
|
+
puts ("Hello world.");
|
58
|
+
}
|
59
|
+
_PRE
|
60
|
+
%>
|
61
|
+
Please note that the <, >, and & charactors are escaped by the pre plugin.
|
62
|
+
|
63
|
+
== Acknowledgements
|
64
|
+
This style is realized using TdiarySection and TdiaryDiary as
|
65
|
+
super-classes. I thank the authors of tdiary_style.rb for providing such
|
66
|
+
flexible classes.
|
67
|
+
|
68
|
+
== Copyright
|
69
|
+
Copyright 2003 zunda <zunda at freeshell.org>
|
70
|
+
|
71
|
+
Permission is granted for use, copying, modification, distribution,
|
72
|
+
and distribution of modified versions of this work under the terms
|
73
|
+
of GPL version 2 or later.
|
74
|
+
=end
|
75
|
+
=begin ChangeLog
|
76
|
+
* Mon Feb 17, 2003 zunda <zunda at freeshell.org>
|
77
|
+
- first draft
|
78
|
+
=end
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'tdiary/style/emptdiary'
|
@@ -0,0 +1,158 @@
|
|
1
|
+
# -*- coding: utf-8; -*-
|
2
|
+
|
3
|
+
require 'tdiary/style/tdiary'
|
4
|
+
|
5
|
+
=begin
|
6
|
+
== Classes and methods defined in this style
|
7
|
+
Please note that not all are documented.
|
8
|
+
=end
|
9
|
+
|
10
|
+
module TDiary
|
11
|
+
module Style
|
12
|
+
=begin
|
13
|
+
=== TDiary::Emptdiary::EmptdiaryString < String
|
14
|
+
Extended String class not to divide things between <% and %>.
|
15
|
+
|
16
|
+
--- TDiary::Emptdiary::EmptdiaryString.split_unless_plugin ( delimiter = "\n\n" )
|
17
|
+
Returns an array of EmptdiaryString splitted at ((|delimiter|))
|
18
|
+
which is outside of <% and %> pairs. Specify ((|delimiter|)) as a
|
19
|
+
String showing a fragment of Regexp. This will be combined in a
|
20
|
+
Regexp like: /(#{delimiter)|<%|%>)/.
|
21
|
+
=end
|
22
|
+
class Emptdiary
|
23
|
+
class EmptdiaryString < String
|
24
|
+
def split_unless_plugin( delimiter = "\n\n+" )
|
25
|
+
result = Array.new
|
26
|
+
fragment = ''
|
27
|
+
nest = 0
|
28
|
+
remain = self.gsub(/.*?(#{delimiter}|<%|%>)/m) do
|
29
|
+
fragment += $&
|
30
|
+
case $1
|
31
|
+
when '<%'
|
32
|
+
nest += 1
|
33
|
+
when '%>'
|
34
|
+
nest -= 1
|
35
|
+
else
|
36
|
+
if nest == 0 then
|
37
|
+
fragment.sub!( /#{delimiter}\z/, '' )
|
38
|
+
result << Emptdiary::EmptdiaryString.new( fragment ) unless fragment.empty?
|
39
|
+
fragment = ''
|
40
|
+
end
|
41
|
+
end
|
42
|
+
''
|
43
|
+
end
|
44
|
+
fragment += remain
|
45
|
+
fragment.sub!( /#{delimiter}\z/, '' )
|
46
|
+
result << Emptdiary::EmptdiaryString.new( fragment ) unless fragment.empty?
|
47
|
+
result
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
=begin
|
53
|
+
=== TDiary::EmptdiartySection < TdiarySection
|
54
|
+
Almost the same as TdiarySection but usess split_unless_plugin instead
|
55
|
+
of split. initialize method is overrideen.
|
56
|
+
=end
|
57
|
+
class EmptdiarySection < TdiarySection
|
58
|
+
def initialize( fragment, author = nil )
|
59
|
+
@author = author
|
60
|
+
lines = fragment.split_unless_plugin( "\n+" )
|
61
|
+
if lines.size > 1 then
|
62
|
+
if /\A<</ =~ lines[0]
|
63
|
+
@subtitle = lines.shift.chomp.sub( /\A</, '' )
|
64
|
+
elsif /\A[ <]/u !~ lines[0]
|
65
|
+
@subtitle = lines.shift.chomp
|
66
|
+
end
|
67
|
+
end
|
68
|
+
@body = Emptdiary::EmptdiaryString.new( lines.join( "\n" ) )
|
69
|
+
@categories = get_categories
|
70
|
+
@stripped_subtitle = strip_subtitle
|
71
|
+
end
|
72
|
+
|
73
|
+
def body_to_html
|
74
|
+
html = ""
|
75
|
+
@body.split_unless_plugin( "\n" ).each do |p|
|
76
|
+
if /\A</ =~ p then
|
77
|
+
html << p
|
78
|
+
else
|
79
|
+
html << "<p>#{p}</p>"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
html
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
=begin
|
87
|
+
=== TDiary::EmptdiaryDiary < TdiaryDiary
|
88
|
+
Almost the same as TdiarySection but usess split_unless_plugin instead
|
89
|
+
of split. append method is overriden and makes EmptdiarySection with
|
90
|
+
body being an EmptdiaryString. Also, to_html4 and to_chtml methods are
|
91
|
+
overridden to split_unless_plugin before collect'ing the body of the
|
92
|
+
sections.
|
93
|
+
=end
|
94
|
+
class EmptdiaryDiary < TdiaryDiary
|
95
|
+
def style
|
96
|
+
'emptdiary'
|
97
|
+
end
|
98
|
+
|
99
|
+
def append( body, author = nil )
|
100
|
+
Emptdiary::EmptdiaryString.new(body.gsub( /\r/, '' )).split_unless_plugin( "\n\n+" ).each do |fragment|
|
101
|
+
section = EmptdiarySection::new( fragment, author )
|
102
|
+
@sections << section if section
|
103
|
+
end
|
104
|
+
@last_modified = Time::now
|
105
|
+
self
|
106
|
+
end
|
107
|
+
|
108
|
+
def to_html4( opt )
|
109
|
+
r = ''
|
110
|
+
each_section do |section|
|
111
|
+
r << %Q[<div class="section">\n]
|
112
|
+
r << %Q[<%=section_enter_proc( Time::at( #{date.to_i} ) )%>\n]
|
113
|
+
if section.subtitle then
|
114
|
+
r << %Q[<h3><%= subtitle_proc( Time::at( #{date.to_i} ), #{section.subtitle.dump.gsub( /%/, '\\\\045' )} ) %></h3>\n]
|
115
|
+
end
|
116
|
+
if /\A</ =~ section.body then
|
117
|
+
r << %Q[#{section.body}]
|
118
|
+
elsif section.subtitle
|
119
|
+
r << %Q[<p>#{section.body.split_unless_plugin( "\n+" ).collect{|l|l.chomp.sub( /\A[ ]/u, '')}.join( "</p>\n<p>" )}</p>]
|
120
|
+
else
|
121
|
+
r << %Q[<p><%= subtitle_proc( Time::at( #{date.to_i} ), nil ) %>]
|
122
|
+
r << %Q[#{section.body.split_unless_plugin( "\n+" ).collect{|l|l.chomp.sub( /\A[ ]/u, '' )}.join( "</p>\n<p>" )}</p>]
|
123
|
+
end
|
124
|
+
r << %Q[<%=section_leave_proc( Time::at( #{date.to_i} ) )%>\n]
|
125
|
+
r << %Q[</div>]
|
126
|
+
end
|
127
|
+
r
|
128
|
+
end
|
129
|
+
|
130
|
+
def to_chtml( opt )
|
131
|
+
r = ''
|
132
|
+
each_section do |section|
|
133
|
+
r << %Q[<%=section_enter_proc( Time::at( #{date.to_i} ) )%>\n]
|
134
|
+
if section.subtitle then
|
135
|
+
r << %Q[<H3><%= subtitle_proc( Time::at( #{date.to_i} ), #{section.subtitle.dump.gsub( /%/, '\\\\045' )} ) %></H3>\n]
|
136
|
+
end
|
137
|
+
if /\A</ =~ section.body then
|
138
|
+
r << section.body
|
139
|
+
elsif section.subtitle
|
140
|
+
r << %Q[<P>#{section.body.split_unless_plugin( "\n+" ).collect{|l|l.chomp.sub( /\A[ ]/u, '' )}.join( "</P>\n<P>" )}</P>]
|
141
|
+
else
|
142
|
+
r << %Q[<P><%= subtitle_proc( Time::at( #{date.to_i} ), nil ) %>]
|
143
|
+
r << %Q[#{section.body.split_unless_plugin( "\n+" ).collect{|l|l.chomp.sub( /\A[ ]/u, '' )}.join( "</P>\n<P>" )}</P>]
|
144
|
+
end
|
145
|
+
r << %Q[<%=section_leave_proc( Time::at( #{date.to_i} ) )%>\n]
|
146
|
+
end
|
147
|
+
r
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
# Local Variables:
|
154
|
+
# mode: ruby
|
155
|
+
# indent-tabs-mode: t
|
156
|
+
# tab-width: 3
|
157
|
+
# ruby-indent-level: 3
|
158
|
+
# End:
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,162 @@
|
|
1
|
+
# -*- coding: utf-8; -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe TDiary::Style::EmptdiaryDiary do
|
5
|
+
before do
|
6
|
+
@diary = TDiary::Style::EmptdiaryDiary.new(Time::at( 1041346800 ), "TITLE", "")
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#append' do
|
10
|
+
before do
|
11
|
+
source = <<-'EOF'
|
12
|
+
subTitle
|
13
|
+
<p>honbun</p>
|
14
|
+
|
15
|
+
subTitle2
|
16
|
+
<p>honbun</p>
|
17
|
+
EOF
|
18
|
+
@diary.append(source)
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'HTML' do
|
22
|
+
before do
|
23
|
+
@html = <<-'EOF'
|
24
|
+
<div class="section">
|
25
|
+
<%=section_enter_proc( Time::at( 1041346800 ) )%>
|
26
|
+
<h3><%= subtitle_proc( Time::at( 1041346800 ), "subTitle" ) %></h3>
|
27
|
+
<p>honbun</p><%=section_leave_proc( Time::at( 1041346800 ) )%>
|
28
|
+
</div><div class="section">
|
29
|
+
<%=section_enter_proc( Time::at( 1041346800 ) )%>
|
30
|
+
<h3><%= subtitle_proc( Time::at( 1041346800 ), "subTitle2" ) %></h3>
|
31
|
+
<p>honbun</p><%=section_leave_proc( Time::at( 1041346800 ) )%>
|
32
|
+
</div>
|
33
|
+
EOF
|
34
|
+
end
|
35
|
+
it { @diary.to_html.should eq @html.chomp }
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'CHTML' do
|
39
|
+
before do
|
40
|
+
@html = <<-'EOF'
|
41
|
+
<%=section_enter_proc( Time::at( 1041346800 ) )%>
|
42
|
+
<H3><%= subtitle_proc( Time::at( 1041346800 ), "subTitle" ) %></H3>
|
43
|
+
<p>honbun</p><%=section_leave_proc( Time::at( 1041346800 ) )%>
|
44
|
+
<%=section_enter_proc( Time::at( 1041346800 ) )%>
|
45
|
+
<H3><%= subtitle_proc( Time::at( 1041346800 ), "subTitle2" ) %></H3>
|
46
|
+
<p>honbun</p><%=section_leave_proc( Time::at( 1041346800 ) )%>
|
47
|
+
EOF
|
48
|
+
end
|
49
|
+
it { @diary.to_html({}, :CHTML).should eq @html }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '#replace' do
|
54
|
+
before do
|
55
|
+
source = <<-'EOF'
|
56
|
+
subTitle
|
57
|
+
<p>honbun</p>
|
58
|
+
|
59
|
+
subTitle2
|
60
|
+
<p>honbun</p>
|
61
|
+
EOF
|
62
|
+
@diary.append(source)
|
63
|
+
|
64
|
+
replaced = <<-'EOF'
|
65
|
+
replaceTitle
|
66
|
+
<p>replace</p>
|
67
|
+
|
68
|
+
replaceTitle2
|
69
|
+
<p>replace</p>
|
70
|
+
|
71
|
+
EOF
|
72
|
+
@diary.replace(Time::at( 1041346800 ), "TITLE", replaced)
|
73
|
+
|
74
|
+
@html = <<-'EOF'
|
75
|
+
<div class="section">
|
76
|
+
<%=section_enter_proc( Time::at( 1041346800 ) )%>
|
77
|
+
<h3><%= subtitle_proc( Time::at( 1041346800 ), "replaceTitle" ) %></h3>
|
78
|
+
<p>replace</p><%=section_leave_proc( Time::at( 1041346800 ) )%>
|
79
|
+
</div><div class="section">
|
80
|
+
<%=section_enter_proc( Time::at( 1041346800 ) )%>
|
81
|
+
<h3><%= subtitle_proc( Time::at( 1041346800 ), "replaceTitle2" ) %></h3>
|
82
|
+
<p>replace</p><%=section_leave_proc( Time::at( 1041346800 ) )%>
|
83
|
+
</div>
|
84
|
+
EOF
|
85
|
+
end
|
86
|
+
it { @diary.to_html.should eq @html.chomp }
|
87
|
+
end
|
88
|
+
|
89
|
+
describe 'test_emptdiary_style_plugin' do
|
90
|
+
before do
|
91
|
+
source = <<-'EOF'
|
92
|
+
sectionTitle
|
93
|
+
<p>body</p>
|
94
|
+
<%=pre <<'_PRE'
|
95
|
+
#include <stdio.h>
|
96
|
+
|
97
|
+
/* comment */
|
98
|
+
int
|
99
|
+
main (int argc, char *argv[])
|
100
|
+
{
|
101
|
+
puts ("Hello world.");
|
102
|
+
}
|
103
|
+
_PRE
|
104
|
+
%>
|
105
|
+
EOF
|
106
|
+
@diary.append(source)
|
107
|
+
end
|
108
|
+
|
109
|
+
context 'HTML' do
|
110
|
+
before do
|
111
|
+
@html = <<-'EOF'
|
112
|
+
<div class="section">
|
113
|
+
<%=section_enter_proc( Time::at( 1041346800 ) )%>
|
114
|
+
<h3><%= subtitle_proc( Time::at( 1041346800 ), "sectionTitle" ) %></h3>
|
115
|
+
<p>body</p>
|
116
|
+
<%=pre <<'_PRE'
|
117
|
+
#include <stdio.h>
|
118
|
+
|
119
|
+
/* comment */
|
120
|
+
int
|
121
|
+
main (int argc, char *argv[])
|
122
|
+
{
|
123
|
+
puts ("Hello world.");
|
124
|
+
}
|
125
|
+
_PRE
|
126
|
+
%><%=section_leave_proc( Time::at( 1041346800 ) )%>
|
127
|
+
</div>
|
128
|
+
EOF
|
129
|
+
end
|
130
|
+
it { @diary.to_html.should eq @html.chomp }
|
131
|
+
end
|
132
|
+
|
133
|
+
context 'CHTML' do
|
134
|
+
before do
|
135
|
+
@html = <<-'EOF'
|
136
|
+
<%=section_enter_proc( Time::at( 1041346800 ) )%>
|
137
|
+
<H3><%= subtitle_proc( Time::at( 1041346800 ), "sectionTitle" ) %></H3>
|
138
|
+
<p>body</p>
|
139
|
+
<%=pre <<'_PRE'
|
140
|
+
#include <stdio.h>
|
141
|
+
|
142
|
+
/* comment */
|
143
|
+
int
|
144
|
+
main (int argc, char *argv[])
|
145
|
+
{
|
146
|
+
puts ("Hello world.");
|
147
|
+
}
|
148
|
+
_PRE
|
149
|
+
%><%=section_leave_proc( Time::at( 1041346800 ) )%>
|
150
|
+
EOF
|
151
|
+
end
|
152
|
+
it { @diary.to_html({}, :CHTML).should eq @html }
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
# Local Variables:
|
158
|
+
# mode: ruby
|
159
|
+
# indent-tabs-mode: t
|
160
|
+
# tab-width: 3
|
161
|
+
# ruby-indent-level: 3
|
162
|
+
# End:
|