qiita-markdown 0.1.7 → 0.1.8

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: 3d25866f4406e5d404845b15505637556d6ef12e
4
- data.tar.gz: cd8bc17d878fcacc598c0f97e04e1b00941f9cb2
3
+ metadata.gz: 0a51a261ae49b1f70422fd8bdc369a74f6642af5
4
+ data.tar.gz: 4a60fcc69702d2bb73eeed3a0e05b1cdedbcc93d
5
5
  SHA512:
6
- metadata.gz: 9712614c01f262c557eadbb2978a39c9123b177ea251917b497587bc91ca95472b92c3587aacdf025c051ac0b50b0e76969781f0b4a60771a1fb15fd0fb9ac4e
7
- data.tar.gz: 75465de23affa1517af97383a7a17319579ba3afea15b17c1d8a14ad0d35bf7fc37bfe3f9b15b6dd2e3c86f0765c175da8e5a11ec567f7f416538edd3de52d12
6
+ metadata.gz: 415b4b139299e1d7a66f9d8940e6eb4f498bdb38680f94841b270abb8d37f12f6593830b7ea75f1acb16f86a260c5934f4a224000592d204e6bec1666c77feb7
7
+ data.tar.gz: d5e627bced5f6ea45a5d755f8f6930b2053de23b0e44857cce03167f3c4412ca78229ede162a04e114b705ad72bdb95bdd39a8a035c3f28c109f27458003b646
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.1.8
2
+ - Add title attribute into footnote link element
3
+
1
4
  ## 0.1.7
2
5
  - Enable footnotes markdown syntax
3
6
 
@@ -9,6 +9,7 @@ require "sanitize"
9
9
 
10
10
  require "qiita/markdown/filters/checkbox"
11
11
  require "qiita/markdown/filters/code"
12
+ require "qiita/markdown/filters/footnote"
12
13
  require "qiita/markdown/filters/mention"
13
14
  require "qiita/markdown/filters/redcarpet"
14
15
  require "qiita/markdown/filters/sanitize"
@@ -0,0 +1,16 @@
1
+ module Qiita
2
+ module Markdown
3
+ module Filters
4
+ class Footnote < HTML::Pipeline::Filter
5
+ def call
6
+ doc.search("sup > a").each do |a|
7
+ if li = doc.search(a["href"]).first
8
+ a[:title] = li.text.gsub(/\A\n/, "").gsub(/ ↩\n\z/, "")
9
+ end
10
+ end
11
+ doc
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -8,6 +8,7 @@ module Qiita
8
8
  DEFAULT_FILTERS = [
9
9
  Filters::Redcarpet,
10
10
  Filters::Sanitize,
11
+ Filters::Footnote,
11
12
  Filters::Code,
12
13
  Filters::Checkbox,
13
14
  Filters::Toc,
@@ -1,5 +1,5 @@
1
1
  module Qiita
2
2
  module Markdown
3
- VERSION = "0.1.7"
3
+ VERSION = "0.1.8"
4
4
  end
5
5
  end
@@ -91,7 +91,7 @@ describe Qiita::Markdown::Processor do
91
91
  end
92
92
  end
93
93
 
94
- context 'with code & filename' do
94
+ context "with code & filename" do
95
95
  let(:markdown) do
96
96
  <<-EOS.strip_heredoc
97
97
  ```example.rb
@@ -100,7 +100,7 @@ describe Qiita::Markdown::Processor do
100
100
  EOS
101
101
  end
102
102
 
103
- it 'returns code-frame, code-lang, and highlighted pre element' do
103
+ it "returns code-frame, code-lang, and highlighted pre element" do
104
104
  should eq <<-EOS.strip_heredoc
105
105
  <div class="code-frame" data-lang="ruby">
106
106
  <div class="code-lang"><span class="bold">example.rb</span></div>
@@ -112,7 +112,7 @@ describe Qiita::Markdown::Processor do
112
112
 
113
113
  end
114
114
 
115
- context 'with code & no filename' do
115
+ context "with code & no filename" do
116
116
  let(:markdown) do
117
117
  <<-EOS.strip_heredoc
118
118
  ```ruby
@@ -121,7 +121,7 @@ describe Qiita::Markdown::Processor do
121
121
  EOS
122
122
  end
123
123
 
124
- it 'returns code-frame and highlighted pre element' do
124
+ it "returns code-frame and highlighted pre element" do
125
125
  should eq <<-EOS.strip_heredoc
126
126
  <div class="code-frame" data-lang="ruby"><div class="highlight"><pre><span class="mi">1</span>
127
127
  </pre></div></div>
@@ -157,7 +157,7 @@ describe Qiita::Markdown::Processor do
157
157
  end
158
158
 
159
159
  it "removes script element" do
160
- should eq "<p></p>\n"
160
+ should eq "\n"
161
161
  end
162
162
  end
163
163
 
@@ -326,7 +326,7 @@ describe Qiita::Markdown::Processor do
326
326
  end
327
327
 
328
328
  it "replaces it with img element" do
329
- should include('img')
329
+ should include("img")
330
330
  end
331
331
  end
332
332
 
@@ -340,7 +340,7 @@ describe Qiita::Markdown::Processor do
340
340
  end
341
341
 
342
342
  it "does not replace it" do
343
- should_not include('img')
343
+ should_not include("img")
344
344
  end
345
345
  end
346
346
 
@@ -420,7 +420,7 @@ describe Qiita::Markdown::Processor do
420
420
  end
421
421
  end
422
422
 
423
- context 'with task list in code block' do
423
+ context "with task list in code block" do
424
424
  let(:markdown) do
425
425
  <<-EOS.strip_heredoc
426
426
  ```
@@ -439,7 +439,7 @@ describe Qiita::Markdown::Processor do
439
439
  end
440
440
  end
441
441
 
442
- context 'with empty line between task list' do
442
+ context "with empty line between task list" do
443
443
  let(:markdown) do
444
444
  <<-EOS.strip_heredoc
445
445
  - [ ] a
@@ -458,7 +458,7 @@ describe Qiita::Markdown::Processor do
458
458
  end
459
459
  end
460
460
 
461
- context 'with empty list' do
461
+ context "with empty list" do
462
462
  let(:markdown) do
463
463
  "- \n"
464
464
  end
@@ -472,7 +472,7 @@ describe Qiita::Markdown::Processor do
472
472
  end
473
473
  end
474
474
 
475
- context 'with text-aligned table' do
475
+ context "with text-aligned table" do
476
476
  let(:markdown) do
477
477
  <<-EOS.strip_heredoc
478
478
  | a | b | c |
@@ -502,5 +502,31 @@ describe Qiita::Markdown::Processor do
502
502
  EOS
503
503
  end
504
504
  end
505
+
506
+ context 'with footenotes syntax' do
507
+ let(:markdown) do
508
+ <<-EOS.strip_heredoc
509
+ [^1]
510
+ [^1]: test
511
+ EOS
512
+ end
513
+
514
+ it "generates footnotes elements" do
515
+ should eq <<-EOS.strip_heredoc
516
+ <p><sup id="fnref1"><a href="#fn1" title="test">1</a></sup></p>
517
+
518
+ <div class="footnotes">
519
+ <hr>
520
+ <ol>
521
+
522
+ <li id="fn1">
523
+ <p>test <a href="#fnref1">↩</a></p>
524
+ </li>
525
+
526
+ </ol>
527
+ </div>
528
+ EOS
529
+ end
530
+ end
505
531
  end
506
532
  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.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-12 00:00:00.000000000 Z
11
+ date: 2014-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -211,6 +211,7 @@ files:
211
211
  - lib/qiita/markdown.rb
212
212
  - lib/qiita/markdown/filters/checkbox.rb
213
213
  - lib/qiita/markdown/filters/code.rb
214
+ - lib/qiita/markdown/filters/footnote.rb
214
215
  - lib/qiita/markdown/filters/mention.rb
215
216
  - lib/qiita/markdown/filters/redcarpet.rb
216
217
  - lib/qiita/markdown/filters/sanitize.rb