jekyll-microtypo 2.0.1 → 2.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e9383dd2c524023d1df8d42ee7b3fd6713046fb63b0af4dafc3f5760f7fdb61
4
- data.tar.gz: c9fa21a2514b510ff7433c5b3dc96816d319b511bef7ca3375155ee8f817697b
3
+ metadata.gz: 35c42c3c8b2d0048b9d5e97c56bfc9263d9033fdcfcda6b68366a64b371ff70f
4
+ data.tar.gz: b9c4e0776f522e027cc9fb08f151dd16911cac8476729e67606597e9309ff459
5
5
  SHA512:
6
- metadata.gz: ae386ed2ab4d9b484f486b2bf4425819f1bd84967189575995813dd216aa7380a2b12fba6ee03f54ff432fe949dcedba5fca967c675335a9fe6bf1eec9d5dc38
7
- data.tar.gz: 4086b04ed2c2532961a773b76fdf17fcc0c53f47518985c2676a35d7b91183dc5557a8f9013d151cf2ad08f1456fff92fc3a2d8295811aeb9d93dd1e343e856e
6
+ metadata.gz: 45a45926a84463dc19a9c8eab9063db529dc1e98db8e79667cecdbd1b419313308419123bc21ffda313fc8a1d126d23fdcb1e67cf1cf89fe4b50739c28c77032
7
+ data.tar.gz: f630a39f40cf740bd12328b8c5a0da2abb6c646bbf3d9a662a6adc61271140b80a28fd03ff2c6ea686936fe812c7453b46180acbea68daeb56b608b011b9e234
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module Microtypo
5
- VERSION = "2.0.1"
5
+ VERSION = "2.0.2"
6
6
  end
7
7
  end
@@ -9,10 +9,8 @@ module Jekyll
9
9
  ["<code", "</code>", true],
10
10
  ["<!-- nomicrotypo -->", "<!-- endnomicrotypo -->", false],
11
11
  ].freeze
12
- DEBUG = false
13
12
 
14
13
  private_constant :QUEUE
15
- private_constant :DEBUG
16
14
 
17
15
  def self.settings(config)
18
16
  @settings ||= {}
@@ -34,15 +32,18 @@ module Jekyll
34
32
 
35
33
  private
36
34
 
35
+ def debug?
36
+ ENV["JEKYLL_MICROTYPO_DEBUG"] == "1"
37
+ end
38
+
39
+ def debug
40
+ return unless debug? && block_given?
41
+ p yield
42
+ end
43
+
37
44
  def recursive_parser(input, locale, bucket, index)
38
45
  input = input.to_s
39
-
40
- prefix = " " + (" " * 3 * (QUEUE.size-index))
41
- p prefix + ' Fix microtypo for ' + input if DEBUG && index.zero? && DEBUG
42
- p prefix + ' and place it in the bucket' if DEBUG && index.zero?
43
46
  return fix_microtypo(+input, locale, bucket) if index.zero?
44
-
45
- p prefix + 'Recursive_parser for ' + input if DEBUG
46
47
 
47
48
  index -= 1
48
49
  head, tail, flag = QUEUE[index]
@@ -51,34 +52,27 @@ module Jekyll
51
52
  indexTail = input.index(tail)
52
53
 
53
54
  if indexHead.nil? || indexTail.nil? || indexHead > indexTail
54
- p prefix + input if DEBUG
55
- p prefix + 'doest not contain '+head+' then '+tail if DEBUG
55
+ debug { "#{input.inspect} does not contain #{head} then #{tail}" }
56
56
  return recursive_parser(input, locale, bucket, index)
57
57
  end
58
58
 
59
- p prefix + input if DEBUG
60
- p prefix + 'contains '+head+' then '+tail if DEBUG
59
+ debug { "#{input.inspect} contains #{head} then #{tail}" }
61
60
 
62
- p prefix + 'cuts the input in parts around '+ head if DEBUG
63
61
  input.split(head).each do |item|
64
62
  item = item.to_s
65
63
 
66
- p prefix + '-----part----' if DEBUG
67
- p prefix + item if DEBUG
68
-
69
64
  if item.include?(tail)
70
- p prefix + 'contains '+tail if DEBUG
65
+ debug { "contains #{tail}" }
71
66
  end_items = item.split(tail)
72
67
 
73
- p prefix + end_items.to_s if DEBUG
74
68
  if flag
75
69
  bucket << head << end_items[0] << tail
76
70
  else
77
71
  bucket << end_items[0]
78
72
  end
79
73
 
80
- p prefix + bucket.to_s if DEBUG
81
- if(end_items.length >= 2)
74
+ debug { bucket.inspect }
75
+ if end_items.length >= 2
82
76
  item = end_items.last
83
77
  recursive_parser(item, locale, bucket, index + 1)
84
78
  end
@@ -108,16 +102,16 @@ module Jekyll
108
102
  end
109
103
 
110
104
  # Special punctuation
111
- input.gsub!(%r!(\s)+\?\!([^\w]|$)!, '&#8239;&#8264;\2')
112
- input.gsub!(%r!(\s)+\!\?([^\w]|$)!, '&#8239;&#8265;\2')
113
- input.gsub!(%r!(\s)+\!\!\!([^\w]|$)!, '&#8239;&#8252;\2')
114
- input.gsub!(%r!(\s)+\!\!([^\w]|$)!, '&#8239;&#8252;\2')
105
+ input.gsub!(%r!\s+\?\!([^\w]|$)!, '&#8239;&#8264;\1')
106
+ input.gsub!(%r!\s+\!\?([^\w]|$)!, '&#8239;&#8265;\1')
107
+ input.gsub!(%r!\s+\!\!\!([^\w]|$)!, '&#8239;&#8252;\1')
108
+ input.gsub!(%r!\s+\!\!([^\w]|$)!, '&#8239;&#8252;\1')
115
109
 
116
110
  # Times
117
- input.gsub!(%r!(\s)+(\d+)(\s)*x(\s)*(?=\d)!, '\1\2&nbsp;&times;&nbsp;\5')
111
+ input.gsub!(%r!\s+(\d+)\s*x\s*(?=\d)!, ' \1&nbsp;&times;&nbsp;')
118
112
 
119
113
  # Non-breaking space before '%' and units (< 4 letters)
120
- input.gsub!(%r!(\s)+(\d+)(\s)+([[:alpha:]]|%)!, '\1\2&nbsp;\4\5')
114
+ input.gsub!(%r!\s+(\d+)\s+([[:alpha:]]|%)!, ' \1&nbsp;\2')
121
115
 
122
116
  # Thin non-breaking space before ;', '!', '?'
123
117
  input.gsub!(%r/ (;|\!|\?)([^\w!]|$)/, '&#8239;\1\2')
@@ -129,7 +123,7 @@ module Jekyll
129
123
  input.gsub!(%r!(\d+)\s*($|€)!, '\1&nbsp;\2')
130
124
 
131
125
  # nbsp after middle dash (dialogs)
132
- input.gsub!(%r!(—|&mdash;)(\s)!, '\1&nbsp;')
126
+ input.gsub!(%r!(—|&mdash;)\s!, '\1&nbsp;')
133
127
  end
134
128
 
135
129
  def fix_microtypo_us(input)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-microtypo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boris Schapira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-04-28 00:00:00.000000000 Z
11
+ date: 2026-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll