jekyll-highlight 1.0.3 → 1.0.4

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: 45ebe4dc194571ffd88159276b6bd6701803822c
4
- data.tar.gz: 7055928401b0aa6b1fb4392c318ab86e9583fc87
3
+ metadata.gz: 173f25fad42453331ffe67273ef989a618c40c33
4
+ data.tar.gz: d3b267c082306e3f895c75d9c8ab8c976db00a11
5
5
  SHA512:
6
- metadata.gz: f68b5518e69eabe314a4c649d628b9ca7d079727055b6a6bb0e87a5e5daa6dc06642c8e3129fc78bf08db6cc5189be5b109dbd16691766b04e5ea318a9c30d39
7
- data.tar.gz: cda0eae353f1728b5d3e28f562d595d17f7c6cbf6d6617037df163bd9c3426da48155f6ead4b623281bde71bf6d783ef37f0cae784a25f768d57007e3e6ee12c
6
+ metadata.gz: c757b4cc2745a6d6967373ddd8f3f7aee97879c0c55c6c12c48eaa1c75bf090fcc0032171b8fc5d84f6e6cc322cee130b18f3f88a8e95236fdd241a8ce687a17
7
+ data.tar.gz: b6a3d2b54cb3c9be6a76745800088ebe8668e46b0410aabd0661b33955e857fe1283eb3aed40efd3a1666bd11c6beceaadaf0bc182144210de4f115480c5fc3a
@@ -8,8 +8,9 @@ module Jekyll
8
8
  # forms: name, name=value, or name="<quoted list>"
9
9
  #
10
10
  # <quoted list> is a space-separated list of numbers
11
- PARAM_SYNTAX = %r!^([a-zA-Z0-9.+#_-]+)((\s+\w+(=(\w+|"([0-9]+\s)*[0-9]+"))?)*)$!
11
+ PARAM_SYNTAX = /^([a-zA-Z0-9.+#_-]+)((\s+\w+(=(\w+|"([0-9]+\s)*[0-9]+"))?)*)$/
12
12
 
13
+ # rubocop:disable Style/GuardClause
13
14
  def initialize(tag_name, markup, tokens)
14
15
  super
15
16
  if markup.strip =~ PARAM_SYNTAX
@@ -26,10 +27,11 @@ eos
26
27
  end
27
28
  end
28
29
 
30
+ # rubocop:disable Metrics/MethodLength,Metrics/AbcSize,Style/DoubleNegation
29
31
  def render(context)
30
32
  prefix = context["highlighter_prefix"] || ""
31
33
  suffix = context["highlighter_suffix"] || ""
32
- code = super.to_s.gsub(%r!\A(\n|\r)+|(\n|\r)+\z!, "")
34
+ code = super.to_s.gsub(/\A(\n|\r)+|(\n|\r)+\z/, "")
33
35
 
34
36
  is_safe = !!context.registers[:site].safe
35
37
 
@@ -54,7 +56,7 @@ eos
54
56
  [:hl_lines, opts.fetch(:hl_lines, nil)],
55
57
  [:linenos, opts.fetch(:linenos, nil)],
56
58
  [:encoding, opts.fetch(:encoding, "utf-8")],
57
- [:cssclass, opts.fetch(:cssclass, nil)],
59
+ [:cssclass, opts.fetch(:cssclass, nil)]
58
60
  ].reject { |f| f.last.nil? }]
59
61
  else
60
62
  opts
@@ -63,11 +65,12 @@ eos
63
65
 
64
66
  private
65
67
 
68
+ # rubocop:disable Metrics/CyclomaticComplexity
66
69
  def parse_options(input)
67
70
  options = {}
68
71
  unless input.empty?
69
72
  # Split along 3 possible forms -- key="<quoted list>", key=value, or key
70
- input.scan(%r!(?:\w="[^"]*"|\w=\w|\w)+!) do |opt|
73
+ input.scan(/(?:\w="[^"]*"|\w=\w|\w)+/) do |opt|
71
74
  key, value = opt.split("=")
72
75
  # If a quoted list, convert to array
73
76
  if value && value.include?("\"")
@@ -88,8 +91,8 @@ eos
88
91
 
89
92
  highlighted_code = Pygments.highlight(
90
93
  code,
91
- :lexer => @lang,
92
- :options => sanitized_opts(@highlight_options, is_safe)
94
+ lexer: @lang,
95
+ options: sanitized_opts(@highlight_options, is_safe)
93
96
  )
94
97
 
95
98
  if highlighted_code.nil?
@@ -111,8 +114,8 @@ eos
111
114
  def render_rouge(code)
112
115
  Jekyll::External.require_with_graceful_fail("rouge")
113
116
  formatter = Rouge::Formatters::HTML.new(
114
- :line_numbers => @highlight_options[:linenos],
115
- :wrap => false
117
+ line_numbers: @highlight_options[:linenos],
118
+ wrap: false
116
119
  )
117
120
  lexer = Rouge::Lexer.find_fancy(@lang, code) || Rouge::Lexers::PlainText
118
121
  formatter.format(lexer.lex(code))
@@ -124,8 +127,8 @@ eos
124
127
 
125
128
  def add_code_tag(code)
126
129
  code_attributes = [
127
- "class=\"language-#{@lang.to_s.tr("+", "-")}\"",
128
- "data-lang=\"#{@lang}\"",
130
+ "class=\"language-#{@lang.to_s.tr('+', '-')}\"",
131
+ "data-lang=\"#{@lang}\""
129
132
  ].join(" ")
130
133
  "<figure class=\"highlight\"><pre><code #{code_attributes}>"\
131
134
  "#{code.chomp}</code></pre></figure>"
@@ -134,4 +137,4 @@ eos
134
137
  end
135
138
  end
136
139
 
137
- Liquid::Template.register_tag("highlight", Jekyll::Tags::HighlightBlock)
140
+ Liquid::Template.register_tag("highlight", Jekyll::Tags::HighlightBlock)
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Highlight
3
- VERSION = "1.0.3".freeze
3
+ VERSION = "1.0.4".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-highlight
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Torgny Bjers