marked-conductor 1.0.33 → 1.0.35
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/lib/conductor/command.rb +1 -1
- data/lib/conductor/filter.rb +20 -20
- data/lib/conductor/script.rb +1 -1
- data/lib/conductor/string.rb +27 -0
- data/lib/conductor/version.rb +1 -1
- 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: 31042fe7c5635982e15c551493cf380e0d3aabae92051871144172e5890e2328
|
4
|
+
data.tar.gz: 8ea8a81fb13a5342332e5c3ac779fea2dced77b34318f1e43210d1d5c388dd54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8bea2c1c42bf3bf95819b1371368ad73a810860725fc2e86ccf2803c11de5de826740cd32723c5b67ccf2423e7bebb15442888e163c1fe5188924988c9b15f3
|
7
|
+
data.tar.gz: b8a3881c29831dae7b37b7eeafb31acf5c34ccaf79c99e9b2bed2252a71f82575417dfe8941ba9c2d6629fad6c10511dacff6d40dd05a5022c91804720568c96
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
### 1.0.35
|
2
|
+
|
3
|
+
2024-08-22 10:14
|
4
|
+
|
5
|
+
#### IMPROVED
|
6
|
+
|
7
|
+
- Code cleanup
|
8
|
+
- Cleaner UTF-8 string encoding
|
9
|
+
|
10
|
+
### 1.0.34
|
11
|
+
|
12
|
+
2024-08-22 10:13
|
13
|
+
|
14
|
+
#### IMPROVED
|
15
|
+
|
16
|
+
- Code cleanup
|
17
|
+
- Cleaner UTF-8 string encoding
|
18
|
+
|
1
19
|
### 1.0.33
|
2
20
|
|
3
21
|
2024-08-22 06:35
|
data/lib/conductor/command.rb
CHANGED
data/lib/conductor/filter.rb
CHANGED
@@ -42,7 +42,7 @@ class ::String
|
|
42
42
|
## @return [Symbol] metadata type
|
43
43
|
##
|
44
44
|
def meta_type
|
45
|
-
lines =
|
45
|
+
lines = utf8.split(/\n/)
|
46
46
|
case lines[0]
|
47
47
|
when /^--- *$/
|
48
48
|
:yaml
|
@@ -65,7 +65,7 @@ class ::String
|
|
65
65
|
|
66
66
|
case meta_type
|
67
67
|
when :yaml
|
68
|
-
lines =
|
68
|
+
lines = utf8.split(/\n/)
|
69
69
|
lines.shift
|
70
70
|
lines.each_with_index do |line, idx|
|
71
71
|
next unless line =~ /^(\.\.\.|---) *$/
|
@@ -74,7 +74,7 @@ class ::String
|
|
74
74
|
break
|
75
75
|
end
|
76
76
|
when :mmd
|
77
|
-
lines =
|
77
|
+
lines = utf8.split(/\n/)
|
78
78
|
lines.each_with_index do |line, idx|
|
79
79
|
next if line =~ /^ *[ \w]+: +\S+/
|
80
80
|
|
@@ -82,7 +82,7 @@ class ::String
|
|
82
82
|
break
|
83
83
|
end
|
84
84
|
when :pandoc
|
85
|
-
lines =
|
85
|
+
lines = utf8.split(/\n/)
|
86
86
|
lines.each_with_index do |line, idx|
|
87
87
|
next if line =~ /^% +\S/
|
88
88
|
|
@@ -101,7 +101,7 @@ class ::String
|
|
101
101
|
##
|
102
102
|
def first_h1
|
103
103
|
first = nil
|
104
|
-
|
104
|
+
utf8.split(/\n/).each_with_index do |line, idx|
|
105
105
|
if line =~ /^(# *[^#]|={2,} *$)/
|
106
106
|
first = idx
|
107
107
|
break
|
@@ -118,7 +118,7 @@ class ::String
|
|
118
118
|
def first_h2
|
119
119
|
first = nil
|
120
120
|
meta_end = meta_insert_point
|
121
|
-
|
121
|
+
utf8.split(/\n/).each_with_index do |line, idx|
|
122
122
|
next if idx <= meta_end
|
123
123
|
|
124
124
|
if line =~ /^(## *[^#]|-{2,} *$)/
|
@@ -177,7 +177,7 @@ class ::String
|
|
177
177
|
## @return [String] content with TOC tag added
|
178
178
|
##
|
179
179
|
def insert_toc(max = nil, after = :h1)
|
180
|
-
lines =
|
180
|
+
lines = utf8.split(/\n/)
|
181
181
|
max = max.to_i&.positive? ? " max#{max}" : ""
|
182
182
|
line = case after.to_sym
|
183
183
|
when :h2
|
@@ -238,7 +238,7 @@ class ::String
|
|
238
238
|
if File.exist?(path)
|
239
239
|
content = IO.read(path)
|
240
240
|
yui = YuiCompressor::Yui.new
|
241
|
-
content = yui.compress(content.
|
241
|
+
content = yui.compress(content.utf8)
|
242
242
|
inject_after_meta(content.wrap_style)
|
243
243
|
else
|
244
244
|
warn "File not found (#{path})"
|
@@ -254,7 +254,7 @@ class ::String
|
|
254
254
|
## @return [String] string with content injected
|
255
255
|
##
|
256
256
|
def inject_after_meta(content)
|
257
|
-
lines =
|
257
|
+
lines = utf8.split(/\n/)
|
258
258
|
insert_point = meta_insert_point
|
259
259
|
insert_at = insert_point.positive? ? insert_point + 1 : 0
|
260
260
|
lines.insert(insert_at, "#{content}\n\n")
|
@@ -294,10 +294,10 @@ class ::String
|
|
294
294
|
inject_after_meta(out)
|
295
295
|
when :h1
|
296
296
|
h1 = first_h1.nil? ? 0 : first_h1 + 1
|
297
|
-
|
297
|
+
utf8.split(/\n/).insert(h1, out).join("\n")
|
298
298
|
when :h2
|
299
299
|
h2 = first_h2.nil? ? 0 : first_h2 + 1
|
300
|
-
|
300
|
+
utf8.split(/\n/).insert(h2, out).join("\n")
|
301
301
|
else
|
302
302
|
"#{self}\n#{out}"
|
303
303
|
end
|
@@ -393,7 +393,7 @@ class ::String
|
|
393
393
|
yaml = YAML.load(m[0])
|
394
394
|
title = yaml["title"]
|
395
395
|
when :mmd
|
396
|
-
|
396
|
+
utf8.split(/\n/).each do |line|
|
397
397
|
if line =~ /^ *title: *(\S.*?)$/i
|
398
398
|
title = Regexp.last_match(1)
|
399
399
|
break
|
@@ -401,7 +401,7 @@ class ::String
|
|
401
401
|
end
|
402
402
|
when :pandoc
|
403
403
|
title = nil
|
404
|
-
|
404
|
+
utf8.split(/\n/).each do |line|
|
405
405
|
if line =~ /^% +(.*?)$/
|
406
406
|
title = Regexp.last_match(1)
|
407
407
|
break
|
@@ -419,7 +419,7 @@ class ::String
|
|
419
419
|
end
|
420
420
|
|
421
421
|
def insert_title(shift: 0)
|
422
|
-
content = dup.
|
422
|
+
content = dup.utf8
|
423
423
|
title = read_title
|
424
424
|
content.increase_headers!(shift) if shift.positive?
|
425
425
|
lines = content.split(/\n/)
|
@@ -441,7 +441,7 @@ class ::String
|
|
441
441
|
end
|
442
442
|
|
443
443
|
def ensure_mmd_meta_newline
|
444
|
-
|
444
|
+
utf8.split(/\n/).insert(meta_insert_point, "\n\n").join("\n")
|
445
445
|
end
|
446
446
|
|
447
447
|
def add_yaml(key, value)
|
@@ -466,7 +466,7 @@ class ::String
|
|
466
466
|
if match(/(\A|\n) *#{key}: *\S+/i)
|
467
467
|
sub(/^ *#{key}:.*?\n/i, "#{key}: #{value}\n")
|
468
468
|
else
|
469
|
-
lines =
|
469
|
+
lines = utf8.split(/\n/)
|
470
470
|
lines.insert(meta_insert_point, "#{key}: #{value}")
|
471
471
|
"#{lines.join("\n")}\n"
|
472
472
|
end
|
@@ -484,7 +484,7 @@ class ::String
|
|
484
484
|
if comment?(key)
|
485
485
|
sub(/ *#{key}: .*?$/, "#{key}: #{value}")
|
486
486
|
else
|
487
|
-
lines =
|
487
|
+
lines = utf8.split(/\n/)
|
488
488
|
lines.insert(meta_insert_point + 1, "\n<!--\n#{key}: #{value}\n-->")
|
489
489
|
lines.join("\n")
|
490
490
|
end
|
@@ -506,10 +506,10 @@ class ::String
|
|
506
506
|
when :yaml
|
507
507
|
sub(/^---.*?(---|\.\.\.)/m, "")
|
508
508
|
when :mmd
|
509
|
-
lines =
|
509
|
+
lines = utf8.split(/\n/)
|
510
510
|
lines[meta_insert_point..].join("\n")
|
511
511
|
when :pandoc
|
512
|
-
lines =
|
512
|
+
lines = utf8.split(/\n/)
|
513
513
|
lines[meta_insert_point..].join("\n")
|
514
514
|
else
|
515
515
|
gsub(/(\n|^)<!--\n[\w\d\s]+: ([\w\d\s]+)\n-->\n/m, '')
|
@@ -574,7 +574,7 @@ class ::String
|
|
574
574
|
##
|
575
575
|
def ensure_h1
|
576
576
|
headers = to_enum(:scan, /(\#{1,6})([^#].*?)$/m).map { Regexp.last_match }
|
577
|
-
return self
|
577
|
+
return self unless headers.select { |h| h[1].size == 1 }.empty?
|
578
578
|
|
579
579
|
lowest_header = headers.min_by { |h| h[1].size }
|
580
580
|
return self if lowest_header.nil?
|
data/lib/conductor/script.rb
CHANGED
data/lib/conductor/string.rb
CHANGED
@@ -200,6 +200,24 @@ class ::String
|
|
200
200
|
gsub(/\$(\d+)/, '\\\\\1').gsub(/(^["']|["']$)/, "")
|
201
201
|
end
|
202
202
|
|
203
|
+
##
|
204
|
+
## Discard invalid characters and output a UTF-8 String
|
205
|
+
##
|
206
|
+
## @return [String] UTF-8 encoded string
|
207
|
+
##
|
208
|
+
def utf8
|
209
|
+
encode('utf-16', invalid: :replace).encode('utf-8')
|
210
|
+
end
|
211
|
+
|
212
|
+
##
|
213
|
+
## Destructive version of #utf8
|
214
|
+
##
|
215
|
+
## @return [String] UTF-8 encoded string, in place
|
216
|
+
##
|
217
|
+
def utf8!
|
218
|
+
replace scrub
|
219
|
+
end
|
220
|
+
|
203
221
|
##
|
204
222
|
## Get a clean UTF-8 string by forcing an ISO encoding and then re-encoding
|
205
223
|
##
|
@@ -208,4 +226,13 @@ class ::String
|
|
208
226
|
def clean_encode
|
209
227
|
force_encoding("ISO-8859-1").encode("utf-8", replace: nil)
|
210
228
|
end
|
229
|
+
|
230
|
+
##
|
231
|
+
## Destructive version of #clean_encode
|
232
|
+
##
|
233
|
+
## @return [String] UTF-8 string, in place
|
234
|
+
##
|
235
|
+
def clean_encode!
|
236
|
+
replace clean_encode
|
237
|
+
end
|
211
238
|
end
|
data/lib/conductor/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marked-conductor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.35
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brett Terpstra
|
@@ -244,7 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
244
244
|
- !ruby/object:Gem::Version
|
245
245
|
version: '0'
|
246
246
|
requirements: []
|
247
|
-
rubygems_version: 3.2.
|
247
|
+
rubygems_version: 3.2.16
|
248
248
|
signing_key:
|
249
249
|
specification_version: 4
|
250
250
|
summary: A custom processor manager for Marked 2 (Mac)
|