md2review 1.7.0 → 1.8.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 +6 -3
- data/README.md +4 -0
- data/appveyor.yml +21 -0
- data/bin/md2review +8 -2
- data/lib/md2review.rb +2 -5
- data/lib/md2review/markdown.rb +16 -0
- data/lib/md2review/version.rb +1 -1
- data/lib/redcarpet/render/review.rb +22 -2
- data/test/review_test.rb +58 -7
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46c0ddf09e6f474c1b87f8016216dda28b433398
|
4
|
+
data.tar.gz: 66d5359d6f229a870d3eccf6825e5e52e8295426
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0cd14e69907497db4368507a813d27d21a8cd327baf520e478cba27a3250b9a68c621f4f60a082ba98bcc88bd19087c7e037ed90965b531915dfb78feafcd81
|
7
|
+
data.tar.gz: 425c784ed78be28a3d2f1ab3face88160f6b1f806a83c644e7cb29301f3ed801c24b342633d3c21d7c0f863524fff3299c35c90c40e955bd76e8f7fc97b42a67
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -27,6 +27,10 @@ You can use the commmand md2review as:
|
|
27
27
|
|
28
28
|
## History
|
29
29
|
|
30
|
+
* 1.8.0
|
31
|
+
* add: option --version
|
32
|
+
* add: option --render-math to support `@<m>{...}` and `//texequation{\n...\n}\n`
|
33
|
+
* add: option --render-table-caption to support `Table: caption`
|
30
34
|
* 1.7.0
|
31
35
|
* fix: when href in emphasis (@hanachin)
|
32
36
|
* fix: spaces before image block (@hanachin)
|
data/appveyor.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
---
|
2
|
+
install:
|
3
|
+
- SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
|
4
|
+
- ruby --version
|
5
|
+
- gem --version
|
6
|
+
- bundle install
|
7
|
+
build_script:
|
8
|
+
- bundle exec rake
|
9
|
+
test_script:
|
10
|
+
- bundle exec rake test
|
11
|
+
artifacts:
|
12
|
+
- path: pkg\*.gem
|
13
|
+
|
14
|
+
environment:
|
15
|
+
matrix:
|
16
|
+
- ruby_version: "200"
|
17
|
+
- ruby_version: "200-x64"
|
18
|
+
- ruby_version: "21"
|
19
|
+
- ruby_version: "21-x64"
|
20
|
+
- ruby_version: "22"
|
21
|
+
- ruby_version: "22-x64"
|
data/bin/md2review
CHANGED
@@ -3,6 +3,10 @@
|
|
3
3
|
# Convert one or more Markdown files to ReVIEW and write to standard output. With
|
4
4
|
# no <file> or when <file> is '-', read Markdown source text from standard input.
|
5
5
|
# With <extension>s, perform additional Markdown processing before writing output.
|
6
|
+
|
7
|
+
require 'md2review'
|
8
|
+
require 'md2review/version'
|
9
|
+
|
6
10
|
if ARGV.include?('--help')
|
7
11
|
File.read(__FILE__).split("\n").grep(/^# /).each do |line|
|
8
12
|
puts line[2..-1]
|
@@ -37,13 +41,15 @@ ARGV.delete_if do |arg|
|
|
37
41
|
elsif arg =~ /^--parse-([\w-]+)$/
|
38
42
|
arg = $1.gsub('-', '_')
|
39
43
|
parse_extensions[arg.to_sym] = true
|
44
|
+
elsif arg =~ /^--version$/
|
45
|
+
print MD2ReVIEW::VERSION, "\n"
|
46
|
+
exit
|
40
47
|
else
|
41
48
|
false
|
42
49
|
end
|
43
50
|
end
|
44
51
|
|
45
|
-
|
46
|
-
md = Redcarpet::Markdown.new(render, parse_extensions)
|
52
|
+
md = MD2ReVIEW::Markdown.new(render_extensions, parse_extensions)
|
47
53
|
md_doc = ARGF.read
|
48
54
|
review_doc = md.render(md_doc)
|
49
55
|
STDOUT.write review_doc
|
data/lib/md2review.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'redcarpet'
|
2
|
+
require 'redcarpet/render/review'
|
3
|
+
|
4
|
+
module MD2ReVIEW
|
5
|
+
class Markdown
|
6
|
+
def initialize(render_options, parser_options)
|
7
|
+
## Redcarpet only
|
8
|
+
render = Redcarpet::Render::ReVIEW.new(render_options)
|
9
|
+
@markdown = Redcarpet::Markdown.new(render, parser_options)
|
10
|
+
end
|
11
|
+
|
12
|
+
def render(text)
|
13
|
+
@markdown.render(text)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/md2review/version.rb
CHANGED
@@ -16,6 +16,9 @@ module Redcarpet
|
|
16
16
|
end
|
17
17
|
@links = {}
|
18
18
|
@cmd = render_extensions[:enable_cmd]
|
19
|
+
@support_table_caption = render_extensions[:table_caption]
|
20
|
+
@table_caption = nil
|
21
|
+
@math = render_extensions[:math]
|
19
22
|
end
|
20
23
|
|
21
24
|
def normal_text(text)
|
@@ -44,6 +47,8 @@ module Redcarpet
|
|
44
47
|
|
45
48
|
if @cmd && (language == "shell-session" || language == "console")
|
46
49
|
"\n//cmd{\n#{code_text}\n//}\n"
|
50
|
+
elsif @math && language == "math"
|
51
|
+
"\n//texequation{\n#{code.chomp}\n//}\n"
|
47
52
|
else
|
48
53
|
"\n//emlist#{caption}{\n#{code_text}\n//}\n"
|
49
54
|
end
|
@@ -102,7 +107,12 @@ module Redcarpet
|
|
102
107
|
header_text = "#{header}-----------------\n"
|
103
108
|
end
|
104
109
|
body.chomp!
|
105
|
-
|
110
|
+
caption = nil
|
111
|
+
if @table_caption
|
112
|
+
caption = @table_caption.strip
|
113
|
+
@table_caption = nil
|
114
|
+
end
|
115
|
+
"//table[#{table_id()}][#{caption}]{\n#{header_text}#{body}\n//}\n"
|
106
116
|
end
|
107
117
|
|
108
118
|
def table_row(content)
|
@@ -162,7 +172,12 @@ module Redcarpet
|
|
162
172
|
end
|
163
173
|
|
164
174
|
def paragraph(text)
|
165
|
-
|
175
|
+
if @support_table_caption && text =~ /\ATable:(.*)\z/
|
176
|
+
@table_caption = $1 ## and no output line
|
177
|
+
""
|
178
|
+
else
|
179
|
+
"\n\n#{text}\n\n"
|
180
|
+
end
|
166
181
|
end
|
167
182
|
|
168
183
|
def list(content, list_type)
|
@@ -233,6 +248,11 @@ module Redcarpet
|
|
233
248
|
|
234
249
|
def postprocess(text)
|
235
250
|
text = text.gsub(%r|^[ \t]+(//image\[[^\]]+\]\[[^\]]+\]{$\n^//})|, '\1')
|
251
|
+
if @math
|
252
|
+
while %r|\$\$(.+?)\$\$| =~ text
|
253
|
+
text.sub!(%r|\$\$(.+?)\$\$|){ "@<m>{" + $1.gsub(/}/, "\\}") + "}" }
|
254
|
+
end
|
255
|
+
end
|
236
256
|
text + @links.map { |key, link| footnote_def(link, key) }.join
|
237
257
|
end
|
238
258
|
|
data/test/review_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# coding:
|
1
|
+
# coding: utf-8
|
2
2
|
rootdir = File.dirname(File.dirname(__FILE__))
|
3
3
|
$LOAD_PATH.unshift "#{rootdir}/lib"
|
4
4
|
|
@@ -7,18 +7,17 @@ if defined? Encoding
|
|
7
7
|
end
|
8
8
|
|
9
9
|
require 'test/unit'
|
10
|
-
require '
|
11
|
-
require '
|
10
|
+
require 'md2review'
|
11
|
+
require 'md2review/markdown'
|
12
12
|
|
13
13
|
class ReVIEWTest < Test::Unit::TestCase
|
14
14
|
|
15
15
|
def setup
|
16
|
-
@markdown =
|
16
|
+
@markdown = MD2ReVIEW::Markdown.new({},{})
|
17
17
|
end
|
18
18
|
|
19
19
|
def render_with(flags, text, render_flags = {})
|
20
|
-
|
21
|
-
Redcarpet::Markdown.new(renderer, flags).render(text)
|
20
|
+
MD2ReVIEW::Markdown.new(render_flags, flags).render(text)
|
22
21
|
end
|
23
22
|
|
24
23
|
def test_that_simple_one_liner_goes_to_review
|
@@ -38,7 +37,7 @@ class ReVIEWTest < Test::Unit::TestCase
|
|
38
37
|
|
39
38
|
def test_href_in_footnote
|
40
39
|
text = %Q[aaa [foo](http://example.jp/foo), [bar](http://example.jp/bar), [foo2](http://example.jp/foo)]
|
41
|
-
rd =
|
40
|
+
rd = MD2ReVIEW::Markdown.new({:link_in_footnote => true},{}).render(text)
|
42
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
|
43
42
|
end
|
44
43
|
|
@@ -119,6 +118,28 @@ class ReVIEWTest < Test::Unit::TestCase
|
|
119
118
|
assert_equal "//table[tbl1][]{\na\tb\tc\n-----------------\nA\tB\tC\n.\tB\tC\n..A\tB\tC\n//}\n", rd
|
120
119
|
end
|
121
120
|
|
121
|
+
def test_table_with_caption
|
122
|
+
rd = render_with({:tables => true}, <<-EOB, {:table_caption => true})
|
123
|
+
|
124
|
+
Table: caption test
|
125
|
+
|
126
|
+
| a | b | c |
|
127
|
+
|----|----|----|
|
128
|
+
| A | B | C |
|
129
|
+
| | B | C |
|
130
|
+
| .A | B | C |
|
131
|
+
EOB
|
132
|
+
assert_equal <<-EOB, rd
|
133
|
+
//table[tbl1][caption test]{
|
134
|
+
a\tb\tc
|
135
|
+
-----------------
|
136
|
+
A\tB\tC
|
137
|
+
.\tB\tC
|
138
|
+
..A\tB\tC
|
139
|
+
//}
|
140
|
+
EOB
|
141
|
+
end
|
142
|
+
|
122
143
|
def test_code_fence_with_caption
|
123
144
|
rd = render_with({:fenced_code_blocks => true}, %Q[~~~ {caption="test"}\ndef foo\n p "test"\nend\n~~~\n])
|
124
145
|
assert_equal %Q[\n//emlist[test]{\ndef foo\n p "test"\nend\n//}\n], rd
|
@@ -153,6 +174,36 @@ class ReVIEWTest < Test::Unit::TestCase
|
|
153
174
|
assert_equal %Q[\n\n昭和@<tcy>{53}年\n\n], rd
|
154
175
|
end
|
155
176
|
|
177
|
+
def test_math
|
178
|
+
rd = render_with({}, "その結果、$$y=ax^2+bx+c$$の式が得られます。",{:math => true})
|
179
|
+
assert_equal %Q[\n\nその結果、@<m>{y=ax^2+bx+c}の式が得られます。\n\n], rd
|
180
|
+
end
|
181
|
+
|
182
|
+
def test_no_math
|
183
|
+
rd = render_with({}, "その結果、$$y=ax^2+bx+c$$の式が得られます。",{:math => false})
|
184
|
+
assert_equal %Q[\n\nその結果、$$y=ax^2+bx+c$$の式が得られます。\n\n], rd
|
185
|
+
end
|
186
|
+
|
187
|
+
def test_math_block
|
188
|
+
rd = render_with({:fenced_code_blocks => true}, <<-EOB,{:math => true})
|
189
|
+
求める式は以下のようになります。
|
190
|
+
|
191
|
+
```math
|
192
|
+
\frac{n!}{k!(n-k)!} = \binom{n}{k}
|
193
|
+
```
|
194
|
+
EOB
|
195
|
+
assert_equal <<-EOB, rd
|
196
|
+
|
197
|
+
|
198
|
+
求める式は以下のようになります。
|
199
|
+
|
200
|
+
|
201
|
+
//texequation{
|
202
|
+
\frac{n!}{k!(n-k)!} = \binom{n}{k}
|
203
|
+
//}
|
204
|
+
EOB
|
205
|
+
end
|
206
|
+
|
156
207
|
def test_footnote
|
157
208
|
rd = render_with({:footnotes=>true}, "これは*脚注*付き[^1]の段落です。\n\n\n[^1]: そして、これが脚注です。\n")
|
158
209
|
assert_equal %Q|\n\nこれは@<b>{脚注}付き@<fn>{1}の段落です。\n\n\n//footnote[1][そして、これが脚注です。]\n|, rd
|
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.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- takahashim
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redcarpet
|
@@ -66,8 +66,10 @@ files:
|
|
66
66
|
- LICENSE.txt
|
67
67
|
- README.md
|
68
68
|
- Rakefile
|
69
|
+
- appveyor.yml
|
69
70
|
- bin/md2review
|
70
71
|
- lib/md2review.rb
|
72
|
+
- lib/md2review/markdown.rb
|
71
73
|
- lib/md2review/version.rb
|
72
74
|
- lib/redcarpet/render/review.rb
|
73
75
|
- md2review.gemspec
|
@@ -91,10 +93,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
93
|
version: '0'
|
92
94
|
requirements: []
|
93
95
|
rubyforge_project:
|
94
|
-
rubygems_version: 2.
|
96
|
+
rubygems_version: 2.6.8
|
95
97
|
signing_key:
|
96
98
|
specification_version: 4
|
97
99
|
summary: a converter from Markdown to Re:VIEW
|
98
100
|
test_files:
|
99
101
|
- test/review_test.rb
|
100
|
-
has_rdoc:
|