devcenter-parser 1.3.4 → 1.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
- metadata.gz: 00864c53d10600e6cccd5e25c00d06f137f64f7e
4
- data.tar.gz: 84f810e795e30e8da6f0a9ac870caf3120b20ef7
3
+ metadata.gz: 3431e9dabf9d7ca6f57b68cdfdcc3072cb78f6ef
4
+ data.tar.gz: f598db39a54c8a0d2dc1790a9e892251bc39a474
5
5
  !binary "U0hBNTEy":
6
- metadata.gz: 0b7343fe802c7a3940b47b8c8ab8651dc694d65db9ecb5eeafe47e862c9707a71415c6a35839dff891f39ca80ef60a0ba68bd69337539d69849013cf53d50beb
7
- data.tar.gz: fffb99dddf5e8cb7102a7129d8ee0022e04d6547e419baf8149fb47af5a73b1145d63fe16585d5e8580117a77a7e1840049d69a21459acae5947a873f69bb205
6
+ metadata.gz: 7c8a1f16903ec6d5c0028e61f28bcdd0953366fc7e549f8b330d4bd027c9687be2bf14a18a0a08b395ee232b4f4e4566c245a6fdb85f3cc98dfd1af2161ae941
7
+ data.tar.gz: 63cf77e86c96ce0f00bd8d3db171826e04bbf6b6cb62797dbc32ee4dd17efa8f155bb3b0a46da83ba675e3c99681f9918d88f5df844e7d6654f83d42ac1ffb13
@@ -6,7 +6,7 @@ require 'sanitize'
6
6
 
7
7
  module DevcenterParser
8
8
 
9
- VERSION = '1.3.4'
9
+ VERSION = '1.3.5'
10
10
 
11
11
  AVAILABLE_FLAVOURS = [:github, :maruku]
12
12
 
@@ -23,23 +23,8 @@ module DevcenterParser
23
23
  sanitize(html)
24
24
  end
25
25
 
26
- # The current parsers consider something like:
27
- # > foo
28
- #
29
- # > bar
30
- # as a single blockquote, while we want it to be two different ones.
31
- # This method adds an empty paragraph between consecutive blocks so parsers process them separately
32
- def self.separate_consecutive_blockquote_blocks(markdown)
33
- separator = '<p class="devcenter-parser-special-block-separator" style="display:none">&nbsp;</p>'
34
- markdown.gsub(/^>(.*)?\s\s>/, '>\1' + "\n\n#{separator}\n\n>")
35
- end
36
-
37
- def self.normalize_newlines(markdown)
38
- markdown.lines.map{ |l| l.chomp }.join("\n")
39
- end
40
-
41
26
  def self.to_unsanitized_html(markdown, flavour)
42
- markdown = normalize_newlines(markdown)
27
+ markdown = normalize_newlines(markdown.to_s)
43
28
  markdown = separate_consecutive_blockquote_blocks(markdown)
44
29
  doc = case flavour.to_sym
45
30
  when :maruku
@@ -71,6 +56,21 @@ module DevcenterParser
71
56
 
72
57
  private
73
58
 
59
+ # The current parsers consider something like:
60
+ # > foo
61
+ #
62
+ # > bar
63
+ # as a single blockquote, while we want it to be two different ones.
64
+ # This method adds an empty paragraph between consecutive blocks so parsers process them separately
65
+ def self.separate_consecutive_blockquote_blocks(markdown)
66
+ separator = '<p class="devcenter-parser-special-block-separator" style="display:none">&nbsp;</p>'
67
+ markdown.gsub(/^>(.*)?\s\s>/, '>\1' + "\n\n#{separator}\n\n>")
68
+ end
69
+
70
+ def self.normalize_newlines(markdown)
71
+ markdown.lines.map{ |l| l.chomp }.join("\n")
72
+ end
73
+
74
74
  def self.github_parser
75
75
  @@github_parser ||= Redcarpet::Markdown.new(HTMLWithPantsRenderer, fenced_code_blocks: true, tables: true)
76
76
  end
@@ -5,15 +5,27 @@ require_relative '../lib/devcenter-parser'
5
5
  describe 'DevcenterParser' do
6
6
 
7
7
  describe '.to_unsanitized_html' do
8
+
9
+ it 'returns empty string for nil input' do
10
+ assert_parsing_unsanitized_result nil, :maruku, ''
11
+ assert_parsing_unsanitized_result nil, :maruku, ''
12
+ end
13
+
8
14
  it 'maintains script tags' do
9
15
  md = '<script>alert("hi")</script>'
10
16
  assert_parsing_unsanitized_result md, :maruku, md
11
17
  assert_parsing_unsanitized_result md, :github, '<script>alert("hi")</script>'
12
18
  end
19
+
13
20
  end
14
21
 
15
22
  describe '.to_html' do
16
23
 
24
+ it 'returns empty string for nil input' do
25
+ assert_maruku_result nil, ''
26
+ assert_github_result nil, ''
27
+ end
28
+
17
29
  it 'raises InvalidMarkdownError when parsing invalid markdown' do
18
30
  md = '[foo](bar'
19
31
  assert_raises DevcenterParser::InvalidMarkdownError do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devcenter-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 1.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Heroku
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-24 00:00:00.000000000 Z
11
+ date: 2013-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: maruku