pseudohikiparser 0.0.0.8.develop → 0.0.0.9.develop

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,13 +11,11 @@ module PseudoHiki
11
11
  include TableRowParser::InlineElement
12
12
 
13
13
  #for InlineParser
14
- LINK, IMG, EM, STRONG, DEL = %w(a img em strong del)
15
- HREF, SRC, ALT = %w(href src alt)
16
- PLAIN, PLUGIN = %w(plain span)
14
+ LINK, LITERAL, PLUGIN = %w(a code span)
15
+ BLANK, SPACE = "", " "
16
+ HREF, SRC, ALT, ID, CLASS, ROWSPAN, COLSPAN = %w(href src alt id class rowspan colspan)
17
17
  #for BlockParser
18
- DESC, VERB, QUOTE, TABLE, PARA, HR, UL, OL = %w(dl pre blockquote table p hr ul ol)
19
- SECTION = "section"
20
- DT, DD, TR, HEADING, LI = %w(dt dd tr h li)
18
+ DT, DD, LI = %w(dt dd li)
21
19
  DescSep = [InlineParser::DescSep]
22
20
 
23
21
  Formatter = {}
@@ -27,7 +25,7 @@ module PseudoHiki
27
25
 
28
26
  def self.setup_new_formatter(new_formatter, generator)
29
27
  new_formatter.each do |node_class, formatter|
30
- new_formatter[node_class] = formatter.dup
28
+ new_formatter[node_class] = formatter.clone
31
29
  new_formatter[node_class].generator = generator
32
30
  new_formatter[node_class].formatter = new_formatter
33
31
  end
@@ -76,9 +74,56 @@ module PseudoHiki
76
74
  chunks.push tree
77
75
  end
78
76
 
77
+ class ListLeafNodeFormatter < self
78
+ def create_self_element(tree)
79
+ super(tree).tap do |element|
80
+ element[ID] = tree.node_id.upcase if tree.node_id
81
+ end
82
+ end
83
+ end
84
+
85
+ [ [EmNode, "em"],
86
+ [StrongNode, "strong"],
87
+ [DelNode, "del"],
88
+ [LiteralNode, LITERAL],
89
+ [PluginNode, PLUGIN],
90
+ [LinkNode, LINK],
91
+ [InlineLeaf, nil],
92
+ [PlainNode, nil], #Until here is for InlineParser
93
+ [DescNode, "dl"],
94
+ [QuoteNode, "blockquote"],
95
+ [TableNode, "table"],
96
+ [ParagraphNode, "p"],
97
+ [HrNode, "hr"],
98
+ [ListNode, "ul"],
99
+ [EnumNode, "ol"],
100
+ [TableLeaf, "tr"],
101
+ [VerbatimNode, "pre"],
102
+ [CommentOutNode, nil],
103
+ [HeadingNode, "section"],
104
+ [DescLeaf, DT],
105
+ [TableCellNode, nil],
106
+ [HeadingLeaf, "h"], #Until here is for BlockParser
107
+ ].each {|node_class, element| Formatter[node_class] = self.new(element) }
108
+
109
+ #for InlineParser
110
+ ImgFormat = self.new("img")
111
+ #for BlockParser
112
+ Formatter[ListWrapNode] = ListLeafNodeFormatter.new(LI)
113
+ Formatter[EnumWrapNode] = ListLeafNodeFormatter.new(LI)
114
+
79
115
  #for InlineParser
80
116
 
81
- class LinkNodeFormatter < self
117
+ class << Formatter[PluginNode]
118
+ def visit(tree)
119
+ str = tree.join
120
+ return str if InlineParser::HEAD[str] or InlineParser::TAIL[str]
121
+ return str.strip * 2 if str == ' {' or str == '} '
122
+ super(tree)
123
+ end
124
+ end
125
+
126
+ class << Formatter[LinkNode]
82
127
  def visit(tree)
83
128
  tree = tree.dup
84
129
  caption = get_caption(tree)
@@ -107,13 +152,13 @@ module PseudoHiki
107
152
  end
108
153
  end
109
154
 
110
- class InlineLeafFormatter < self
155
+ class << Formatter[InlineLeaf]
111
156
  def visit(leaf)
112
157
  @generator.escape(leaf.first)
113
158
  end
114
159
  end
115
160
 
116
- class PlainNodeFormatter < self
161
+ class << Formatter[PlainNode]
117
162
  def create_self_element(tree=nil)
118
163
  @generator::Children.new
119
164
  end
@@ -121,32 +166,32 @@ module PseudoHiki
121
166
 
122
167
  #for BlockParser
123
168
 
124
- class VerbatimNodeFormatter < self
169
+ class << Formatter[VerbatimNode]
125
170
  def visit(tree)
126
171
  create_self_element.tap do |element|
127
172
  contents = @generator.escape(tree.join).gsub(BlockParser::URI_RE) do |url|
128
- @generator.create("a", url, "href" => url).to_s
173
+ @generator.create(LINK, url, HREF => url).to_s
129
174
  end
130
175
  element.push contents
131
176
  end
132
177
  end
133
178
  end
134
179
 
135
- class CommentOutNodeFormatter < self
136
- def visit(tree); ""; end
180
+ class << Formatter[CommentOutNode]
181
+ def visit(tree); BLANK; end
137
182
  end
138
183
 
139
- class HeadingNodeFormatter < self
184
+ class << Formatter[HeadingNode]
140
185
  def create_self_element(tree)
141
186
  super(tree).tap do |element|
142
187
  heading_level = "h#{tree.first.nominal_level}"
143
- element['class'] ||= heading_level
144
- element['class'] += " " + heading_level unless element['class'] == heading_level
188
+ element[CLASS] ||= heading_level
189
+ element[CLASS] += SPACE + heading_level unless element[CLASS] == heading_level
145
190
  end
146
191
  end
147
192
  end
148
193
 
149
- class DescLeafFormatter < self
194
+ class << Formatter[DescLeaf]
150
195
  def visit(tree)
151
196
  tree = tree.dup
152
197
  element = @generator::Children.new
@@ -162,61 +207,24 @@ module PseudoHiki
162
207
  end
163
208
  end
164
209
 
165
- class TableCellNodeFormatter < self
210
+ class << Formatter[TableCellNode]
166
211
  def visit(tree)
167
212
  @element_name = tree.cell_type
168
213
  super(tree).tap do |element|
169
- element["rowspan"] = tree.rowspan if tree.rowspan > 1
170
- element["colspan"] = tree.colspan if tree.colspan > 1
214
+ element[ROWSPAN] = tree.rowspan if tree.rowspan > 1
215
+ element[COLSPAN] = tree.colspan if tree.colspan > 1
171
216
  # element.push "&#160;" if element.empty? # &#160; = &nbsp; this line would be necessary for HTML 4 or XHTML 1.0
172
217
  end
173
218
  end
174
219
  end
175
220
 
176
- class HeadingLeafFormatter < self
221
+ class << Formatter[HeadingLeaf]
177
222
  def create_self_element(tree)
178
223
  @generator.create(@element_name+tree.nominal_level.to_s).tap do |element|
179
- element["id"] = tree.node_id.upcase if tree.node_id
180
- end
181
- end
182
- end
183
-
184
- class ListLeafNodeFormatter < self
185
- def create_self_element(tree)
186
- super(tree).tap do |element|
187
- element["id"] = tree.node_id.upcase if tree.node_id
224
+ element[ID] = tree.node_id.upcase if tree.node_id
188
225
  end
189
226
  end
190
227
  end
191
-
192
- [ [EmNode,EM],
193
- [StrongNode,STRONG],
194
- [DelNode,DEL],
195
- [PluginNode,PLUGIN], #Until here is for InlineParser
196
- [DescNode, DESC],
197
- [QuoteNode, QUOTE],
198
- [TableNode, TABLE],
199
- [ParagraphNode, PARA],
200
- [HrNode, HR],
201
- [ListNode, UL],
202
- [EnumNode, OL],
203
- [TableLeaf, TR], #Until here is for BlockParser
204
- ].each {|node_class, element| Formatter[node_class] = self.new(element) }
205
-
206
- #for InlineParser
207
- ImgFormat = self.new(IMG)
208
- Formatter[LinkNode] = LinkNodeFormatter.new(LINK)
209
- Formatter[InlineLeaf] = InlineLeafFormatter.new(nil)
210
- Formatter[PlainNode] = PlainNodeFormatter.new(PLAIN)
211
- #for BlockParser
212
- Formatter[VerbatimNode] = VerbatimNodeFormatter.new(VERB)
213
- Formatter[CommentOutNode] = CommentOutNodeFormatter.new(nil)
214
- Formatter[HeadingNode] = HeadingNodeFormatter.new(SECTION)
215
- Formatter[DescLeaf] = DescLeafFormatter.new(DT)
216
- Formatter[TableCellNode] = TableCellNodeFormatter.new(nil)
217
- Formatter[HeadingLeaf] = HeadingLeafFormatter.new(HEADING)
218
- Formatter[ListWrapNode] = ListLeafNodeFormatter.new(LI)
219
- Formatter[EnumWrapNode] = ListLeafNodeFormatter.new(LI)
220
228
  end
221
229
 
222
230
  class XhtmlFormat < HtmlFormat
@@ -27,7 +27,7 @@ module PseudoHiki
27
27
  # class LinkSepLeaf < InlineLeaf; end
28
28
 
29
29
  PseudoHiki.subclass_of(InlineNode, binding,
30
- %w(LinkNode EmNode StrongNode DelNode PlainNode PluginNode))
30
+ %w(LinkNode EmNode StrongNode DelNode PlainNode LiteralNode PluginNode))
31
31
 
32
32
  LinkSep, TableSep, DescSep = %w(| || :)
33
33
  end
@@ -42,6 +42,7 @@ module PseudoHiki
42
42
  [EmNode, "''", "''"],
43
43
  [StrongNode, "'''", "'''"],
44
44
  [DelNode, "==", "=="],
45
+ [LiteralNode, "``", "``"],
45
46
  [PluginNode, "{{","}}"]].each do |type, head, tail|
46
47
  HEAD[head] = type
47
48
  TAIL[tail] = type
@@ -13,6 +13,18 @@ module PseudoHiki
13
13
  include TableRowParser::InlineElement
14
14
  include BlockParser::BlockElement
15
15
 
16
+ Formatters = {}
17
+
18
+ def self.format(tree, options={ :strict_mode=> false, :gfm_style => false })
19
+ if Formatters.empty?
20
+ default_options = { :strict_mode=> false, :gfm_style => false }
21
+ Formatters[default_options] = create(default_options)
22
+ end
23
+
24
+ Formatters[options] ||= create(options)
25
+ Formatters[options].format(tree)
26
+ end
27
+
16
28
  def initialize(formatter={}, options={ :strict_mode=> false, :gfm_style => false })
17
29
  @formatter = formatter
18
30
  options_given_via_block = nil
@@ -78,7 +90,8 @@ module PseudoHiki
78
90
  formatter[EmNode] = EmNodeFormatter.new(formatter, options)
79
91
  formatter[StrongNode] = StrongNodeFormatter.new(formatter, options)
80
92
  formatter[DelNode] = DelNodeFormatter.new(formatter, options)
81
- # formatter[PluginNode] = PluginNodeFormatter.new(formatter, options)
93
+ formatter[LiteralNode] = LiteralNodeFormatter.new(formatter, options)
94
+ formatter[PluginNode] = PluginNodeFormatter.new(formatter, options)
82
95
  # formatter[DescLeaf] = DescLeafFormatter.new(formatter, options)
83
96
  # formatter[TableCellNode] = TableCellNodeFormatter.new(formatter, options)
84
97
  formatter[VerbatimLeaf] = VerbatimLeafFormatter.new(formatter, options)
@@ -172,7 +185,20 @@ module PseudoHiki
172
185
  end
173
186
  end
174
187
 
175
- # class PluginNodeFormatter < self; end
188
+ class LiteralNodeFormatter < self
189
+ def visit(tree)
190
+ "`#{super(tree).join.strip}`"
191
+ end
192
+ end
193
+
194
+ class PluginNodeFormatter < self
195
+ def visit(tree)
196
+ str =tree.join
197
+ return str.strip * 2 if str == " {" or str == "} "
198
+ super(tree)
199
+ end
200
+ end
201
+
176
202
  # class DescLeafFormatter < self; end
177
203
  # class TableCellNodeFormatter < self; end
178
204
 
@@ -268,7 +294,7 @@ module PseudoHiki
268
294
  format%[cell]
269
295
  end
270
296
  "|#{formatted_row.join("|") }|#{$/}"
271
- end.join
297
+ end.join+$/
272
298
  end
273
299
 
274
300
  def format_html_table(tree)
@@ -66,6 +66,7 @@ module PseudoHiki
66
66
  formatter[TableNode] = TableNodeFormatter.new(formatter, options)
67
67
  formatter[CommentOutNode] = CommentOutNodeFormatter.new(formatter, options)
68
68
  formatter[ParagraphNode] = ParagraphNodeFormatter.new(formatter, options)
69
+ formatter[PluginNode] = PluginNodeFormatter.new(formatter, options)
69
70
  main_formatter
70
71
  end
71
72
 
@@ -215,5 +216,13 @@ ERROR_TEXT
215
216
  super(tree).join+$/
216
217
  end
217
218
  end
219
+
220
+ class PluginNodeFormatter < self
221
+ def visit(tree)
222
+ str =tree.join
223
+ return str.strip * 2 if str == " {" or str == "} "
224
+ super(tree)
225
+ end
226
+ end
218
227
  end
219
228
  end
@@ -1,3 +1,3 @@
1
1
  module PseudoHiki
2
- VERSION = "0.0.0.8.develop"
2
+ VERSION = "0.0.0.9.develop"
3
3
  end
@@ -1,9 +1,9 @@
1
1
  #/usr/bin/env ruby
2
2
 
3
- require 'test/unit'
3
+ require 'minitest/autorun'
4
4
  require 'lib/pseudohiki/blockparser'
5
5
 
6
- class TC_BlockLeaf < Test::Unit::TestCase
6
+ class TC_BlockLeaf < MiniTest::Unit::TestCase
7
7
  include PseudoHiki::BlockParser::BlockElement
8
8
 
9
9
  def test_block_when_descnode
@@ -1,9 +1,9 @@
1
1
  #/usr/bin/env ruby
2
2
 
3
- require 'test/unit'
3
+ require 'minitest/autorun'
4
4
  require 'lib/htmlelement'
5
5
 
6
- class TC_HtmlElement < Test::Unit::TestCase
6
+ class TC_HtmlElement < MiniTest::Unit::TestCase
7
7
 
8
8
  def test_format_attributes
9
9
  a = HtmlElement.create("a")
@@ -1,11 +1,10 @@
1
1
  #/usr/bin/env ruby
2
2
 
3
- require 'test/unit'
3
+ require 'minitest/autorun'
4
4
  require 'lib/pseudohiki/blockparser'
5
5
  require 'lib/pseudohiki/htmlformat'
6
6
 
7
-
8
- class TC_HtmlFormat < Test::Unit::TestCase
7
+ class TC_HtmlFormat < MiniTest::Unit::TestCase
9
8
  include PseudoHiki
10
9
 
11
10
  class ::String
@@ -98,6 +97,8 @@ HTML
98
97
 
99
98
  a paragraph with an ''emphasised'' word.
100
99
  a paragraph with a [[link|http://www.example.org/]].
100
+
101
+ a paragraph with a ``literal`` word.
101
102
  TEXT
102
103
 
103
104
  html = <<HTML
@@ -105,6 +106,8 @@ TEXT
105
106
  <h2>heading2</h2>
106
107
  <p>
107
108
  a paragraph with an <em>emphasised</em> word.a paragraph with a <a href="http://www.example.org/">link</a>.</p>
109
+ <p>
110
+ a paragraph with a <code>literal</code> word.</p>
108
111
  <!-- end of section h2 -->
109
112
  </div>
110
113
  HTML
@@ -112,6 +115,30 @@ HTML
112
115
  assert_equal(html,convert_text_to_html(text))
113
116
  end
114
117
 
118
+ def test_plugin
119
+ text = <<TEXT
120
+ a paragraph with several plugin tags.
121
+ {{''}} should be presented as two quotation marks.
122
+ {{ {}} should be presented as two left curly braces.
123
+ {{} }} should be presented as two right curly braces.
124
+ {{in span}} should be presented as <span>in span</span>.
125
+ TEXT
126
+
127
+ html = <<HTML
128
+ <p>
129
+ a paragraph with several plugin tags.
130
+ '' should be presented as two quotation marks.
131
+ {{ should be presented as two left curly braces.
132
+ }} should be presented as two right curly braces.
133
+ <span>in span</span> should be presented as &lt;span&gt;in span&lt;/span&gt;.
134
+ </p>
135
+ HTML
136
+
137
+ tree = BlockParser.parse(text)
138
+ assert_equal(html, HtmlFormat.format(tree).to_s)
139
+ assert_equal(html, XhtmlFormat.format(tree).to_s)
140
+ end
141
+
115
142
  def test_table
116
143
  text = <<TEXT
117
144
  ||!col||!^[[col|link]]||>col
@@ -1,9 +1,9 @@
1
1
  #/usr/bin/env ruby
2
2
 
3
- require 'test/unit'
3
+ require 'minitest/autorun'
4
4
  require 'lib/pseudohiki/htmlplugin'
5
5
 
6
- class TC_HtmlPlugin < Test::Unit::TestCase
6
+ class TC_HtmlPlugin < MiniTest::Unit::TestCase
7
7
  include PseudoHiki
8
8
 
9
9
  def test_visit_pluginnode
@@ -1,9 +1,9 @@
1
1
  #/usr/bin/env ruby
2
2
 
3
- require 'test/unit'
3
+ require 'minitest/autorun'
4
4
  require 'htmlelement/htmltemplate'
5
5
 
6
- class TC_HtmlTemplate < Test::Unit::TestCase
6
+ class TC_HtmlTemplate < MiniTest::Unit::TestCase
7
7
 
8
8
  def test_new
9
9
  html_result = <<HTML
@@ -94,7 +94,7 @@ HTML
94
94
  end
95
95
  end
96
96
 
97
- class TC_XhtmlTemplate < Test::Unit::TestCase
97
+ class TC_XhtmlTemplate < MiniTest::Unit::TestCase
98
98
 
99
99
  def test_new
100
100
  html_result = <<HTML
@@ -1,16 +1,16 @@
1
1
  #/usr/bin/env ruby
2
2
 
3
- require 'test/unit'
3
+ require 'minitest/autorun'
4
4
  require 'lib/pseudohiki/inlineparser'
5
5
  require 'lib/pseudohiki/htmlformat'
6
6
 
7
7
 
8
- class TC_InlineParser < Test::Unit::TestCase
8
+ class TC_InlineParser < MiniTest::Unit::TestCase
9
9
  include PseudoHiki
10
10
 
11
11
  def test_inlineparser_compile_token_pat
12
12
  parser = InlineParser.new("")
13
- assert_equal(/'''|\}\}|\|\||\{\{|\]\]|\[\[|==|''|\||:/,parser.token_pat)
13
+ assert_equal(/'''|\}\}|\|\||\{\{|``|\]\]|\[\[|==|''|\||:/,parser.token_pat)
14
14
  end
15
15
 
16
16
  def test_inlineparser_split_into_tokens
@@ -47,7 +47,7 @@ class TC_InlineParser < Test::Unit::TestCase
47
47
  end
48
48
  end
49
49
 
50
- class TC_HtmlFormat < Test::Unit::TestCase
50
+ class TC_HtmlFormat < MiniTest::Unit::TestCase
51
51
  include PseudoHiki
52
52
 
53
53
  def test_visit_linknode
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'test/unit'
3
+ require 'minitest/autorun'
4
4
  require 'pseudohiki/markdownformat'
5
5
 
6
- class TC_MarkDownFormat < Test::Unit::TestCase
6
+ class TC_MarkDownFormat < MiniTest::Unit::TestCase
7
7
  include PseudoHiki
8
8
 
9
9
  def setup
@@ -12,6 +12,38 @@ class TC_MarkDownFormat < Test::Unit::TestCase
12
12
  @forced_gfm_formatter = MarkDownFormat.create({ :gfm_style => :force })
13
13
  end
14
14
 
15
+ def test_self_format
16
+ text = <<TEXT
17
+ ||!header 1||!header 2
18
+ ||cell 1-1||cell 1-2
19
+ ||cell 2-1||cell 2-2
20
+ ||cell 3-1 (a bit wider)||cell 3-2
21
+ TEXT
22
+
23
+ md_text = <<TEXT
24
+ <table>
25
+ <tr><th>header 1</th><th>header 2</th></tr>
26
+ <tr><td>cell 1-1</td><td>cell 1-2</td></tr>
27
+ <tr><td>cell 2-1</td><td>cell 2-2</td></tr>
28
+ <tr><td>cell 3-1 (a bit wider)</td><td>cell 3-2</td></tr>
29
+ </table>
30
+
31
+ TEXT
32
+
33
+ gfm_text = <<TEXT
34
+ |header 1 |header 2|
35
+ |----------------------|--------|
36
+ |cell 1-1 |cell 1-2|
37
+ |cell 2-1 |cell 2-2|
38
+ |cell 3-1 (a bit wider)|cell 3-2|
39
+
40
+ TEXT
41
+
42
+ tree = BlockParser.parse(text)
43
+ assert_equal(md_text, MarkDownFormat.format(tree))
44
+ assert_equal(gfm_text, MarkDownFormat.format(tree, :gfm_style => true))
45
+ end
46
+
15
47
  def test_plain
16
48
  text = <<TEXT
17
49
  test string
@@ -54,6 +86,33 @@ IMAGE
54
86
  assert_equal("a ~~striked out string~~#{$/}", @formatter.format(tree).to_s)
55
87
  end
56
88
 
89
+ def test_literal
90
+ text = "a ``literal`` word"
91
+ tree = BlockParser.parse(text.lines.to_a)
92
+ assert_equal("a `literal` word#{$/}", @formatter.format(tree).to_s)
93
+ end
94
+
95
+ def test_plugin
96
+ text = <<TEXT
97
+ A paragraph with several plugin tags.
98
+ {{''}} should be presented as two quotation marks.
99
+ {{ {}} should be presented as two left curly braces.
100
+ {{} }} should be presented as two right curly braces.
101
+ {{in span}} should be presented as 'in span'.
102
+ TEXT
103
+ expected_text = <<TEXT
104
+ A paragraph with several plugin tags.
105
+ '' should be presented as two quotation marks.
106
+ {{ should be presented as two left curly braces.
107
+ }} should be presented as two right curly braces.
108
+ in span should be presented as 'in span'.
109
+
110
+ TEXT
111
+
112
+ tree = BlockParser.parse(text.lines.to_a)
113
+ assert_equal(expected_text, @formatter.format(tree).to_s)
114
+ end
115
+
57
116
  def test_hr
58
117
  text = "----#{$/}"
59
118
  md_text = "----#{$/}"
@@ -150,6 +209,7 @@ TEXT
150
209
  |cell 1-1 |cell 1-2|
151
210
  |cell 2-1 |cell 2-2|
152
211
  |cell 3-1 (a bit wider)|cell 3-2|
212
+
153
213
  TEXT
154
214
 
155
215
  html =<<HTML
@@ -173,6 +233,7 @@ HTML
173
233
  ||cell 1-1||cell 1-2
174
234
  ||cell 2-1||cell 2-2
175
235
  ||cell 3-1 (a bit wider)||cell 3-2
236
+
176
237
  TEXT
177
238
 
178
239
  md_text = <<TEXT
@@ -181,6 +242,7 @@ TEXT
181
242
  |cell 1-1 |cell 1-2|
182
243
  |cell 2-1 |cell 2-2|
183
244
  |cell 3-1 (a bit wider)|cell 3-2|
245
+
184
246
  TEXT
185
247
 
186
248
  html =<<HTML
@@ -217,6 +279,7 @@ TEXT
217
279
  |cell 1-1 |cell 1-2 |
218
280
  |cell 2-1 |cell 2-2 |
219
281
  |cell 3-1 (a bit wider)|cell 3-2 |
282
+
220
283
  TEXT
221
284
 
222
285
  html = <<HTML
@@ -252,6 +315,7 @@ TEXT
252
315
  |cell 1-1 |cell 1-2 |cell 1-3 |cell 1-4 |
253
316
  |cell 2-1 |cell 2-2 | |cell 2-4 |
254
317
  |cell 3-1 (a bit wider)|cell 3-2 |cell 3-3 |cell 3-4 |
318
+
255
319
  TEXT
256
320
 
257
321
  html = <<HTML
@@ -286,6 +350,7 @@ TEXT
286
350
  |cell 1-1 |cell 1-2 |cell 1-3 |cell 1-4 |
287
351
  |cell 2-1 |cell 2-2 | |cell 2-4 |
288
352
  |cell 3-1 (a bit wider)|cell 3-2 |cell 3-3 |cell 3-4 |
353
+
289
354
  TEXT
290
355
 
291
356
  html = <<HTML
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'test/unit'
3
+ require 'minitest/autorun'
4
4
  require 'pseudohiki/plaintextformat'
5
5
 
6
- class TC_PlainTextFormat < Test::Unit::TestCase
6
+ class TC_PlainTextFormat < MiniTest::Unit::TestCase
7
7
  include PseudoHiki
8
8
 
9
9
  def setup
@@ -54,6 +54,40 @@ TEXT
54
54
  assert_equal(expected_text_in_verbose_mode, @verbose_formatter.format(tree).to_s)
55
55
  end
56
56
 
57
+ def test_literal
58
+ text = <<TEXT
59
+ A test string with a ``literal`` is here.
60
+ TEXT
61
+ expected_text = <<TEXT
62
+ A test string with a literal is here.
63
+
64
+ TEXT
65
+
66
+ tree = BlockParser.parse(text.lines.to_a)
67
+ assert_equal(expected_text, @formatter.format(tree).to_s)
68
+ end
69
+
70
+ def test_plugin
71
+ text = <<TEXT
72
+ A paragraph with several plugin tags.
73
+ {{''}} should be presented as two quotation marks.
74
+ {{ {}} should be presented as two left curly braces.
75
+ {{} }} should be presented as two right curly braces.
76
+ {{in span}} should be presented as 'in span'.
77
+ TEXT
78
+ expected_text = <<TEXT
79
+ A paragraph with several plugin tags.
80
+ '' should be presented as two quotation marks.
81
+ {{ should be presented as two left curly braces.
82
+ }} should be presented as two right curly braces.
83
+ in span should be presented as 'in span'.
84
+
85
+ TEXT
86
+
87
+ tree = BlockParser.parse(text.lines.to_a)
88
+ assert_equal(expected_text, @formatter.format(tree).to_s)
89
+ end
90
+
57
91
  def test_link_url
58
92
  text = <<TEXT
59
93
  A test string with a [[link|http://www.example.org/]] is here.
@@ -204,7 +238,7 @@ cell 3-1 || || cell 3-4 cell 3-5
204
238
  cell 4-1 cell 4-2 cell 4-3 cell 4-4 cell 4-5
205
239
  TEXT
206
240
 
207
- assert_raise(PlainTextFormat::TableNodeFormatter::MalFormedTableError) do
241
+ assert_raises(PlainTextFormat::TableNodeFormatter::MalFormedTableError) do
208
242
  tree = BlockParser.parse(mal_formed_text.lines.to_a)
209
243
  @strict_formatter.format(tree).to_s
210
244
  end
@@ -1,9 +1,9 @@
1
1
  #/usr/bin/env ruby
2
2
 
3
- require 'test/unit'
3
+ require 'minitest/autorun'
4
4
  require 'pseudohiki/treestack'
5
5
 
6
- class TC_TreeStack < Test::Unit::TestCase
6
+ class TC_TreeStack < MiniTest::Unit::TestCase
7
7
 
8
8
  def test_push_node
9
9
  stack = TreeStack.new
@@ -34,7 +34,7 @@ class TC_TreeStack < Test::Unit::TestCase
34
34
  node = TreeStack::Node.new
35
35
  assert_same node.class, TreeStack::Node
36
36
  assert_equal true, node.kind_of?(TreeStack::Node)
37
- assert_not_equal true, node.kind_of?(TreeStack::Mergeable)
37
+ refute node.kind_of?(TreeStack::Mergeable)
38
38
  end
39
39
 
40
40
  def test_with_mergeable