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 +4 -4
- data/lib/jekyll/microtypo/version.rb +1 -1
- data/lib/jekyll/microtypo.rb +21 -27
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 35c42c3c8b2d0048b9d5e97c56bfc9263d9033fdcfcda6b68366a64b371ff70f
|
|
4
|
+
data.tar.gz: b9c4e0776f522e027cc9fb08f151dd16911cac8476729e67606597e9309ff459
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 45a45926a84463dc19a9c8eab9063db529dc1e98db8e79667cecdbd1b419313308419123bc21ffda313fc8a1d126d23fdcb1e67cf1cf89fe4b50739c28c77032
|
|
7
|
+
data.tar.gz: f630a39f40cf740bd12328b8c5a0da2abb6c646bbf3d9a662a6adc61271140b80a28fd03ff2c6ea686936fe812c7453b46180acbea68daeb56b608b011b9e234
|
data/lib/jekyll/microtypo.rb
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
81
|
-
if
|
|
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
|
|
112
|
-
input.gsub!(%r
|
|
113
|
-
input.gsub!(%r
|
|
114
|
-
input.gsub!(%r
|
|
105
|
+
input.gsub!(%r!\s+\?\!([^\w]|$)!, ' ⁈\1')
|
|
106
|
+
input.gsub!(%r!\s+\!\?([^\w]|$)!, ' ⁉\1')
|
|
107
|
+
input.gsub!(%r!\s+\!\!\!([^\w]|$)!, ' ‼\1')
|
|
108
|
+
input.gsub!(%r!\s+\!\!([^\w]|$)!, ' ‼\1')
|
|
115
109
|
|
|
116
110
|
# Times
|
|
117
|
-
input.gsub!(%r
|
|
111
|
+
input.gsub!(%r!\s+(\d+)\s*x\s*(?=\d)!, ' \1 × ')
|
|
118
112
|
|
|
119
113
|
# Non-breaking space before '%' and units (< 4 letters)
|
|
120
|
-
input.gsub!(%r
|
|
114
|
+
input.gsub!(%r!\s+(\d+)\s+([[:alpha:]]|%)!, ' \1 \2')
|
|
121
115
|
|
|
122
116
|
# Thin non-breaking space before ;', '!', '?'
|
|
123
117
|
input.gsub!(%r/ (;|\!|\?)([^\w!]|$)/, ' \1\2')
|
|
@@ -129,7 +123,7 @@ module Jekyll
|
|
|
129
123
|
input.gsub!(%r!(\d+)\s*($|€)!, '\1 \2')
|
|
130
124
|
|
|
131
125
|
# nbsp after middle dash (dialogs)
|
|
132
|
-
input.gsub!(%r!(—|—)
|
|
126
|
+
input.gsub!(%r!(—|—)\s!, '\1 ')
|
|
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.
|
|
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-
|
|
11
|
+
date: 2026-05-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: jekyll
|