md2review 1.3.0 → 1.4.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: a57ec7a51d60f3ee878b3744a749f25aa3d5567a
4
- data.tar.gz: 860a29d7751752ba1715da6b10b7e8e9f3a9c0f5
3
+ metadata.gz: 47cac18a12085d3bdb0239c62b58fe2dbe5555c8
4
+ data.tar.gz: fbc94b20594d10698e9c9ec17b30c6267472357c
5
5
  SHA512:
6
- metadata.gz: 15bb56747f0611da2a5d34e6f59a163d3029a19cfb477df6936af6f9a7639298d0ee87edf8b0765b829f6fbe1c78267faf2442a5c8a2098106c61fd97dd1f052
7
- data.tar.gz: 6f6f179e177c34a40cf0d000033ace1cf1bc04d28c9f158e3e63073bd5e38f7baa0d35d748225fc4a80a400c7b97af275a2cb840e3f36cba037585b0ced0a5e8
6
+ metadata.gz: 2a3c26c36591f4f5c3dd632b8a4d0ddbe00513253a1bfcaf48775659479105cce2beca2c1b25f54c1f597fceb2654f6fe4ea84070ded41e4e0bf1ae48e493139
7
+ data.tar.gz: e62530cb1aebdac4ee717c18d3acae3aedea6ddeb2e05f9774e76cf105e5d5cbc98d02325221d31ffb673a12e6757b4577b48fac89cdbfb993381e8d90217d67
data/README.md CHANGED
@@ -25,6 +25,18 @@ You can use the commmand md2review as:
25
25
 
26
26
  $ md2review your-document.md > your-document.re
27
27
 
28
+ ## History
29
+
30
+ * 1.4.0
31
+ * fix handling empty cell in //table
32
+ * support header attributes in PHP Markdown Extra
33
+ * 1.3.0
34
+ * allow images in list items (with @<icon>)
35
+ * add option --disable-image-caption
36
+ * allow 6th header level
37
+ * add option --render-link-in-footnote (by @masarakki)
38
+ * support inline markup in footnote (by @hamano)
39
+
28
40
  ## Contributing
29
41
 
30
42
  1. Fork it
@@ -1,3 +1,3 @@
1
1
  module MD2ReVIEW
2
- VERSION = "1.3.0"
2
+ VERSION = "1.4.0"
3
3
  end
@@ -22,11 +22,11 @@ module Redcarpet
22
22
  end
23
23
 
24
24
  def escape_inline(text)
25
- text.gsub(/\}/){'\\}'}
25
+ text.gsub(/\}/){ '\\}' }
26
26
  end
27
27
 
28
28
  def escape_href(text)
29
- text.to_s.gsub(/,/){'\\,'}
29
+ text.to_s.gsub(/,/){ '\\,' }
30
30
  end
31
31
 
32
32
  def block_code(code, language)
@@ -45,7 +45,7 @@ module Redcarpet
45
45
 
46
46
  def block_quote(quote)
47
47
  quote_text = normal_text(quote).chomp
48
- quote_text.gsub!(/\A\n\n/,'')
48
+ quote_text.gsub!(/\A\n\n/, '')
49
49
  "\n//quote{\n#{quote_text}\n//}\n"
50
50
  end
51
51
 
@@ -64,23 +64,29 @@ module Redcarpet
64
64
  end
65
65
 
66
66
  def header(title, level, anchor="")
67
+ buf = ""
68
+ if /\s*(\{.*?\})\s*$/ =~ title
69
+ buf << "\n#@# header_attribute: #{$1}"
70
+ title = $`
71
+ end
67
72
  l = level - @header_offset
68
73
  case l
69
74
  when 1
70
- "\n= #{title}\n"
75
+ buf << "\n= #{title}\n"
71
76
  when 2
72
- "\n== #{title}\n"
77
+ buf << "\n== #{title}\n"
73
78
  when 3
74
- "\n=== #{title}\n"
79
+ buf << "\n=== #{title}\n"
75
80
  when 4
76
- "\n==== #{title}\n"
81
+ buf << "\n==== #{title}\n"
77
82
  when 5
78
- "\n===== #{title}\n"
83
+ buf << "\n===== #{title}\n"
79
84
  when 6
80
- "\n====== #{title}\n"
85
+ buf << "\n====== #{title}\n"
81
86
  else
82
87
  raise "too long header"
83
88
  end
89
+ buf
84
90
  end
85
91
 
86
92
  def table(header, body)
@@ -101,11 +107,16 @@ module Redcarpet
101
107
  def table_cell(content, alignment)
102
108
  sep = @sep
103
109
  @sep = "\t"
110
+ if content == ""
111
+ content = "."
112
+ elsif content =~ /\A\./
113
+ content = "." + content
114
+ end
104
115
  "#{sep}#{content}"
105
116
  end
106
117
 
107
118
  def image(link, title, alt_text)
108
- filename = File.basename(link,".*")
119
+ filename = File.basename(link, ".*")
109
120
  if @image_caption
110
121
  "//image[#{filename}][#{alt_text}]{\n//}\n"
111
122
  else
@@ -164,6 +175,8 @@ module Redcarpet
164
175
  else
165
176
  ret << " * " << item
166
177
  end
178
+ else
179
+ raise "invalid type: #{list_type}"
167
180
  end
168
181
  end
169
182
  ret
@@ -175,15 +188,17 @@ module Redcarpet
175
188
  }
176
189
  case list_type
177
190
  when :ordered
178
- item = content.gsub(/\n(\s+[^0-9])/){$1}.gsub(/\n(\s+[0-9]+[^.])/){$1}.strip
191
+ item = content.gsub(/\n(\s+[^0-9])/){ $1 }.gsub(/\n(\s+[0-9]+[^.])/){ $1 }.strip
179
192
  "#{item}\n"
180
193
  when :unordered
181
- item = content.gsub(/\n(\s*[^* ])/){$1}.strip
194
+ item = content.gsub(/\n(\s*[^* ])/){ $1 }.strip
182
195
  "#{item}\n"
196
+ else
197
+ raise "invalid type: #{list_type}"
183
198
  end
184
199
  end
185
200
 
186
- def table_id()
201
+ def table_id
187
202
  @table_num += 1
188
203
  "#{@table_id_prefix}#{@table_num}"
189
204
  end
@@ -205,7 +220,7 @@ module Redcarpet
205
220
  "#{text}"
206
221
  end
207
222
 
208
- def footnote_def(text,number)
223
+ def footnote_def(text, number)
209
224
  "\n//footnote[#{number}][#{text.strip}]\n"
210
225
  end
211
226
 
data/test/review_test.rb CHANGED
@@ -52,6 +52,11 @@ class ReVIEWTest < Test::Unit::TestCase
52
52
  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")
53
53
  end
54
54
 
55
+ def test_header_attributes
56
+ assert_respond_to @markdown, :render
57
+ assert_equal "\n\#@# header_attribute: {-}\n= AAA\n\n\#@# header_attribute: {\#foo .bar title=hoge}\n= BBB\n", @markdown.render("\#AAA {-}\n\n\#BBB {\#foo .bar title=hoge}\n\n")
58
+ end
59
+
55
60
  def test_image
56
61
  assert_equal "\n\n//image[image][test]{\n//}\n\n\n", @markdown.render("![test](path/to/image.jpg)\n")
57
62
  end
@@ -82,6 +87,11 @@ class ReVIEWTest < Test::Unit::TestCase
82
87
  assert_equal " 1. aaa@<br>{}@<icon>{foo}\n 1. bbb\n 1. ccc\n", @markdown.render("1. aaa \n ![test](foo.jpg)\n2. bbb\n3. ccc\n")
83
88
  end
84
89
 
90
+ def test_table_with_empty_cell
91
+ 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])
92
+ assert_equal "//table[tbl1][]{\na\tb\tc\n-----------------\nA\tB\tC\n.\tB\tC\n..A\tB\tC\n//}\n", rd
93
+ end
94
+
85
95
  def test_code_fence_with_caption
86
96
  rd = render_with({:fenced_code_blocks => true}, %Q[~~~ {caption="test"}\ndef foo\n p "test"\nend\n~~~\n])
87
97
  assert_equal %Q[\n//emlist[test]{\ndef foo\n p "test"\nend\n//}\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.3.0
4
+ version: 1.4.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-01-15 00:00:00.000000000 Z
11
+ date: 2015-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redcarpet