pseudohikiparser 0.0.4 → 0.0.5.develop
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.ja.md +13 -11
- data/README.md +14 -12
- data/bin/{pseudohiki2html.rb → pseudohiki2html} +1 -1
- data/lib/htmlelement/utils.rb +132 -0
- data/lib/htmlelement.rb +1 -1
- data/lib/pseudohiki/blockparser.rb +115 -15
- data/lib/pseudohiki/converter.rb +204 -135
- data/lib/pseudohiki/htmlformat.rb +65 -0
- data/lib/pseudohiki/markdownformat.rb +8 -1
- data/lib/pseudohiki/sinatra_helpers.rb +23 -0
- data/lib/pseudohiki/utils.rb +34 -0
- data/lib/pseudohiki/version.rb +1 -1
- data/lib/pseudohikiparser.rb +2 -0
- data/test/test_blockparser.rb +67 -0
- data/test/test_data/css/test.css +3 -0
- data/test/test_htmlelement_utils.rb +200 -0
- data/test/test_htmlformat.rb +419 -0
- data/test/test_markdownformat.rb +153 -0
- data/test/test_plaintextformat.rb +85 -0
- data/test/test_pseudohiki2html.rb +111 -26
- data/test/test_utils.rb +22 -0
- metadata +14 -10
- data/test/test_latexformat.rb +0 -19
data/test/test_markdownformat.rb
CHANGED
@@ -518,6 +518,159 @@ TEXT
|
|
518
518
|
assert_equal(md_text, @formatter.format(tree).to_s)
|
519
519
|
end
|
520
520
|
|
521
|
+
def test_decorator_for_verbatim
|
522
|
+
text = <<TEXT
|
523
|
+
//@code[ruby]
|
524
|
+
def bonjour!
|
525
|
+
puts "Bonjour!"
|
526
|
+
end
|
527
|
+
TEXT
|
528
|
+
|
529
|
+
gfm_text =<<TEXT
|
530
|
+
```ruby
|
531
|
+
def bonjour!
|
532
|
+
puts "Bonjour!"
|
533
|
+
end
|
534
|
+
```
|
535
|
+
|
536
|
+
TEXT
|
537
|
+
|
538
|
+
md_text = <<TEXT
|
539
|
+
def bonjour!
|
540
|
+
puts "Bonjour!"
|
541
|
+
end
|
542
|
+
|
543
|
+
TEXT
|
544
|
+
|
545
|
+
tree = BlockParser.parse(text.lines.to_a)
|
546
|
+
assert_equal(gfm_text, @gfm_formatter.format(tree).to_s)
|
547
|
+
assert_equal(md_text, @formatter.format(tree).to_s)
|
548
|
+
end
|
549
|
+
|
550
|
+
def test_decorator_for_verbatim_block
|
551
|
+
text = <<TEXT
|
552
|
+
//@code[ruby]
|
553
|
+
<<<
|
554
|
+
def bonjour!
|
555
|
+
puts "Bonjour!"
|
556
|
+
end
|
557
|
+
>>>
|
558
|
+
TEXT
|
559
|
+
|
560
|
+
gfm_text =<<TEXT
|
561
|
+
```ruby
|
562
|
+
def bonjour!
|
563
|
+
puts "Bonjour!"
|
564
|
+
end
|
565
|
+
```
|
566
|
+
|
567
|
+
TEXT
|
568
|
+
|
569
|
+
md_text = <<TEXT
|
570
|
+
def bonjour!
|
571
|
+
puts "Bonjour!"
|
572
|
+
end
|
573
|
+
|
574
|
+
TEXT
|
575
|
+
|
576
|
+
tree = BlockParser.parse(text.lines.to_a)
|
577
|
+
assert_equal(gfm_text, @gfm_formatter.format(tree).to_s)
|
578
|
+
assert_equal(md_text, @formatter.format(tree).to_s)
|
579
|
+
end
|
580
|
+
|
581
|
+
def test_without_sectioning_node
|
582
|
+
text = <<TEXT
|
583
|
+
! Main title
|
584
|
+
|
585
|
+
!! first title in header
|
586
|
+
|
587
|
+
paragraph
|
588
|
+
|
589
|
+
!! second title in header
|
590
|
+
|
591
|
+
paragraph2
|
592
|
+
|
593
|
+
!! first subtitle in main part
|
594
|
+
|
595
|
+
paragraph3
|
596
|
+
|
597
|
+
paragraph4
|
598
|
+
|
599
|
+
TEXT
|
600
|
+
|
601
|
+
expected_text = <<HTML
|
602
|
+
# Main title
|
603
|
+
|
604
|
+
## first title in header
|
605
|
+
|
606
|
+
paragraph
|
607
|
+
|
608
|
+
## second title in header
|
609
|
+
|
610
|
+
paragraph2
|
611
|
+
|
612
|
+
## first subtitle in main part
|
613
|
+
|
614
|
+
paragraph3
|
615
|
+
|
616
|
+
paragraph4
|
617
|
+
|
618
|
+
HTML
|
619
|
+
|
620
|
+
tree = BlockParser.parse(text.lines.to_a)
|
621
|
+
assert_equal(expected_text, @gfm_formatter.format(tree).to_s)
|
622
|
+
end
|
623
|
+
|
624
|
+
def test_sectioning_node
|
625
|
+
text = <<TEXT
|
626
|
+
! Main title
|
627
|
+
|
628
|
+
//@begin[header]
|
629
|
+
!! first title in header
|
630
|
+
|
631
|
+
paragraph
|
632
|
+
|
633
|
+
!! second title in header
|
634
|
+
|
635
|
+
paragraph2
|
636
|
+
|
637
|
+
//@end[header]
|
638
|
+
|
639
|
+
!! first subtitle in main part
|
640
|
+
|
641
|
+
paragraph3
|
642
|
+
|
643
|
+
//@begin[#footer]
|
644
|
+
|
645
|
+
paragraph4
|
646
|
+
|
647
|
+
//@end[#footer]
|
648
|
+
|
649
|
+
TEXT
|
650
|
+
|
651
|
+
expected_text = <<HTML
|
652
|
+
# Main title
|
653
|
+
|
654
|
+
## first title in header
|
655
|
+
|
656
|
+
paragraph
|
657
|
+
|
658
|
+
## second title in header
|
659
|
+
|
660
|
+
paragraph2
|
661
|
+
|
662
|
+
## first subtitle in main part
|
663
|
+
|
664
|
+
paragraph3
|
665
|
+
|
666
|
+
paragraph4
|
667
|
+
|
668
|
+
HTML
|
669
|
+
|
670
|
+
tree = BlockParser.parse(text.lines.to_a)
|
671
|
+
assert_equal(expected_text, @gfm_formatter.format(tree).to_s)
|
672
|
+
end
|
673
|
+
|
521
674
|
def test_collect_headings
|
522
675
|
text = <<TEXT
|
523
676
|
!![main-heading] heading
|
@@ -265,4 +265,89 @@ TEXT
|
|
265
265
|
assert_equal(expected_text_in_verbose_mode, PlainTextFormat.format(tree, { :verbose_mode => true }).to_s)
|
266
266
|
assert_equal(expected_text, PlainTextFormat.format(tree, { :verbose_mode => false }).to_s)
|
267
267
|
end
|
268
|
+
|
269
|
+
def test_without_sectioning_node
|
270
|
+
text = <<TEXT
|
271
|
+
! Main title
|
272
|
+
|
273
|
+
!! first title in header
|
274
|
+
|
275
|
+
paragraph
|
276
|
+
|
277
|
+
!! second title in header
|
278
|
+
|
279
|
+
paragraph2
|
280
|
+
|
281
|
+
!! first subtitle in main part
|
282
|
+
|
283
|
+
paragraph3
|
284
|
+
|
285
|
+
paragraph4
|
286
|
+
|
287
|
+
TEXT
|
288
|
+
|
289
|
+
expected_text = <<HTML
|
290
|
+
Main title
|
291
|
+
first title in header
|
292
|
+
paragraph
|
293
|
+
|
294
|
+
second title in header
|
295
|
+
paragraph2
|
296
|
+
|
297
|
+
first subtitle in main part
|
298
|
+
paragraph3
|
299
|
+
|
300
|
+
paragraph4
|
301
|
+
|
302
|
+
HTML
|
303
|
+
|
304
|
+
tree = BlockParser.parse(text.lines.to_a)
|
305
|
+
assert_equal(expected_text, PlainTextFormat.format(tree, { :verbose_mode => false }).to_s)
|
306
|
+
end
|
307
|
+
|
308
|
+
def test_sectioning_node
|
309
|
+
text = <<TEXT
|
310
|
+
! Main title
|
311
|
+
|
312
|
+
//@begin[header]
|
313
|
+
!! first title in header
|
314
|
+
|
315
|
+
paragraph
|
316
|
+
|
317
|
+
!! second title in header
|
318
|
+
|
319
|
+
paragraph2
|
320
|
+
|
321
|
+
//@end[header]
|
322
|
+
|
323
|
+
!! first subtitle in main part
|
324
|
+
|
325
|
+
paragraph3
|
326
|
+
|
327
|
+
//@begin[#footer]
|
328
|
+
|
329
|
+
paragraph4
|
330
|
+
|
331
|
+
//@end[#footer]
|
332
|
+
|
333
|
+
TEXT
|
334
|
+
|
335
|
+
expected_text = <<HTML
|
336
|
+
Main title
|
337
|
+
first title in header
|
338
|
+
paragraph
|
339
|
+
|
340
|
+
second title in header
|
341
|
+
paragraph2
|
342
|
+
|
343
|
+
first subtitle in main part
|
344
|
+
paragraph3
|
345
|
+
|
346
|
+
paragraph4
|
347
|
+
|
348
|
+
HTML
|
349
|
+
|
350
|
+
tree = BlockParser.parse(text.lines.to_a)
|
351
|
+
assert_equal(expected_text, PlainTextFormat.format(tree, { :verbose_mode => false }).to_s)
|
352
|
+
end
|
268
353
|
end
|
@@ -13,11 +13,11 @@ end
|
|
13
13
|
class TC_OptionManager < MiniTest::Unit::TestCase
|
14
14
|
include PseudoHiki
|
15
15
|
|
16
|
-
def
|
16
|
+
def test_parse_command_line_options
|
17
17
|
set_argv("-fx -s -m 'Table of Contents' -c css/with_toc.css wikipage.txt -o wikipage_with_toc.html")
|
18
18
|
|
19
19
|
options = OptionManager.new
|
20
|
-
options.
|
20
|
+
options.parse_command_line_options
|
21
21
|
|
22
22
|
assert_equal("xhtml1", options[:html_version].version)
|
23
23
|
assert_equal(true, options[:split_main_heading])
|
@@ -27,11 +27,11 @@ class TC_OptionManager < MiniTest::Unit::TestCase
|
|
27
27
|
assert_equal("wikipage_with_toc.html", File.basename(options[:output]))
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
30
|
+
def test_parse_command_line_options2
|
31
31
|
set_argv("-f h -m 'Table of Contents' -w 'Title' -c css/with_toc.css wikipage.txt")
|
32
32
|
|
33
33
|
options = OptionManager.new
|
34
|
-
options.
|
34
|
+
options.parse_command_line_options
|
35
35
|
|
36
36
|
assert_equal("html4", options[:html_version].version)
|
37
37
|
assert_equal(false, options[:split_main_heading])
|
@@ -51,7 +51,7 @@ LINES
|
|
51
51
|
set_argv("-f h -m 'Table of Contents' -w 'Title' -c css/with_toc.css wikipage.txt")
|
52
52
|
|
53
53
|
options = OptionManager.new
|
54
|
-
options.
|
54
|
+
options.parse_command_line_options
|
55
55
|
options.set_options_from_input_file(input_data.each_line.to_a)
|
56
56
|
|
57
57
|
assert_equal("Table of Contents set in the input file", options[:toc])
|
@@ -68,7 +68,7 @@ LINES
|
|
68
68
|
set_argv("-F -f h -m 'Table of Contents' -w 'Title' -c css/with_toc.css wikipage.txt")
|
69
69
|
|
70
70
|
options = OptionManager.new
|
71
|
-
options.
|
71
|
+
options.parse_command_line_options
|
72
72
|
options.set_options_from_input_file(input_data.each_line.to_a)
|
73
73
|
|
74
74
|
assert_equal("Table of Contents", options[:toc])
|
@@ -85,7 +85,7 @@ LINES
|
|
85
85
|
set_argv("-F -f h -m 'Table of Contents' -c css/with_toc.css wikipage.txt")
|
86
86
|
|
87
87
|
options = OptionManager.new
|
88
|
-
options.
|
88
|
+
options.parse_command_line_options
|
89
89
|
options.set_options_from_input_file(input_data.each_line.to_a)
|
90
90
|
|
91
91
|
assert_equal("Table of Contents", options[:toc])
|
@@ -101,12 +101,25 @@ LINES
|
|
101
101
|
set_argv("-F -f h -m 'Table of Contents' -c css/with_toc.css wikipage.txt")
|
102
102
|
|
103
103
|
options = OptionManager.new
|
104
|
-
options.
|
104
|
+
options.parse_command_line_options
|
105
105
|
options.set_options_from_input_file(input_data.each_line.to_a)
|
106
106
|
|
107
107
|
assert_equal("Table of Contents", options[:toc])
|
108
108
|
assert_equal(nil, options[:title])
|
109
109
|
end
|
110
|
+
|
111
|
+
def test_remove_bom
|
112
|
+
bom = "\xef\xbb\xbf"
|
113
|
+
string_without_bom = "a string without BOM"
|
114
|
+
string_with_bom = bom + string_without_bom
|
115
|
+
io_with_bom = StringIO.new(string_with_bom, "r")
|
116
|
+
io_without_bom = StringIO.new(string_without_bom, "r")
|
117
|
+
|
118
|
+
OptionManager.remove_bom(io_with_bom)
|
119
|
+
assert_equal(string_without_bom, io_with_bom.read)
|
120
|
+
OptionManager.remove_bom(io_without_bom)
|
121
|
+
assert_equal(string_without_bom, io_without_bom.read)
|
122
|
+
end
|
110
123
|
end
|
111
124
|
|
112
125
|
class TC_PageComposer < MiniTest::Unit::TestCase
|
@@ -138,17 +151,17 @@ HIKI
|
|
138
151
|
def test_collect_nodes_for_table_of_contents
|
139
152
|
set_argv("-fg -s -c css/with_toc.css wikipage.txt")
|
140
153
|
options = OptionManager.new
|
141
|
-
options.
|
154
|
+
options.parse_command_line_options
|
142
155
|
collected_nodes = [[["Heading1\n"]],
|
143
156
|
[["Heading2\n"]],
|
144
157
|
[["Heading2-1\n"]]]
|
145
158
|
|
146
159
|
tree = BlockParser.parse(@input_lines)
|
147
|
-
toc_nodes = PageComposer.new(options).collect_nodes_for_table_of_contents
|
160
|
+
toc_nodes = PageComposer::BaseComposer.new(options).send(:collect_nodes_for_table_of_contents, tree)
|
148
161
|
assert_equal(collected_nodes, toc_nodes)
|
149
162
|
end
|
150
163
|
|
151
|
-
def
|
164
|
+
def test_plain_composer_create_table_of_contents
|
152
165
|
toc_in_plain_text = <<TEXT
|
153
166
|
* Heading1
|
154
167
|
* Heading2
|
@@ -157,14 +170,28 @@ TEXT
|
|
157
170
|
set_argv("-fg -s -c css/with_toc.css wikipage.txt")
|
158
171
|
|
159
172
|
options = OptionManager.new
|
160
|
-
options.
|
173
|
+
options.parse_command_line_options
|
174
|
+
toc = PageComposer::PlainComposer.new(options).create_table_of_contents(@parsed_tree)
|
161
175
|
|
162
|
-
toc
|
176
|
+
assert_equal(toc_in_plain_text, toc)
|
177
|
+
end
|
178
|
+
|
179
|
+
def test_gfm_composer_create_table_of_contents
|
180
|
+
toc_in_plain_text = <<TEXT
|
181
|
+
* [Heading1](#heading1)
|
182
|
+
* [Heading2](#heading2)
|
183
|
+
* [Heading2-1](#heading21)
|
184
|
+
TEXT
|
185
|
+
set_argv("-fg -s -c css/with_toc.css wikipage.txt")
|
186
|
+
|
187
|
+
options = OptionManager.new
|
188
|
+
options.parse_command_line_options
|
189
|
+
toc = PageComposer::GfmComposer.new(options).create_table_of_contents(@parsed_tree)
|
163
190
|
|
164
191
|
assert_equal(toc_in_plain_text, toc)
|
165
192
|
end
|
166
193
|
|
167
|
-
def
|
194
|
+
def test_html_composer_create_table_of_contents
|
168
195
|
toc_in_html = <<TEXT
|
169
196
|
<ul>
|
170
197
|
<li><a href="#HEADING1" title="toc_item: Heading1">Heading1
|
@@ -181,9 +208,8 @@ TEXT
|
|
181
208
|
set_argv("-fh5 -s -c css/with_toc.css wikipage.txt")
|
182
209
|
|
183
210
|
options = OptionManager.new
|
184
|
-
options.
|
185
|
-
|
186
|
-
toc = PageComposer.new(options).create_html_table_of_contents(@parsed_tree).join
|
211
|
+
options.parse_command_line_options
|
212
|
+
toc = PageComposer::HtmlComposer.new(options).create_table_of_contents(@parsed_tree).join
|
187
213
|
|
188
214
|
assert_equal(toc_in_html, toc)
|
189
215
|
end
|
@@ -191,7 +217,7 @@ TEXT
|
|
191
217
|
def test_create_table_of_contents
|
192
218
|
set_argv("-c css/with_toc.css wikipage.txt")
|
193
219
|
options = OptionManager.new
|
194
|
-
options.
|
220
|
+
options.parse_command_line_options
|
195
221
|
toc = PageComposer.new(options).create_table_of_contents(@parsed_tree)
|
196
222
|
assert_equal("", toc)
|
197
223
|
|
@@ -203,7 +229,7 @@ TEXT
|
|
203
229
|
|
204
230
|
set_argv("-fg -m 'table of contents' -c css/with_toc.css wikipage.txt")
|
205
231
|
options = OptionManager.new
|
206
|
-
options.
|
232
|
+
options.parse_command_line_options
|
207
233
|
toc = PageComposer.new(options).create_table_of_contents(@parsed_tree)
|
208
234
|
assert_equal(toc_in_gfm_text, toc)
|
209
235
|
|
@@ -222,11 +248,28 @@ TEXT
|
|
222
248
|
|
223
249
|
set_argv("-fh5 -m 'table of contents' -c css/with_toc.css wikipage.txt")
|
224
250
|
options = OptionManager.new
|
225
|
-
options.
|
251
|
+
options.parse_command_line_options
|
226
252
|
toc = PageComposer.new(options).create_table_of_contents(@parsed_tree).join
|
227
253
|
assert_equal(toc_in_html, toc)
|
228
254
|
end
|
229
255
|
|
256
|
+
def test_html_composer_create_style
|
257
|
+
expected_style = <<STYLE
|
258
|
+
<style type="text/css">
|
259
|
+
h1 {
|
260
|
+
margin-left: 0.5em;
|
261
|
+
}
|
262
|
+
</style>
|
263
|
+
STYLE
|
264
|
+
|
265
|
+
set_argv("-c test_data/css/test.css wikipage.txt")
|
266
|
+
options = OptionManager.new
|
267
|
+
options.parse_command_line_options
|
268
|
+
test_data = File.join(File.dirname(__FILE__), "test_data/css/test.css")
|
269
|
+
style = PageComposer::HtmlComposer.new(options).create_style(test_data).to_s
|
270
|
+
assert_equal(expected_style, style)
|
271
|
+
end
|
272
|
+
|
230
273
|
def test_compose_html
|
231
274
|
expected_html =<<HTML
|
232
275
|
<?xml version="1.0" encoding="UTF-8"?>
|
@@ -321,19 +364,61 @@ TEXT
|
|
321
364
|
|
322
365
|
set_argv("-fh5 -m 'table of contents' -c css/with_toc.css wikipage.txt")
|
323
366
|
options = OptionManager.new
|
324
|
-
options.
|
367
|
+
options.parse_command_line_options
|
325
368
|
|
326
369
|
composed_html = PageComposer.new(options).compose_html(@input_lines).to_s
|
327
370
|
assert_equal(expected_html, composed_html)
|
328
371
|
|
329
372
|
set_argv("-fg -m 'table of contents' -c css/with_toc.css wikipage.txt")
|
330
373
|
options = OptionManager.new
|
331
|
-
options.
|
374
|
+
options.parse_command_line_options
|
332
375
|
|
333
376
|
composed_gfm_text = PageComposer.new(options).compose_html(@input_lines).join
|
334
377
|
assert_equal(expected_gfm_text, composed_gfm_text)
|
335
378
|
end
|
336
379
|
|
380
|
+
def test_compose_html_with_relative_links
|
381
|
+
expected_html =<<HTML
|
382
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
383
|
+
<!DOCTYPE html>
|
384
|
+
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
385
|
+
<head>
|
386
|
+
<meta charset="UTF-8" />
|
387
|
+
<title>wikipage</title>
|
388
|
+
<link href="css/with_toc.css" rel="stylesheet" type="text/css" />
|
389
|
+
</head>
|
390
|
+
<body>
|
391
|
+
<p>
|
392
|
+
a link in a paragraph <a href="./">http://www.example.org/</a>
|
393
|
+
</p>
|
394
|
+
<p>
|
395
|
+
another link <a href="index.html">for index.html</a> in a paragraph
|
396
|
+
</p>
|
397
|
+
<pre>
|
398
|
+
<a href="http://www.example.org/">http://www.example.org/</a>
|
399
|
+
</pre>
|
400
|
+
</body>
|
401
|
+
</html>
|
402
|
+
HTML
|
403
|
+
|
404
|
+
input_text = <<TEXT
|
405
|
+
a link in a paragraph http://www.example.org/
|
406
|
+
|
407
|
+
another link [[for index.html|http://www.example.org/index.html]] in a paragraph
|
408
|
+
|
409
|
+
<<<
|
410
|
+
http://www.example.org/
|
411
|
+
>>>
|
412
|
+
TEXT
|
413
|
+
|
414
|
+
set_argv("-fh5 -d 'www.example.org' --relative-links-in-html -c css/with_toc.css wikipage.txt")
|
415
|
+
options = OptionManager.new
|
416
|
+
options.parse_command_line_options
|
417
|
+
|
418
|
+
composed_html = PageComposer.new(options).compose_html(input_text).to_s
|
419
|
+
assert_equal(expected_html, composed_html)
|
420
|
+
end
|
421
|
+
|
337
422
|
def test_output_in_gfm_with_toc
|
338
423
|
input = <<TEXT.each_line.to_a
|
339
424
|
//title: Test Data
|
@@ -372,7 +457,7 @@ GFM
|
|
372
457
|
set_argv("-fg -s -c css/with_toc.css wikipage.txt")
|
373
458
|
|
374
459
|
options = OptionManager.new
|
375
|
-
options.
|
460
|
+
options.parse_command_line_options
|
376
461
|
options.set_options_from_input_file(input)
|
377
462
|
|
378
463
|
html = PageComposer.new(options).compose_html(input).join
|
@@ -384,7 +469,7 @@ GFM
|
|
384
469
|
current_auto_linker = BlockParser.auto_linker
|
385
470
|
set_argv("--with-wikiname wikipage.txt")
|
386
471
|
options = OptionManager.new
|
387
|
-
options.
|
472
|
+
options.parse_command_line_options
|
388
473
|
|
389
474
|
assert_equal(AutoLink::WikiName, BlockParser.auto_linker.class)
|
390
475
|
|
@@ -443,14 +528,14 @@ HTML
|
|
443
528
|
|
444
529
|
set_argv("-fh5 -c css/with_toc.css wikipage.txt")
|
445
530
|
options = OptionManager.new
|
446
|
-
options.
|
531
|
+
options.parse_command_line_options
|
447
532
|
|
448
533
|
composed_html = PageComposer.new(options).compose_html(verbatim_block_text).to_s
|
449
534
|
assert_equal(expected_html, composed_html)
|
450
535
|
|
451
536
|
set_argv("-fh5 -c css/with_toc.css wikipage.txt")
|
452
537
|
options = OptionManager.new
|
453
|
-
options.
|
538
|
+
options.parse_command_line_options
|
454
539
|
|
455
540
|
current_auto_linker = BlockParser.auto_linker
|
456
541
|
BlockParser.auto_linker = AutoLink::Off
|
data/test/test_utils.rb
CHANGED
@@ -37,5 +37,27 @@ TEXT
|
|
37
37
|
|
38
38
|
assert_equal(selected_headings, nodes)
|
39
39
|
end
|
40
|
+
|
41
|
+
def test_table_manager_guess_header_scope
|
42
|
+
table_with_row_header_text = <<TABLE
|
43
|
+
||!header1||!header2||!header3
|
44
|
+
||row1-1||row1-2||row1-3
|
45
|
+
||row2-1||row2-2||row2-3
|
46
|
+
TABLE
|
47
|
+
|
48
|
+
table_with_col_header_text = <<TABLE
|
49
|
+
||!header1||col1-1||col2-1
|
50
|
+
||!header2||col1-2||col2-2
|
51
|
+
||!header3||col1-3||col2-3
|
52
|
+
TABLE
|
53
|
+
|
54
|
+
table_manager = PseudoHiki::Utils::TableManager.new
|
55
|
+
|
56
|
+
table_with_row_header = PseudoHiki::BlockParser.parse(table_with_row_header_text)[0]
|
57
|
+
assert_equal("col", table_manager.guess_header_scope(table_with_row_header))
|
58
|
+
|
59
|
+
table_with_col_header = PseudoHiki::BlockParser.parse(table_with_col_header_text)[0]
|
60
|
+
assert_equal("row", table_manager.guess_header_scope(table_with_col_header))
|
61
|
+
end
|
40
62
|
end
|
41
63
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pseudohikiparser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5.develop
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- HASHIMOTO, Naoki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,21 +66,22 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0.31'
|
69
|
-
description: PseudoHikiParser
|
70
|
-
|
69
|
+
description: PseudoHikiParser parses texts written in a Hiki like notation, and coverts
|
70
|
+
them into HTML, Markdown or other formats.
|
71
71
|
email:
|
72
72
|
- hashimoto.naoki@gmail.com
|
73
73
|
executables:
|
74
|
-
- pseudohiki2html
|
74
|
+
- pseudohiki2html
|
75
75
|
extensions: []
|
76
76
|
extra_rdoc_files: []
|
77
77
|
files:
|
78
78
|
- LICENSE
|
79
79
|
- README.ja.md
|
80
80
|
- README.md
|
81
|
-
- bin/pseudohiki2html
|
81
|
+
- bin/pseudohiki2html
|
82
82
|
- lib/htmlelement.rb
|
83
83
|
- lib/htmlelement/htmltemplate.rb
|
84
|
+
- lib/htmlelement/utils.rb
|
84
85
|
- lib/pseudohiki/autolink.rb
|
85
86
|
- lib/pseudohiki/blockparser.rb
|
86
87
|
- lib/pseudohiki/converter.rb
|
@@ -89,18 +90,20 @@ files:
|
|
89
90
|
- lib/pseudohiki/inlineparser.rb
|
90
91
|
- lib/pseudohiki/markdownformat.rb
|
91
92
|
- lib/pseudohiki/plaintextformat.rb
|
93
|
+
- lib/pseudohiki/sinatra_helpers.rb
|
92
94
|
- lib/pseudohiki/treestack.rb
|
93
95
|
- lib/pseudohiki/utils.rb
|
94
96
|
- lib/pseudohiki/version.rb
|
95
97
|
- lib/pseudohikiparser.rb
|
96
98
|
- test/test_autolink.rb
|
97
99
|
- test/test_blockparser.rb
|
100
|
+
- test/test_data/css/test.css
|
98
101
|
- test/test_htmlelement.rb
|
102
|
+
- test/test_htmlelement_utils.rb
|
99
103
|
- test/test_htmlformat.rb
|
100
104
|
- test/test_htmlplugin.rb
|
101
105
|
- test/test_htmltemplate.rb
|
102
106
|
- test/test_inlineparser.rb
|
103
|
-
- test/test_latexformat.rb
|
104
107
|
- test/test_markdownformat.rb
|
105
108
|
- test/test_plaintextformat.rb
|
106
109
|
- test/test_pseudohiki2html.rb
|
@@ -122,9 +125,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
122
125
|
version: 1.8.7
|
123
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
127
|
requirements:
|
125
|
-
- - "
|
128
|
+
- - ">"
|
126
129
|
- !ruby/object:Gem::Version
|
127
|
-
version:
|
130
|
+
version: 1.3.1
|
128
131
|
requirements: []
|
129
132
|
rubyforge_project:
|
130
133
|
rubygems_version: 2.2.3
|
@@ -144,5 +147,6 @@ test_files:
|
|
144
147
|
- test/test_htmlformat.rb
|
145
148
|
- test/test_htmlplugin.rb
|
146
149
|
- test/test_autolink.rb
|
150
|
+
- test/test_htmlelement_utils.rb
|
147
151
|
- test/test_utils.rb
|
148
|
-
- test/
|
152
|
+
- test/test_data/css/test.css
|
data/test/test_latexformat.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'minitest/autorun'
|
4
|
-
require 'pseudohiki/latexformat'
|
5
|
-
|
6
|
-
class TC_LaTeXTag < MiniTest::Unit::TestCase
|
7
|
-
include PseudoHiki
|
8
|
-
|
9
|
-
def test_escape
|
10
|
-
unescaped = '# $ % \\ & {} ^ _ ~'
|
11
|
-
escaped = '\\# \\$ \\% \\textbackslash{} \\& \\{\\} \\^{} \\_ \\~{}'
|
12
|
-
assert_equal(escaped, LaTeXTag.escape(unescaped))
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_format_options
|
16
|
-
command = LaTeXTag.new("documentclass")
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|