html-pipeline 2.2.4 → 2.3.0

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
  SHA1:
3
- metadata.gz: d024be6b98d12461e4abdf314fba27b91a6c519d
4
- data.tar.gz: 3f07269ac32bf661022c4c78b6cc1353054c9d40
3
+ metadata.gz: e870978544619b3fa0227bbd4cc8c6e36949780d
4
+ data.tar.gz: 99761bada479fffb0f7274db2518d909dd5e893a
5
5
  SHA512:
6
- metadata.gz: 40b87e0e6026609001cb9eda168dc75bce1804bbba55137d8af35c79f38d46381dab9444c77f919ea346cd595fd2b5f82e73222a353a24e17570f6fe7b5cc010
7
- data.tar.gz: 2186705979bce94663edf7d1ec00195823f21d1421b1a5755304d29b88ec5b569b5258915e407ca6acbe5f1efc2acd52e67062ad01ebc2b0c5e1ad6d744aee04
6
+ metadata.gz: 99901c855f115587bcda2679e6a4cc465fe0c2eb26002bc92ec6c24610e74e01924f71f58590680f8f440418d2761ce4be42445dd39866835f85067bbc26aa69
7
+ data.tar.gz: 120582d65f9d33660acd0230324633a191931122d2e84c965d9d18332a4f9e6531d7ad04310f1f5711269fd8edeb75ce45e23b867e0d9a0582df933117c47cd8
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 2.3.0
4
+
5
+ * Add option to pass in an anchor icon, instead of using octicons [#244](https://github.com/jch/html-pipeline/pull/244)
6
+
3
7
  ## 2.2.4
4
8
 
5
9
  * Use entire namespace so MissingDependencyError constant is resolved [#243](https://github.com/jch/html-pipeline/pull/243)
@@ -25,6 +25,11 @@ module HTML
25
25
  class TableOfContentsFilter < Filter
26
26
  PUNCTUATION_REGEXP = RUBY_VERSION > "1.9" ? /[^\p{Word}\- ]/u : /[^\w\- ]/
27
27
 
28
+ # The icon that will be placed next to an anchored rendered markdown header
29
+ def anchor_icon
30
+ context[:anchor_icon] || "<span aria-hidden=\"true\" class=\"octicon octicon-link\"></span>"
31
+ end
32
+
28
33
  def call
29
34
  result[:toc] = ""
30
35
 
@@ -39,7 +44,7 @@ module HTML
39
44
  headers[id] += 1
40
45
  if header_content = node.children.first
41
46
  result[:toc] << %Q{<li><a href="##{id}#{uniq}">#{text}</a></li>\n}
42
- header_content.add_previous_sibling(%Q{<a id="#{id}#{uniq}" class="anchor" href="##{id}#{uniq}" aria-hidden="true"><span class="octicon octicon-link"></span></a>})
47
+ header_content.add_previous_sibling(%Q{<a id="#{id}#{uniq}" class="anchor" href="##{id}#{uniq}" aria-hidden="true">#{anchor_icon}</a>})
43
48
  end
44
49
  end
45
50
  result[:toc] = %Q{<ul class="section-nav">\n#{result[:toc]}</ul>} unless result[:toc].empty?
@@ -1,5 +1,5 @@
1
1
  module HTML
2
2
  class Pipeline
3
- VERSION = "2.2.4"
3
+ VERSION = "2.3.0"
4
4
  end
5
5
  end
@@ -20,6 +20,13 @@ class HTML::Pipeline::TableOfContentsFilterTest < Minitest::Test
20
20
  assert_includes TocFilter.call(orig).to_s, '<a id='
21
21
  end
22
22
 
23
+ def test_custom_anchor_icons_added_properly
24
+ orig = %(<h1>Ice cube</h1>)
25
+ expected = %Q{<h1>\n<a id="ice-cube" class="anchor" href="#ice-cube" aria-hidden="true">#</a>Ice cube</h1>}
26
+
27
+ assert_equal expected, TocFilter.call(orig, {:anchor_icon => "#"}).to_s
28
+ end
29
+
23
30
  def test_toc_list_added_properly
24
31
  @orig = %(<h1>Ice cube</h1><p>Will swarm on any motherfucker in a blue uniform</p>)
25
32
  assert_includes toc, %Q{<ul class="section-nav">\n<li><a href="}
@@ -107,9 +114,9 @@ class HTML::Pipeline::TableOfContentsFilterTest < Minitest::Test
107
114
 
108
115
  rendered_h1s = TocFilter.call(orig).search('h1').map(&:to_s)
109
116
 
110
- assert_equal "<h1>\n<a id=\"日本語\" class=\"anchor\" href=\"#%E6%97%A5%E6%9C%AC%E8%AA%9E\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"></span></a>日本語</h1>",
117
+ assert_equal "<h1>\n<a id=\"日本語\" class=\"anchor\" href=\"#%E6%97%A5%E6%9C%AC%E8%AA%9E\" aria-hidden=\"true\"><span aria-hidden=\"true\" class=\"octicon octicon-link\"></span></a>日本語</h1>",
111
118
  rendered_h1s[0]
112
- assert_equal "<h1>\n<a id=\"Русский\" class=\"anchor\" href=\"#%D0%A0%D1%83%D1%81%D1%81%D0%BA%D0%B8%D0%B9\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"></span></a>Русский</h1>",
119
+ assert_equal "<h1>\n<a id=\"Русский\" class=\"anchor\" href=\"#%D0%A0%D1%83%D1%81%D1%81%D0%BA%D0%B8%D0%B9\" aria-hidden=\"true\"><span aria-hidden=\"true\" class=\"octicon octicon-link\"></span></a>Русский</h1>",
113
120
  rendered_h1s[1]
114
121
  end
115
122
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html-pipeline
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.4
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Tomayko
@@ -9,40 +9,40 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-01-17 00:00:00.000000000 Z
12
+ date: 2016-01-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ">="
18
+ - - '>='
19
19
  - !ruby/object:Gem::Version
20
20
  version: '1.4'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ">="
25
+ - - '>='
26
26
  - !ruby/object:Gem::Version
27
27
  version: '1.4'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: activesupport
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ">="
32
+ - - '>='
33
33
  - !ruby/object:Gem::Version
34
34
  version: '2'
35
- - - "<"
35
+ - - <
36
36
  - !ruby/object:Gem::Version
37
37
  version: '5'
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  requirements:
42
- - - ">="
42
+ - - '>='
43
43
  - !ruby/object:Gem::Version
44
44
  version: '2'
45
- - - "<"
45
+ - - <
46
46
  - !ruby/object:Gem::Version
47
47
  version: '5'
48
48
  description: GitHub HTML processing filters and utilities
@@ -53,8 +53,8 @@ executables: []
53
53
  extensions: []
54
54
  extra_rdoc_files: []
55
55
  files:
56
- - ".gitignore"
57
- - ".travis.yml"
56
+ - .gitignore
57
+ - .travis.yml
58
58
  - CHANGELOG.md
59
59
  - CONTRIBUTING.md
60
60
  - Gemfile
@@ -118,17 +118,17 @@ require_paths:
118
118
  - lib
119
119
  required_ruby_version: !ruby/object:Gem::Requirement
120
120
  requirements:
121
- - - ">="
121
+ - - '>='
122
122
  - !ruby/object:Gem::Version
123
123
  version: '0'
124
124
  required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  requirements:
126
- - - ">="
126
+ - - '>='
127
127
  - !ruby/object:Gem::Version
128
128
  version: '0'
129
129
  requirements: []
130
130
  rubyforge_project:
131
- rubygems_version: 2.5.1
131
+ rubygems_version: 2.0.14
132
132
  signing_key:
133
133
  specification_version: 4
134
134
  summary: Helpers for processing content through a chain of filters