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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7fe75be532aea31066a8d4d72bf8d374c5012f5d
4
- data.tar.gz: 8c8cc8e6ea93aa0130e3ae829afa6493b277fdf4
3
+ metadata.gz: e89900431129c85303b2e0b6a88148e46aeaf0c8
4
+ data.tar.gz: a42c3ebdae24c58d1d94c316d2f7183a67211fc2
5
5
  SHA512:
6
- metadata.gz: 6b2ca4b637fbf6d5d5841b6cf855dc4945373247925a941b6d45de53a0221237f05aff3688945952df3f6496032e9b43d36f75937f2b09e48507886c2c82d8e2
7
- data.tar.gz: 0bf1477d3c85f553ffe5bf31678093b883e3cd45dd6ab21d8ae6a17c242c506ae08f8d80f04367b981e3a7b259c264b396d125f332078d2879b468fac6457b9d
6
+ metadata.gz: cfef0533c707cddc1ba28ccd5367f6977dd03b14ca9cf6475527e4b79b77985fb5aeb00f5d6668b092cbdd9420bc44f9595dbf41962dfc5ad037c16b28bfe8a7
7
+ data.tar.gz: 1b8f74362eb313400d83a6ed906ad73a0c429301adf2d6cda2b5c086c785248f9cbd4b93f94a992409f14da4bedbb735cdac91aa8b13eeca2171f928dcbd6192
@@ -1,3 +1,3 @@
1
1
  module MD2ReVIEW
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -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
- case list_type
131
- when :ordered
132
- "\n#{content}\n"
133
- when :unordered
134
- "\n#{content}\n"
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
- " 1. #{content.strip}\n"
154
+ item = content.gsub(/\n(\s+[^0-9])/){$1}.gsub(/\n(\s+[0-9]+[^.])/){$1}.strip
155
+ "#{item}\n"
142
156
  when :unordered
143
- " * #{content.strip}\n"
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.1.0
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-04-19 00:00:00.000000000 Z
11
+ date: 2014-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redcarpet