pseudohikiparser 0.0.5 → 0.0.6.develop
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/pseudohiki2html +1 -20
- data/lib/htmlelement/htmltemplate.rb +39 -1
- data/lib/htmlelement.rb +15 -1
- data/lib/pseudohiki/autolink.rb +1 -1
- data/lib/pseudohiki/blockparser.rb +119 -18
- data/lib/pseudohiki/converter.rb +9 -19
- data/lib/pseudohiki/htmlformat.rb +88 -23
- data/lib/pseudohiki/htmlplugin.rb +3 -3
- data/lib/pseudohiki/inlineparser.rb +29 -18
- data/lib/pseudohiki/markdownformat.rb +71 -64
- data/lib/pseudohiki/plaintextformat.rb +25 -25
- data/lib/pseudohiki/shim.rb +30 -0
- data/lib/pseudohiki/sinatra_helpers.rb +23 -0
- data/lib/pseudohiki/treestack.rb +4 -4
- data/lib/pseudohiki/utils.rb +2 -2
- data/lib/pseudohiki/version.rb +1 -1
- data/lib/pseudohikiparser.rb +2 -0
- data/test/test_blockparser.rb +67 -0
- data/test/test_htmlelement.rb +34 -0
- data/test/test_htmlelement_utils.rb +11 -0
- data/test/test_htmlformat.rb +413 -0
- data/test/test_htmltemplate.rb +84 -0
- data/test/test_inlineparser.rb +4 -4
- data/test/test_markdownformat.rb +157 -4
- data/test/test_plaintextformat.rb +85 -0
- data/test/test_pseudohiki2html.rb +24 -7
- metadata +8 -6
data/test/test_markdownformat.rb
CHANGED
@@ -420,10 +420,10 @@ TEXT
|
|
420
420
|
|
421
421
|
md_text = <<TEXT
|
422
422
|
1. item 1
|
423
|
-
|
424
|
-
|
423
|
+
2. item 2
|
424
|
+
1. item 2-1
|
425
425
|
2. item 2-2
|
426
|
-
|
426
|
+
1. item 2-2-1
|
427
427
|
|
428
428
|
TEXT
|
429
429
|
|
@@ -508,7 +508,7 @@ TEXT
|
|
508
508
|
## heading
|
509
509
|
|
510
510
|
1. item 1
|
511
|
-
|
511
|
+
1. item 1-1
|
512
512
|
|
513
513
|
a paragraph for testing a striked through ~~string with an _emphasis_ in it.~~
|
514
514
|
|
@@ -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
|
@@ -253,21 +253,35 @@ TEXT
|
|
253
253
|
assert_equal(toc_in_html, toc)
|
254
254
|
end
|
255
255
|
|
256
|
-
def
|
257
|
-
|
256
|
+
def test_embed_css_into_html
|
257
|
+
expected_html = <<HTML
|
258
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
259
|
+
"http://www.w3.org/TR/html4/loose.dtd">
|
260
|
+
<html lang="en">
|
261
|
+
<head>
|
262
|
+
<meta content="en" http-equiv="Content-Language">
|
263
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
264
|
+
<meta content="text/javascript" http-equiv="Content-Script-Type">
|
265
|
+
<title>wikipage</title>
|
266
|
+
<link href="default.css" rel="stylesheet" type="text/css">
|
258
267
|
<style type="text/css">
|
268
|
+
<!--
|
259
269
|
h1 {
|
260
270
|
margin-left: 0.5em;
|
261
271
|
}
|
272
|
+
-->
|
262
273
|
</style>
|
263
|
-
|
274
|
+
</head>
|
275
|
+
<body>
|
276
|
+
</body>
|
277
|
+
</html>
|
278
|
+
HTML
|
264
279
|
|
265
|
-
set_argv("-
|
280
|
+
set_argv("-C #{File.join(File.dirname(__FILE__), "test_data/css/test.css")} wikipage.txt")
|
266
281
|
options = OptionManager.new
|
267
282
|
options.parse_command_line_options
|
268
|
-
|
269
|
-
|
270
|
-
assert_equal(expected_style, style)
|
283
|
+
html = PageComposer.new(options).compose_html("").to_s
|
284
|
+
assert_equal(expected_html, html)
|
271
285
|
end
|
272
286
|
|
273
287
|
def test_compose_html
|
@@ -281,6 +295,9 @@ STYLE
|
|
281
295
|
<link href="css/with_toc.css" rel="stylesheet" type="text/css" />
|
282
296
|
</head>
|
283
297
|
<body>
|
298
|
+
<div class="skip-link">
|
299
|
+
<a href="#contents">Skip to Content</a><!-- end of skip-link -->
|
300
|
+
</div>
|
284
301
|
<section id="main">
|
285
302
|
<section id="toc">
|
286
303
|
<h2>table of contents</h2>
|
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.6.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: 2016-
|
11
|
+
date: 2016-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -90,6 +90,8 @@ files:
|
|
90
90
|
- lib/pseudohiki/inlineparser.rb
|
91
91
|
- lib/pseudohiki/markdownformat.rb
|
92
92
|
- lib/pseudohiki/plaintextformat.rb
|
93
|
+
- lib/pseudohiki/shim.rb
|
94
|
+
- lib/pseudohiki/sinatra_helpers.rb
|
93
95
|
- lib/pseudohiki/treestack.rb
|
94
96
|
- lib/pseudohiki/utils.rb
|
95
97
|
- lib/pseudohiki/version.rb
|
@@ -111,7 +113,7 @@ files:
|
|
111
113
|
- test/test_utils.rb
|
112
114
|
homepage: https://github.com/nico-hn/PseudoHikiParser/wiki
|
113
115
|
licenses:
|
114
|
-
- BSD
|
116
|
+
- BSD-2-Clause
|
115
117
|
metadata: {}
|
116
118
|
post_install_message:
|
117
119
|
rdoc_options: []
|
@@ -124,12 +126,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
124
126
|
version: 1.8.7
|
125
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
128
|
requirements:
|
127
|
-
- - "
|
129
|
+
- - ">"
|
128
130
|
- !ruby/object:Gem::Version
|
129
|
-
version:
|
131
|
+
version: 1.3.1
|
130
132
|
requirements: []
|
131
133
|
rubyforge_project:
|
132
|
-
rubygems_version: 2.
|
134
|
+
rubygems_version: 2.6.6
|
133
135
|
signing_key:
|
134
136
|
specification_version: 4
|
135
137
|
summary: 'PseudoHikiParser: a parser of texts in a Hiki like notation.'
|