md2review 1.10.0 → 1.11.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: 0b0c25dd78674626ae763d7e22a3d0f3bb0d1bbe
4
- data.tar.gz: a20ad0bfc4b7a8cc8911fe45e62c463b9a6e809c
3
+ metadata.gz: 8c560a9be30a083529292ae26d7a45d9fced085d
4
+ data.tar.gz: 7ab713f3fda9726c9d138bfe418ef52c57ae2d56
5
5
  SHA512:
6
- metadata.gz: b6f7e6c11a967266328ad668175f77c3c8e66664e57a77d7a421a2037ffaf54ca8af49090dfd69ac8084258a3bef3db913e0cb4f6e8abee1b17ec8e97cb2c48c
7
- data.tar.gz: 839647f7b807bff78490e84b5f2665cffb33c83fb298f446a9a31d18b5b6affd1b09c581532147d17930182c4f1fb6d162a468b205b4c6abccb1e10c94e2811f
6
+ metadata.gz: '00689ab7e51fca52eae36f9137fbed5fde4f90d142b6bdc0e241301023caafb31996441ec4caa7eca3b2ebabc6fa457ba8cafd9607d4bac0cad37f0c7a57b4dd'
7
+ data.tar.gz: 352be9cc2485f702ddfae7ebddaf941175e7e3f9e3aa93ab53bd3843111634eb9cd343ed953421e0482bdd0954b31f7d1758338c741c479cb23fc3fa13cd9517
@@ -0,0 +1,87 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.3
3
+ DisabledByDefault: true
4
+
5
+ Style/HashSyntax:
6
+ Enabled: true
7
+
8
+ Style/EmptyLines:
9
+ Enabled: true
10
+
11
+ Style/TrailingBlankLines:
12
+ Enabled: true
13
+
14
+ Style/TrailingWhitespace:
15
+ Enabled: true
16
+
17
+ Style/MethodDefParentheses:
18
+ Enabled: true
19
+
20
+
21
+ Style/BarePercentLiterals:
22
+ EnforcedStyle: percent_q
23
+ Enabled: true
24
+
25
+ # EnforcedStyle: empty_lines => 16 offenses
26
+ # EnforcedStyle: no_empty_lines => 0 offense
27
+ Style/EmptyLinesAroundBlockBody:
28
+ EnforcedStyle: no_empty_lines
29
+ Enabled: true
30
+
31
+ Style/MethodDefParentheses:
32
+ EnforcedStyle: require_parentheses
33
+ Enabled: true
34
+
35
+ Style/MethodName:
36
+ EnforcedStyle: snake_case
37
+ Enabled: true
38
+
39
+ Style/SpaceInsideHashLiteralBraces:
40
+ EnforcedStyle: no_space
41
+ EnforcedStyleForEmptyBraces: no_space
42
+ Enabled: true
43
+
44
+ Style/SpaceInsideStringInterpolation:
45
+ EnforcedStyle: no_space
46
+ Enabled: true
47
+
48
+ Style/VariableName:
49
+ EnforcedStyle: snake_case
50
+ Enabled: true
51
+
52
+ Style/MissingElse:
53
+ EnforcedStyle: case
54
+ Enabled: true
55
+
56
+ Lint/Debugger:
57
+ Enabled: true
58
+
59
+ Lint/DefEndAlignment:
60
+ Enabled: true
61
+
62
+ Lint/DeprecatedClassMethods:
63
+ Enabled: true
64
+
65
+ Lint/DuplicateCaseCondition:
66
+ Enabled: true
67
+
68
+ Lint/DuplicateMethods:
69
+ Enabled: true
70
+
71
+ Lint/DuplicatedKey:
72
+ Enabled: true
73
+
74
+ Lint/ElseLayout:
75
+ Enabled: true
76
+
77
+ Lint/EndInMethod:
78
+ Enabled: true
79
+
80
+ Lint/HandleExceptions:
81
+ Enabled: true
82
+
83
+ Lint/ImplicitStringConcatenation:
84
+ Enabled: true
85
+
86
+ Lint/MultipleCompare:
87
+ Enabled: true
@@ -1,6 +1,11 @@
1
1
  language: ruby
2
2
  sudo: false
3
3
 
4
+
5
+ before_install:
6
+ - gem update --system
7
+ - gem update bundler
8
+
4
9
  rvm:
5
10
  - 2.0
6
11
  - 2.1
data/Gemfile CHANGED
@@ -2,4 +2,4 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- gem "redcarpet", :git => 'git://github.com/gnue/redcarpet.git', :branch => 'denden'
5
+ gem "redcarpet", git: 'https://github.com/gnue/redcarpet.git', branch: 'denden'
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # md2review
2
2
 
3
- [![Build Status](https://api.travis-ci.org/takahashim/md2review.png)](https://travis-ci.org/takahashim/md2review)
3
+ [![Gem Version](https://badge.fury.io/rb/md2review.svg)](https://badge.fury.io/rb/md2review)
4
+ [![Build Status](https://secure.travis-ci.org/takahashim/md2review.svg)](https://travis-ci.org/takahashim/md2review)
4
5
 
5
6
  md2review is a CLI tool to convert from Markdown into Re:VIEW (http://reviewml.org/ ).
6
7
  This command uses Redcarpet gem to parse markdown.
@@ -23,6 +24,7 @@ You can use the commmand md2review as:
23
24
  * `--render-table-cation`: support table caption before table like `Table: some captions`
24
25
  * `--parse-no-intra-emphasis`: do not parse emphasis inside of words.
25
26
  * `--parse-autolink`: parse links even when they are not enclosed in `<>` characters.
27
+ * `--render-empty-image-caption`: use `//image` with caption and use `//indepimage` without caption
26
28
 
27
29
 
28
30
  ## Installation
@@ -41,34 +43,45 @@ Or install it yourself as:
41
43
 
42
44
  ## History
43
45
 
44
- * 1.10.0
45
- * add: option --image-table to support `//imgtable` with `![Table:foo](...)`
46
- * fix: olist before/after ulist
47
- * 1.9.0
48
- * fix: fix math support for complex cases
49
- * 1.8.0
50
- * add: option --version
51
- * add: option --render-math to support `@<m>{...}` and `//texequation{\n...\n}\n`
52
- * add: option --render-table-caption to support `Table: caption`
53
- * 1.7.0
54
- * fix: when href in emphasis (@hanachin)
55
- * fix: spaces before image block (@hanachin)
56
- * fix: remove inline markup in href content (@hanachin)
57
- * 1.6.0
58
- * special attribute in header need a separator(U+0020) to distinguish from Re:VIEW inline markup
59
- (reported by @himajin315 and @yasulab)
60
- * 1.5.0
61
- * support language on code block
62
- * add option --render-enable-cmd
63
- * 1.4.0
64
- * fix handling empty cell in //table
65
- * support header attributes in PHP Markdown Extra
66
- * 1.3.0
67
- * allow images in list items (with @<icon>)
68
- * add option --disable-image-caption
69
- * allow 6th header level
70
- * add option --render-link-in-footnote (by @masarakki)
71
- * support inline markup in footnote (by @hamano)
46
+ ### v1.11.0
47
+ * add: option --empty-image-caption: switch to use `//image` or `//indepimage` with caption
48
+
49
+ ### v1.10.0
50
+ * add: option --image-table to support `//imgtable` with `![Table:foo](...)`
51
+ * fix: olist before/after ulist
52
+
53
+ ### v1.9.0
54
+ * fix: fix math support for complex cases
55
+
56
+ ### v1.8.0
57
+ * add: option --version
58
+ * add: option --render-math to support `@<m>{...}` and `//texequation{\n...\n}\n`
59
+ * add: option --render-table-caption to support `Table: caption`
60
+
61
+ ### v1.7.0
62
+ * fix: when href in emphasis (@hanachin)
63
+ * fix: spaces before image block (@hanachin)
64
+ * fix: remove inline markup in href content (@hanachin)
65
+
66
+ ### v1.6.0
67
+ * special attribute in header need a separator(U+0020) to distinguish from Re:VIEW inline markup
68
+ (reported by @himajin315 and @yasulab)
69
+
70
+ ### v1.5.0
71
+ * support language on code block
72
+ * add option --render-enable-cmd
73
+
74
+ ### v1.4.0
75
+ * fix handling empty cell in `//table`
76
+ * support header attributes in PHP Markdown Extra
77
+
78
+ ### v1.3.0
79
+ * allow images in list items (with `@<icon>`)
80
+ * add option --disable-image-caption
81
+ * allow 6th header level
82
+ * add option --render-link-in-footnote (by @masarakki)
83
+ * support inline markup in footnote (by @hamano)
84
+
72
85
 
73
86
  ## Contributing
74
87
 
data/Rakefile CHANGED
@@ -1,10 +1,13 @@
1
1
  require "bundler/gem_tasks"
2
-
3
2
  require 'rake/testtask'
3
+ require 'rubocop/rake_task'
4
+
4
5
  Rake::TestTask.new('test:unit') do |t|
5
6
  t.test_files = FileList['test/*_test.rb']
6
7
  end
7
8
 
8
- task :default => :test
9
+ RuboCop::RakeTask.new
10
+
11
+ task default: [:test, :rubocop]
9
12
 
10
- task :test => ['test:unit']
13
+ task test: ['test:unit']
@@ -1,3 +1,3 @@
1
1
  module MD2ReVIEW
2
- VERSION = "1.10.0"
2
+ VERSION = "1.11.0"
3
3
  end
@@ -11,6 +11,12 @@ module Redcarpet
11
11
  @header_offset = 0
12
12
  @link_in_footnote = render_extensions[:link_in_footnote]
13
13
  @image_caption = !render_extensions[:disable_image_caption]
14
+ if render_extensions[:empty_image_caption]
15
+ @image_caption = false
16
+ @empty_image_caption = true
17
+ else
18
+ @empty_image_caption = false
19
+ end
14
20
  @image_table = render_extensions[:image_table]
15
21
  if render_extensions[:header_offset]
16
22
  @header_offset = render_extensions[:header_offset]
@@ -165,7 +171,7 @@ module Redcarpet
165
171
  if @image_table && alt_text =~ /\ATable:\s*(.*)/
166
172
  caption = $1
167
173
  "//imgtable[#{filename}][#{caption}]{\n//}\n"
168
- elsif @image_caption
174
+ elsif @image_caption || (@empty_image_caption && alt_text.to_s.size > 0)
169
175
  "//image[#{filename}][#{alt_text}]{\n//}\n"
170
176
  else
171
177
  "//indepimage[#{filename}]\n"
@@ -19,4 +19,5 @@ Gem::Specification.new do |gem|
19
19
  gem.add_dependency('redcarpet', '>2.0.0')
20
20
  gem.add_development_dependency "rake"
21
21
  gem.add_development_dependency "test-unit"
22
+ gem.add_development_dependency "rubocop"
22
23
  end
@@ -37,7 +37,7 @@ class ReVIEWTest < Test::Unit::TestCase
37
37
 
38
38
  def test_href_in_footnote
39
39
  text = %Q[aaa [foo](http://example.jp/foo), [bar](http://example.jp/bar), [foo2](http://example.jp/foo)]
40
- rd = MD2ReVIEW::Markdown.new({:link_in_footnote => true},{}).render(text)
40
+ rd = MD2ReVIEW::Markdown.new({link_in_footnote: true},{}).render(text)
41
41
  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
42
42
  end
43
43
 
@@ -88,12 +88,22 @@ class ReVIEWTest < Test::Unit::TestCase
88
88
  end
89
89
 
90
90
  def test_indepimage
91
- rev = render_with({}, "![test](path/to/image.jpg)\n",{:disable_image_caption => true})
91
+ rev = render_with({}, "![test](path/to/image.jpg)\n", {disable_image_caption: true})
92
92
  assert_equal "\n\n//indepimage[image]\n\n\n", rev
93
93
  end
94
94
 
95
+ def test_indepimage_empty
96
+ rev = render_with({}, "![](path/to/image.jpg)\n", {empty_image_caption: true})
97
+ assert_equal "\n\n//indepimage[image]\n\n\n", rev
98
+ end
99
+
100
+ def test_indepimage_not_empty
101
+ rev = render_with({}, "![test](path/to/image.jpg)\n", {empty_image_caption: true})
102
+ assert_equal "\n\n//image[image][test]{\n//}\n\n\n", rev
103
+ end
104
+
95
105
  def test_image_table
96
- rev = render_with({}, "![Table:test](path/to/image.jpg)\n",{:image_table => true})
106
+ rev = render_with({}, "![Table:test](path/to/image.jpg)\n", {image_table: true})
97
107
  assert_equal "\n\n//imgtable[image][test]{\n//}\n\n\n", rev
98
108
  end
99
109
 
@@ -123,12 +133,12 @@ class ReVIEWTest < Test::Unit::TestCase
123
133
  end
124
134
 
125
135
  def test_table_with_empty_cell
126
- rd = render_with({:tables => true}, %Q[\n\n| a | b | c |\n|----|----|----|\n| A | B | C |\n| | B | C |\n| .A | B | C |\n\n])
136
+ rd = render_with({tables: true}, %Q[\n\n| a | b | c |\n|----|----|----|\n| A | B | C |\n| | B | C |\n| .A | B | C |\n\n])
127
137
  assert_equal "//table[tbl1][]{\na\tb\tc\n-----------------\nA\tB\tC\n.\tB\tC\n..A\tB\tC\n//}\n", rd
128
138
  end
129
139
 
130
140
  def test_table_with_caption
131
- rd = render_with({:tables => true}, <<-EOB, {:table_caption => true})
141
+ rd = render_with({tables: true}, <<-EOB, {table_caption: true})
132
142
 
133
143
  Table: caption test
134
144
 
@@ -150,7 +160,7 @@ EOB
150
160
  end
151
161
 
152
162
  def test_code_fence_with_caption
153
- rd = render_with({:fenced_code_blocks => true}, %Q[~~~ {caption="test"}\ndef foo\n p "test"\nend\n~~~\n])
163
+ rd = render_with({fenced_code_blocks: true}, %Q[~~~ {caption="test"}\ndef foo\n p "test"\nend\n~~~\n])
154
164
  assert_equal %Q[\n//emlist[test]{\ndef foo\n p "test"\nend\n//}\n], rd
155
165
  end
156
166
 
@@ -160,41 +170,41 @@ EOB
160
170
  end
161
171
 
162
172
  def test_code_fence_with_lang
163
- rd = render_with({:fenced_code_blocks => true}, %Q[~~~ruby\ndef foo\n p "test"\nend\n~~~\n])
173
+ rd = render_with({fenced_code_blocks: true}, %Q[~~~ruby\ndef foo\n p "test"\nend\n~~~\n])
164
174
  assert_equal %Q[\n//emlist[][ruby]{\ndef foo\n p "test"\nend\n//}\n], rd
165
175
  end
166
176
 
167
177
  def test_code_fence_with_console
168
- rd = render_with({:fenced_code_blocks => true}, %Q[~~~console\ndef foo\n p "test"\nend\n~~~\n])
178
+ rd = render_with({fenced_code_blocks: true}, %Q[~~~console\ndef foo\n p "test"\nend\n~~~\n])
169
179
  assert_equal %Q[\n//emlist[][console]{\ndef foo\n p "test"\nend\n//}\n], rd
170
- rd = render_with({:fenced_code_blocks => true},
180
+ rd = render_with({fenced_code_blocks: true},
171
181
  %Q[~~~console\ndef foo\n p "test"\nend\n~~~\n],
172
- {:enable_cmd => true})
182
+ {enable_cmd: true})
173
183
  assert_equal %Q[\n//cmd{\ndef foo\n p "test"\nend\n//}\n], rd
174
184
  end
175
185
 
176
186
  def test_group_ruby
177
- rd = render_with({:ruby => true}, "{電子出版|でんししゅっぱん}を手軽に\n")
187
+ rd = render_with({ruby: true}, "{電子出版|でんししゅっぱん}を手軽に\n")
178
188
  assert_equal %Q[\n\n@<ruby>{電子出版,でんししゅっぱん}を手軽に\n\n], rd
179
189
  end
180
190
 
181
191
  def test_tcy
182
- rd = render_with({:tcy => true}, "昭和^53^年\n")
192
+ rd = render_with({tcy: true}, "昭和^53^年\n")
183
193
  assert_equal %Q[\n\n昭和@<tcy>{53}年\n\n], rd
184
194
  end
185
195
 
186
196
  def test_math
187
- rd = render_with({}, "その結果、$$y=ax^2+bx+c$$の式が得られます。",{:math => true})
197
+ rd = render_with({}, "その結果、$$y=ax^2+bx+c$$の式が得られます。",{math: true})
188
198
  assert_equal %Q[\n\nその結果、@<m>{y=ax^2+bx+c}の式が得られます。\n\n], rd
189
199
  end
190
200
 
191
201
  def test_multi_math
192
- rd = render_with({}, "その結果、$$y=a_2x^2+b_2x+c_2$$の式が得られます。$$a_2$$は2次の係数、$$b_2$$は1次の係数、$$c_2$$は定数です。",{:math => true})
202
+ rd = render_with({}, "その結果、$$y=a_2x^2+b_2x+c_2$$の式が得られます。$$a_2$$は2次の係数、$$b_2$$は1次の係数、$$c_2$$は定数です。",{math: true})
193
203
  assert_equal %Q[\n\nその結果、@<m>{y=a_2x^2+b_2x+c_2}の式が得られます。@<m>{a_2}は2次の係数、@<m>{b_2}は1次の係数、@<m>{c_2}は定数です。\n\n], rd
194
204
  end
195
205
 
196
206
  def test_math2
197
- rd = render_with({}, <<-'EOB',{:math => true})
207
+ rd = render_with({}, <<-'EOB',{math: true})
198
208
  $$X = \{ {x_1}, \cdots ,{x_n} \}$$、$$m$$、$${\mu _X}$$、$$\sigma _X^2$$、$$\{ {\hat x_1}, \cdots ,{\hat x_n} \}$$
199
209
 
200
210
  $$\mathbf{W} = ({w_1}, \cdots ,{w_n})$$、$$\sqrt {w_1^2 + \cdots + w_n^2} $$、$$\left| {w_1^{}} \right| + \left| {w_2^{}} \right| + \cdots + \left| {w_n^{}} \right|$$。
@@ -212,12 +222,12 @@ EOB
212
222
  end
213
223
 
214
224
  def test_no_math
215
- rd = render_with({}, "その結果、$$y=ax^2+bx+c$$の式が得られます。",{:math => false})
225
+ rd = render_with({}, "その結果、$$y=ax^2+bx+c$$の式が得られます。",{math: false})
216
226
  assert_equal %Q[\n\nその結果、$$y=ax^2+bx+c$$の式が得られます。\n\n], rd
217
227
  end
218
228
 
219
229
  def test_math_block
220
- rd = render_with({:fenced_code_blocks => true}, <<-EOB,{:math => true})
230
+ rd = render_with({fenced_code_blocks: true}, <<-EOB,{math: true})
221
231
  求める式は以下のようになります。
222
232
 
223
233
  ```math
@@ -237,12 +247,12 @@ EOB
237
247
  end
238
248
 
239
249
  def test_footnote
240
- rd = render_with({:footnotes=>true}, "これは*脚注*付き[^1]の段落です。\n\n\n[^1]: そして、これが脚注です。\n")
250
+ rd = render_with({footnotes: true}, "これは*脚注*付き[^1]の段落です。\n\n\n[^1]: そして、これが脚注です。\n")
241
251
  assert_equal %Q|\n\nこれは@<b>{脚注}付き@<fn>{1}の段落です。\n\n\n//footnote[1][そして、これが脚注です。]\n|, rd
242
252
  end
243
253
 
244
254
  def test_autolink
245
- rd = render_with({:autolink => true}, "リンクの[テスト](http://example.jp/test)です。\nhttp://example.jp/test2/\n")
255
+ rd = render_with({autolink: true}, "リンクの[テスト](http://example.jp/test)です。\nhttp://example.jp/test2/\n")
246
256
  assert_equal %Q[\n\nリンクの@<href>{http://example.jp/test,テスト}です。\n@<href>{http://example.jp/test2/}\n\n], rd
247
257
  end
248
258
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: md2review
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.0
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - takahashim
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description: a converter from Markdown to Re:VIEW. It uses redcarpet.
56
70
  email:
57
71
  - takahashimm@gmail.com
@@ -61,6 +75,7 @@ extensions: []
61
75
  extra_rdoc_files: []
62
76
  files:
63
77
  - ".gitignore"
78
+ - ".rubocop.yml"
64
79
  - ".travis.yml"
65
80
  - Gemfile
66
81
  - LICENSE.txt