jekyll-mentions 1.3.0 → 1.4.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jekyll-mentions.rb +15 -12
  3. metadata +5 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8090d5f034e3e6580ba8532ddf6994019a3ac65bdba51124958ddee7fe20dfcf
4
- data.tar.gz: 0a6dad4a4ef00908d9773e408efe169c11b9958f1c1aa36461a0a2c32ae817f0
3
+ metadata.gz: e0e89bf24b373986c0a5934b996d213d48b650ef6561c875ac63d549688d9175
4
+ data.tar.gz: 3b1aaab991d6ac8039918f5ade4b68cbad5015db70d6d7ada4854222672da470
5
5
  SHA512:
6
- metadata.gz: a3979cd66900184782818d1ddb829d8029dd25c7fc27d8c9e7e6677c992aa10ff8a33d35d64a4c9508ceb9dce369719f870ee0f0fc5dc4bced0c82a85c551e50
7
- data.tar.gz: 2ee4a7702dfc3a34afcff5004e150069874c2ab84c759228d41138942a72317fc1e9da80d7ae46424dfd1367255c2b8b945ea9034d4586605d2b5e55f9892674
6
+ metadata.gz: e6c7e8c1dcc85fae48b7c81e54af94842d8d1c5c32365e309aa260290bb1636a896540928331ff25fe0f309afca8cadce84d5e9b0741612a000fa58b9bfd1ea7
7
+ data.tar.gz: adcdff7b0d75a5f5de02804e8d4c46dc98f43dbe6f30059f5698bdb6b617f5f7344c10c44ac0587200f16ef645772d67c65504b8ffc75ca2616f8f46fb505b79
@@ -5,27 +5,30 @@ require "html/pipeline"
5
5
 
6
6
  module Jekyll
7
7
  class Mentions
8
- GITHUB_DOT_COM = "https://github.com".freeze
9
- BODY_START_TAG = "<body".freeze
8
+ GITHUB_DOT_COM = "https://github.com"
9
+ BODY_START_TAG = "<body"
10
+
11
+ OPENING_BODY_TAG_REGEX = %r!<body(.*)>\s*!
10
12
 
11
13
  InvalidJekyllMentionConfig = Class.new(Jekyll::Errors::FatalException)
12
14
 
13
15
  class << self
14
16
  # rubocop:disable Metrics/AbcSize
15
17
  def mentionify(doc)
16
- return unless doc.output.include?("@")
18
+ content = doc.output
19
+ return unless content.include?("@")
17
20
  src = mention_base(doc.site.config)
18
- if doc.output.include? BODY_START_TAG
19
- parsed_doc = Nokogiri::HTML::Document.parse(doc.output)
20
- body = parsed_doc.at_css("body")
21
+ if content.include? BODY_START_TAG
22
+ head, opener, tail = content.partition(OPENING_BODY_TAG_REGEX)
23
+ body_content, *rest = tail.partition("</body>")
21
24
 
22
- return unless body.to_html =~ filter_regex
25
+ return unless body_content =~ filter_regex
23
26
 
24
- body.children = filter_with_mention(src).call(body.inner_html)[:output].to_s
25
- doc.output = parsed_doc.to_html
27
+ processed_markup = filter_with_mention(src).call(body_content)[:output].to_s
28
+ doc.output = String.new(head) << opener << processed_markup << rest.join
26
29
  else
27
- return unless doc.output =~ filter_regex
28
- doc.output = filter_with_mention(src).call(doc.output)[:output].to_s
30
+ return unless content =~ filter_regex
31
+ doc.output = filter_with_mention(src).call(content)[:output].to_s
29
32
  end
30
33
  end
31
34
  # rubocop:enable Metrics/AbcSize
@@ -84,7 +87,7 @@ module Jekyll
84
87
  # Returns true if the doc is written & is HTML.
85
88
  def mentionable?(doc)
86
89
  (doc.is_a?(Jekyll::Page) || doc.write?) &&
87
- doc.output_ext == ".html" || (doc.permalink && doc.permalink.end_with?("/"))
90
+ doc.output_ext == ".html" || (doc.permalink&.end_with?("/"))
88
91
  end
89
92
 
90
93
  private
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-mentions
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-14 00:00:00.000000000 Z
11
+ date: 2018-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: activesupport
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '4.0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '4.0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: html-pipeline
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +72,14 @@ dependencies:
86
72
  requirements:
87
73
  - - '='
88
74
  - !ruby/object:Gem::Version
89
- version: '0.51'
75
+ version: '0.55'
90
76
  type: :development
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
80
  - - '='
95
81
  - !ruby/object:Gem::Version
96
- version: '0.51'
82
+ version: '0.55'
97
83
  description:
98
84
  email: support@github.com
99
85
  executables: []
@@ -113,7 +99,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
99
  requirements:
114
100
  - - ">="
115
101
  - !ruby/object:Gem::Version
116
- version: '0'
102
+ version: 2.3.0
117
103
  required_rubygems_version: !ruby/object:Gem::Requirement
118
104
  requirements:
119
105
  - - ">="