devcenter-parser 1.4.6 → 1.4.7

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: 0830bf58ad740ad5831ebd3d90b7045b3163b337
4
- data.tar.gz: fbba31fbf961ced6e017c28c93f753d5d466d28e
3
+ metadata.gz: ed18f1b8a6e84f0183d3596de7b36aea8e7c3275
4
+ data.tar.gz: 54c43006783052812ed750c842d502173d3022f8
5
5
  SHA512:
6
- metadata.gz: 3cf8eb95c7849e2a23976644e32d6f8a45785269b8e1ffda900f473ad7fedddb431e9a7cef847d95774145e6f83d6288194b23f099a8f0e4f4e21db206603a37
7
- data.tar.gz: 28f287f3983f65daf07e6e122c2ee6ad3b7502f9adb2acb2ca7bd1516eac6df1a3da2966c022ab8736a32d339840f48060358e3655d6a3c7def45ce221439bf7
6
+ metadata.gz: b3118fb98d3979c1fae417d05be13eb0e1d6bee53c1a10160ab4b7e0806571b73d9d14e1beda12d84628a65e57502d7b1e1a3804b904e30f98a9b437532e9c42
7
+ data.tar.gz: 4410ebecb05957bb2a04cc79755c58bd2318522cb0178066a4f84d5b715a71231bb7d40657ef8b7807b950dd70e40ab0abe18224ce59c35489d820f28cc2fd60
@@ -48,6 +48,7 @@ module DevcenterParser
48
48
 
49
49
  def self.normalize_markdown(markdown)
50
50
  markdown = normalize_newlines(markdown.to_s)
51
+ markdown = remove_tags_inside_html_comments(markdown)
51
52
  separate_consecutive_blockquote_blocks(markdown)
52
53
  end
53
54
 
@@ -66,6 +67,15 @@ module DevcenterParser
66
67
  markdown.lines.map{ |l| l.rstrip }.join("\n")
67
68
  end
68
69
 
70
+ def self.remove_tags_inside_html_comments(markdown)
71
+ markdown.gsub /<!--((.|\s)*?)-->/ do
72
+ inner = $1
73
+ inner.gsub!(/\[|\]|\(|\)|\<|\>/,'')
74
+ "<!--#{inner}-->"
75
+ end
76
+ end
77
+
78
+
69
79
  # Note that Sanitize requires all the elements/attributes downcased
70
80
  def self.sanitize_config
71
81
  return @@sanitize_config if defined?(@@sanitize_config)
@@ -8,6 +8,11 @@ module MarukuParser
8
8
  doc
9
9
  end
10
10
 
11
+ # This parser seem to deal correctly with tags inside HTML comments
12
+ def self.remove_tags_inside_html_comments(markdown)
13
+ markdown
14
+ end
15
+
11
16
  private
12
17
 
13
18
  def self.code_blocks(doc)
@@ -1,3 +1,3 @@
1
1
  module DevcenterParser
2
- VERSION = '1.4.6'
2
+ VERSION = '1.4.7'
3
3
  end
@@ -56,6 +56,60 @@ SRC
56
56
 
57
57
  describe 'github markdown' do
58
58
 
59
+ it 'removes markdown links or nested tags inside HTML comments' do
60
+ md = <<-MD
61
+ <!-- c1 -->
62
+ 1<!-- c2 -->
63
+ <!-- c3 -->2
64
+ 3<!-- c4 -->4
65
+
66
+ One
67
+
68
+ <!-- [c1](c1) -->
69
+ 5<!-- [c2](c2) -->
70
+ <!-- [c3](c3) -->6
71
+ 7<!-- [c4](c4) -->8
72
+
73
+ Two
74
+
75
+ <!-- <a href="#">c1</a> -->
76
+ 9<!-- <a href="#">c2</a> -->
77
+ <!-- <a href="#">c3</a> -->10
78
+ 11<!-- <a href="#">c4</a> -->12
79
+
80
+ Three
81
+ MD
82
+
83
+ html = <<-HTML
84
+ <!-- c1 -->
85
+
86
+ <p>1<!-- c2 -->
87
+ <!-- c3 -->2
88
+ 3<!-- c4 -->4</p>
89
+
90
+ <p>One</p>
91
+
92
+ <!-- c1c1 -->
93
+
94
+ <p>5<!-- c2c2 -->
95
+ <!-- c3c3 -->6
96
+ 7<!-- c4c4 -->8</p>
97
+
98
+ <p>Two</p>
99
+
100
+ <!-- a href="#"c1/a -->
101
+
102
+ <p>9<!-- a href=&quot;#&quot;c2/a -->
103
+ <!-- a href=&quot;#&quot;c3/a -->10
104
+ 11<!-- a href=&quot;#&quot;c4/a -->12</p>
105
+
106
+ <p>Three</p>
107
+ HTML
108
+
109
+ assert_github_result md, html
110
+ end
111
+
112
+
59
113
  it 'generates apostrophes from single quotes in plain text' do
60
114
  md = "That's it"
61
115
  html = "<p>That’s it</p>"
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.4.6
4
+ version: 1.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Heroku
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-04 00:00:00.000000000 Z
11
+ date: 2014-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: maruku