md2review 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/md2review/version.rb +1 -1
- data/lib/redcarpet/render/review.rb +24 -9
- data/test/review_test.rb +22 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e89900431129c85303b2e0b6a88148e46aeaf0c8
|
4
|
+
data.tar.gz: a42c3ebdae24c58d1d94c316d2f7183a67211fc2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfef0533c707cddc1ba28ccd5367f6977dd03b14ca9cf6475527e4b79b77985fb5aeb00f5d6668b092cbdd9420bc44f9595dbf41962dfc5ad037c16b28bfe8a7
|
7
|
+
data.tar.gz: 1b8f74362eb313400d83a6ed906ad73a0c429301adf2d6cda2b5c086c785248f9cbd4b93f94a992409f14da4bedbb735cdac91aa8b13eeca2171f928dcbd6192
|
data/lib/md2review/version.rb
CHANGED
@@ -95,7 +95,7 @@ module Redcarpet
|
|
95
95
|
|
96
96
|
def image(link, title, alt_text)
|
97
97
|
filename = File.basename(link,".*")
|
98
|
-
"//image[#{filename}][#{alt_text}]{\n//}"
|
98
|
+
"//image[#{filename}][#{alt_text}]{\n//}\n"
|
99
99
|
end
|
100
100
|
|
101
101
|
def autolink(link, link_type)
|
@@ -123,24 +123,39 @@ module Redcarpet
|
|
123
123
|
end
|
124
124
|
|
125
125
|
def paragraph(text)
|
126
|
-
"\n\n#{text}\n"
|
126
|
+
"\n\n#{text}\n\n"
|
127
127
|
end
|
128
128
|
|
129
129
|
def list(content, list_type)
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
130
|
+
ret = ""
|
131
|
+
content.each_line do |item|
|
132
|
+
case list_type
|
133
|
+
when :ordered
|
134
|
+
if item =~ /^ +(\d+\.) (.*)/
|
135
|
+
## XXX not support yet in Re:VIEW
|
136
|
+
ret << " #{$1} #{$2.chomp}" << "\n"
|
137
|
+
else
|
138
|
+
ret << " 1. " << item
|
139
|
+
end
|
140
|
+
when :unordered
|
141
|
+
if item =~ /^ (\*+) (.*)/
|
142
|
+
ret << " *#{$1} #{$2.chomp}" << "\n"
|
143
|
+
else
|
144
|
+
ret << " * " << item
|
145
|
+
end
|
146
|
+
end
|
135
147
|
end
|
148
|
+
ret
|
136
149
|
end
|
137
150
|
|
138
151
|
def list_item(content, list_type)
|
139
152
|
case list_type
|
140
153
|
when :ordered
|
141
|
-
|
154
|
+
item = content.gsub(/\n(\s+[^0-9])/){$1}.gsub(/\n(\s+[0-9]+[^.])/){$1}.strip
|
155
|
+
"#{item}\n"
|
142
156
|
when :unordered
|
143
|
-
|
157
|
+
item = content.gsub(/\n(\s*[^* ])/){$1}.strip
|
158
|
+
"#{item}\n"
|
144
159
|
end
|
145
160
|
end
|
146
161
|
|
data/test/review_test.rb
CHANGED
@@ -22,22 +22,35 @@ class ReVIEWTest < Test::Unit::TestCase
|
|
22
22
|
|
23
23
|
def test_that_simple_one_liner_goes_to_review
|
24
24
|
assert_respond_to @markdown, :render
|
25
|
-
assert_equal "\n\nHello World.\n", @markdown.render("Hello World
|
25
|
+
assert_equal "\n\nHello World.\n\n", @markdown.render("Hello World.\n")
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_href
|
29
29
|
assert_respond_to @markdown, :render
|
30
|
-
assert_equal "\n\n@<href>{http://exmaple.com,example}\n", @markdown.render("[example](http://exmaple.com)")
|
30
|
+
assert_equal "\n\n@<href>{http://exmaple.com,example}\n\n", @markdown.render("[example](http://exmaple.com)\n")
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_href_with_comma
|
34
34
|
assert_respond_to @markdown, :render
|
35
|
-
assert_equal "\n\n@<href>{http://exmaple.com/foo\\,bar,example}\n", @markdown.render("[example](http://exmaple.com/foo,bar)")
|
35
|
+
assert_equal "\n\n@<href>{http://exmaple.com/foo\\,bar,example}\n\n", @markdown.render("[example](http://exmaple.com/foo,bar)")
|
36
36
|
end
|
37
37
|
|
38
38
|
def test_header
|
39
39
|
assert_respond_to @markdown, :render
|
40
|
-
assert_equal "\n= AAA\n\n\nBBB\n\n== ccc\n\n\nddd\n", @markdown.render("#AAA\nBBB\n\n##ccc\n\nddd\n")
|
40
|
+
assert_equal "\n= AAA\n\n\nBBB\n\n\n== ccc\n\n\nddd\n\n", @markdown.render("#AAA\nBBB\n\n##ccc\n\nddd\n")
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_nested_ulist
|
44
|
+
assert_equal " * aaa\n ** bbb\n * ccc\n", @markdown.render("- aaa\n - bbb\n- ccc\n")
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_olist
|
48
|
+
assert_equal " 1. aaa\n 1. bbb\n 1. ccc\n", @markdown.render("1. aaa\n2. bbb\n3. ccc\n")
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_nested_olist
|
52
|
+
## XXX not support yet in Re:VIEW
|
53
|
+
assert_equal " 1. aaa\n 1. bbb\n 1. ccc\n", @markdown.render("1. aaa\n 2. bbb\n3. ccc\n")
|
41
54
|
end
|
42
55
|
|
43
56
|
def test_code_fence_with_caption
|
@@ -47,21 +60,21 @@ class ReVIEWTest < Test::Unit::TestCase
|
|
47
60
|
|
48
61
|
def test_code_fence_without_flag
|
49
62
|
rd = render_with({}, %Q[~~~ {caption="test"}\ndef foo\n p "test"\nend\n~~~\n])
|
50
|
-
assert_equal %Q[\n\n~~~ {caption="test"}\ndef foo\n p "test"\nend\n~~~\n], rd
|
63
|
+
assert_equal %Q[\n\n~~~ {caption="test"}\ndef foo\n p "test"\nend\n~~~\n\n], rd
|
51
64
|
end
|
52
65
|
|
53
66
|
def test_group_ruby
|
54
67
|
rd = render_with({:ruby => true}, "{電子出版|でんししゅっぱん}を手軽に\n")
|
55
|
-
assert_equal %Q[\n\n@<ruby>{電子出版,でんししゅっぱん}を手軽に\n], rd
|
68
|
+
assert_equal %Q[\n\n@<ruby>{電子出版,でんししゅっぱん}を手軽に\n\n], rd
|
56
69
|
end
|
57
70
|
|
58
71
|
def test_tcy
|
59
72
|
rd = render_with({:tcy => true}, "昭和^53^年\n")
|
60
|
-
assert_equal %Q[\n\n昭和@<tcy>{53}年\n], rd
|
73
|
+
assert_equal %Q[\n\n昭和@<tcy>{53}年\n\n], rd
|
61
74
|
end
|
62
75
|
|
63
76
|
def test_footnote
|
64
|
-
rd = render_with({:footnotes=>true}, "これは脚注付き[^1]の段落です。\n\n[^1]: そして、これが脚注です。\n")
|
65
|
-
assert_equal %Q|\n\nこれは脚注付き@<fn>{1}の段落です。\n\n//footnote[1][そして、これが脚注です。]\n|, rd
|
77
|
+
rd = render_with({:footnotes=>true}, "これは脚注付き[^1]の段落です。\n\n\n[^1]: そして、これが脚注です。\n")
|
78
|
+
assert_equal %Q|\n\nこれは脚注付き@<fn>{1}の段落です。\n\n\n//footnote[1][そして、これが脚注です。]\n|, rd
|
66
79
|
end
|
67
80
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: md2review
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- takahashim
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redcarpet
|