qiita-markdown 0.2.1 → 0.2.2

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.

Potentially problematic release.


This version of qiita-markdown might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 248dab83e19fd3e32b11fa78625b51a24f36479b
4
- data.tar.gz: 8e564e30dfca3ed14cbcfc5377d493150baad7a0
3
+ metadata.gz: a2246b9c7de465987d8096f8f06dff05874c31b1
4
+ data.tar.gz: 7f980024c9522ba903c7ffaa6da2964b4b78d907
5
5
  SHA512:
6
- metadata.gz: 9f80abb21c9f17a44eb8a9727cac09d61699f247d6119bde8e82bf686fcf35c3efb64152a623962b312ac2cc7a0d7128088912d86a660e02c2ba3aaa57fd4b2a
7
- data.tar.gz: 3c39f211272a8302879811ef3866d1c5f4a42df751109fa664a470da4db842f25a50d26bb0f9bf8b028ec8159ff19608f76d8cdf491a9bc6ef557317ad84f47c
6
+ metadata.gz: c83fa85dced0ec7c9dc7f4962073b5576b9dc6ef6b6c2616cb3fd6bcb033ae56e1f85a77553b9f8d350c030f5f711b57fd0d0a337bfa0eaf6671cd142675b2e3
7
+ data.tar.gz: ae5a0ccaf8a142815d3fefc1030f24bda3cfab000abc75af67c698df4771b7cae64348908e0e53a419e637bbdba153a952aae34a42b7bdbdf2a1e43cb4b1e467
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.2.2
2
+ - Fix a bug that raised error on rendering `<a>` tag with href for unknown fragment inside of `<sup>` tag (e.g. `<sup><a href="#foo.1">Link</a></sup>`)
3
+
1
4
  ## 0.2.1
2
5
  - Strengthen sanitization (thx xrekkusu)
3
6
 
@@ -4,13 +4,20 @@ module Qiita
4
4
  class Footnote < HTML::Pipeline::Filter
5
5
  def call
6
6
  doc.search("sup > a").each do |a|
7
- href = a["href"]
8
- if href.start_with?("#") && (li = doc.search(href).first)
9
- a[:title] = li.text.gsub(/\A\n/, "").gsub(/ ↩\n\z/, "")
10
- end
7
+ footnote = find_footnote(a)
8
+ next unless footnote
9
+ a[:title] = footnote.text.gsub(/\A\n/, "").gsub(/ ↩\n\z/, "")
11
10
  end
12
11
  doc
13
12
  end
13
+
14
+ private
15
+
16
+ def find_footnote(a)
17
+ href = a["href"]
18
+ return nil if !href || href.match(/\A#fn\d+\z/).nil?
19
+ doc.search(href).first
20
+ end
14
21
  end
15
22
  end
16
23
  end
@@ -1,5 +1,5 @@
1
1
  module Qiita
2
2
  module Markdown
3
- VERSION = "0.2.1"
3
+ VERSION = "0.2.2"
4
4
  end
5
5
  end
@@ -561,5 +561,19 @@ describe Qiita::Markdown::Processor do
561
561
  EOS
562
562
  end
563
563
  end
564
+
565
+ context 'with manually written <a> tag with strange href inside of <sup> tag' do
566
+ let(:markdown) do
567
+ <<-EOS.strip_heredoc
568
+ <sup><a href="#foo.1">Link</a></sup>
569
+ EOS
570
+ end
571
+
572
+ it "does not confuse the structure with automatically generated footnote reference" do
573
+ should eq <<-EOS.strip_heredoc
574
+ <p><sup><a href="#foo.1">Link</a></sup></p>
575
+ EOS
576
+ end
577
+ end
564
578
  end
565
579
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qiita-markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-23 00:00:00.000000000 Z
11
+ date: 2015-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport