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 +4 -4
- data/.travis.yml +2 -0
- data/README.md +4 -0
- data/lib/md2review/version.rb +1 -1
- data/lib/redcarpet/render/review.rb +18 -2
- data/test/review_test.rb +21 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0788a6609e5e81f082dbc5f14a51c28ce0c9ee5b
|
4
|
+
data.tar.gz: cffe67adf60805b44e796f1838b7635667bfa2f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7bc540bd7a66dc33afcde5604338debeeab627896a7d3e090fb122990be66496da114f4de1e0f0c71bd5a945a98b4eba4ec6f4990aa203b72fb153f2f641c04
|
7
|
+
data.tar.gz: 549143a0c669ca9f091ed0c18904729c29b98b8f0724a706a9522b1649188263ba4696ad498dace68d9fac0bc239deb817b70ead97629efdabeed1d5f1242c3f
|
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)
|
data/lib/md2review/version.rb
CHANGED
@@ -140,7 +140,8 @@ module Redcarpet
|
|
140
140
|
@links[key] ||= link
|
141
141
|
footnotes(content) + footnote_ref(key)
|
142
142
|
else
|
143
|
-
|
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
|
-
|
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.
|
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-
|
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:
|