md2review 1.6.0 → 1.7.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: 0c33fd9405522deed97226f68c102915fc82a265
4
- data.tar.gz: 16c2bf470421be818b4880b60b6f90f1f4620018
3
+ metadata.gz: 0788a6609e5e81f082dbc5f14a51c28ce0c9ee5b
4
+ data.tar.gz: cffe67adf60805b44e796f1838b7635667bfa2f5
5
5
  SHA512:
6
- metadata.gz: be1a2406bb5dd4e9602839c80c3fc2c16f11bfd785565f1dc2e4045138fe86756399a167be20e8d6fad7863dc26c5d0a452b72154e409c2140b4b887806ed025
7
- data.tar.gz: f429bbc5a6020373cb03035175f20a8fa4097e24b9f475ec2c58dd50d8ce0001dc05e24833c78690176b2340afd8e437b3d49a8fe401886d3f376b792564e190
6
+ metadata.gz: b7bc540bd7a66dc33afcde5604338debeeab627896a7d3e090fb122990be66496da114f4de1e0f0c71bd5a945a98b4eba4ec6f4990aa203b72fb153f2f641c04
7
+ data.tar.gz: 549143a0c669ca9f091ed0c18904729c29b98b8f0724a706a9522b1649188263ba4696ad498dace68d9fac0bc239deb817b70ead97629efdabeed1d5f1242c3f
data/.travis.yml CHANGED
@@ -1,3 +1,5 @@
1
+ sudo: false
2
+
1
3
  rvm:
2
4
  - 1.9.3
3
5
  - 2.0.0
data/README.md CHANGED
@@ -27,6 +27,10 @@ You can use the commmand md2review as:
27
27
 
28
28
  ## History
29
29
 
30
+ * 1.7.0
31
+ * fix: when href in emphasis (@hanachin)
32
+ * fix: spaces before image block (@hanachin)
33
+ * fix: remove inline markup in href content (@hanachin)
30
34
  * 1.6.0
31
35
  * special attribute in header need a separator(U+0020) to distinguish from Re:VIEW inline markup
32
36
  (reported by @himajin315 and @yasulab)
@@ -1,3 +1,3 @@
1
1
  module MD2ReVIEW
2
- VERSION = "1.6.0"
2
+ VERSION = "1.7.0"
3
3
  end
@@ -140,7 +140,8 @@ module Redcarpet
140
140
  @links[key] ||= link
141
141
  footnotes(content) + footnote_ref(key)
142
142
  else
143
- "@<href>{#{escape_href(link)},#{escape_inline(content)}}"
143
+ content = escape_inline(remove_inline_markups(content))
144
+ "@<href>{#{escape_href(link)},#{content}}"
144
145
  end
145
146
  end
146
147
 
@@ -149,7 +150,7 @@ module Redcarpet
149
150
  end
150
151
 
151
152
  def emphasis(text)
152
- "@<b>{#{escape_inline(text)}}"
153
+ sandwitch_link('b', text)
153
154
  end
154
155
 
155
156
  def strikethrough(text)
@@ -231,8 +232,23 @@ module Redcarpet
231
232
  end
232
233
 
233
234
  def postprocess(text)
235
+ text = text.gsub(%r|^[ \t]+(//image\[[^\]]+\]\[[^\]]+\]{$\n^//})|, '\1')
234
236
  text + @links.map { |key, link| footnote_def(link, key) }.join
235
237
  end
238
+
239
+ def remove_inline_markups(text)
240
+ text.gsub(/@<(?:b|strong|tt)>{([^}]*)}/, '\1')
241
+ end
242
+
243
+ def sandwitch_link(op, text)
244
+ head, match, tail = text.partition(/@<href>{(?:\\,|[^}])*}/)
245
+
246
+ if match.empty? && tail.empty?
247
+ return "@<#{op}>{#{escape_inline(text)}}"
248
+ end
249
+
250
+ sandwitch_link(op, head) + match + sandwitch_link(op, tail)
251
+ end
236
252
  end
237
253
  end
238
254
  end
data/test/review_test.rb CHANGED
@@ -42,6 +42,23 @@ class ReVIEWTest < Test::Unit::TestCase
42
42
  assert_equal %Q|\n\naaa foo@<fn>{3ccd7167b80081c737b749ad1c27dcdc}, bar@<fn>{9dcab303478e38d32d83ae19daaea9f6}, foo2@<fn>{3ccd7167b80081c737b749ad1c27dcdc}\n\n\n//footnote[3ccd7167b80081c737b749ad1c27dcdc][http://example.jp/foo]\n\n//footnote[9dcab303478e38d32d83ae19daaea9f6][http://example.jp/bar]\n|, rd
43
43
  end
44
44
 
45
+ def test_href_with_emphasised_anchor
46
+ assert_equal "\n\n@<href>{http://exmaple.com/,example}\n\n", @markdown.render("[*example*](http://exmaple.com/)")
47
+ end
48
+
49
+ def test_href_with_double_emphasised_anchor
50
+ assert_equal "\n\n@<href>{http://exmaple.com/,example}\n\n", @markdown.render("[**example**](http://exmaple.com/)")
51
+ end
52
+
53
+ def test_href_with_codespan_anchor
54
+ assert_equal "\n\n@<href>{http://exmaple.com/,example}\n\n", @markdown.render("[`example`](http://exmaple.com/)")
55
+ end
56
+
57
+ def test_emphasis_with_href
58
+ assert_respond_to @markdown, :render
59
+ assert_equal "\n\n@<b>{{hello\\} }@<href>{http://exmaple.com/foo\\,bar,example}@<b>{ world}\n\n", @markdown.render("*{hello} [example](http://exmaple.com/foo,bar) world*")
60
+ end
61
+
45
62
  def test_header
46
63
  assert_respond_to @markdown, :render
47
64
  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")
@@ -67,6 +84,10 @@ class ReVIEWTest < Test::Unit::TestCase
67
84
  assert_equal "\n\n//image[image][test]{\n//}\n\n\n", @markdown.render("![test](path/to/image.jpg)\n")
68
85
  end
69
86
 
87
+ def test_indented_image
88
+ assert_equal "\n\n//image[image][test]{\n//}\n\n\n", @markdown.render(" ![test](path/to/image.jpg)\n")
89
+ end
90
+
70
91
  def test_indepimage
71
92
  rev = render_with({}, "![test](path/to/image.jpg)\n",{:disable_image_caption => true})
72
93
  assert_equal "\n\n//indepimage[image]\n\n\n", rev
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.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - takahashim
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-16 00:00:00.000000000 Z
11
+ date: 2015-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redcarpet
@@ -97,3 +97,4 @@ specification_version: 4
97
97
  summary: a converter from Markdown to Re:VIEW
98
98
  test_files:
99
99
  - test/review_test.rb
100
+ has_rdoc: