marked-conductor 1.0.32 → 1.0.35
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/CHANGELOG.md +26 -0
- data/Gemfile.lock +1 -1
- data/bin/conductor +23 -59
- 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 +36 -0
- data/lib/conductor/version.rb +1 -1
- data/lib/conductor/yui_compressor.rb +2 -2
- metadata +3 -3
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,29 @@
|
|
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
|
+
|
19
|
+
### 1.0.33
|
20
|
+
|
21
|
+
2024-08-22 06:35
|
22
|
+
|
23
|
+
#### IMPROVED
|
24
|
+
|
25
|
+
- Clean up string encoding in filters
|
26
|
+
|
1
27
|
### 1.0.32
|
2
28
|
|
3
29
|
2024-07-31 11:12
|
data/Gemfile.lock
CHANGED
data/bin/conductor
CHANGED
@@ -1,65 +1,29 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
1
|
+
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
Process.exit 0
|
24
|
-
end
|
25
|
-
|
26
|
-
opts.on("-h", "--help", "Display this screen") do
|
27
|
-
puts opts
|
28
|
-
exit
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'conductor' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
29
23
|
end
|
30
24
|
end
|
31
25
|
|
32
|
-
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
33
28
|
|
34
|
-
|
35
|
-
config.config_file = options[:config_file] if options[:config_file]
|
36
|
-
res = config.configure
|
37
|
-
|
38
|
-
Process.exit 0 unless res
|
39
|
-
|
40
|
-
Conductor.stdin
|
41
|
-
Conductor.original_input = Conductor.stdin
|
42
|
-
|
43
|
-
tracks = config.tracks
|
44
|
-
res, condition = Conductor.conduct(tracks)
|
45
|
-
|
46
|
-
##
|
47
|
-
## Clean up conditions for output
|
48
|
-
##
|
49
|
-
## @param condition The condition
|
50
|
-
##
|
51
|
-
def clean_condition(condition)
|
52
|
-
condition.join("").sub(/ *(->|,) *$/, "")
|
53
|
-
end
|
54
|
-
|
55
|
-
if res.nil?
|
56
|
-
warn "No conditions satisfied"
|
57
|
-
# puts Conductor::Env
|
58
|
-
puts "NOCUSTOM"
|
59
|
-
elsif res == Conductor.original_input
|
60
|
-
warn "No change in output"
|
61
|
-
puts "NOCUSTOM"
|
62
|
-
else
|
63
|
-
warn "Met condition: #{clean_condition(condition)}"
|
64
|
-
puts res
|
65
|
-
end
|
29
|
+
load Gem.bin_path("marked-conductor", "conductor")
|
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 = split(/\n/)
|
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 = split(/\n/)
|
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 = split(/\n/)
|
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 = split(/\n/)
|
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
|
-
split(/\n/).each_with_index do |line, idx|
|
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
|
-
split(/\n/).each_with_index do |line, idx|
|
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 = split(/\n/)
|
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 = split(/\n/)
|
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
|
-
split(/\n/).insert(h1, out).join("\n")
|
297
|
+
utf8.split(/\n/).insert(h1, out).join("\n")
|
298
298
|
when :h2
|
299
299
|
h2 = first_h2.nil? ? 0 : first_h2 + 1
|
300
|
-
split(/\n/).insert(h2, out).join("\n")
|
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
|
-
split(/\n/).each do |line|
|
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
|
-
split(/\n/).each do |line|
|
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
|
-
split(/\n/).insert(meta_insert_point, "\n\n").join("\n")
|
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 = split(/\n/)
|
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 = split(/\n/)
|
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 = split(/\n/)
|
509
|
+
lines = utf8.split(/\n/)
|
510
510
|
lines[meta_insert_point..].join("\n")
|
511
511
|
when :pandoc
|
512
|
-
lines = split(/\n/)
|
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
@@ -199,4 +199,40 @@ class ::String
|
|
199
199
|
def to_pattern
|
200
200
|
gsub(/\$(\d+)/, '\\\\\1').gsub(/(^["']|["']$)/, "")
|
201
201
|
end
|
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
|
+
|
221
|
+
##
|
222
|
+
## Get a clean UTF-8 string by forcing an ISO encoding and then re-encoding
|
223
|
+
##
|
224
|
+
## @return [String] UTF-8 string
|
225
|
+
##
|
226
|
+
def clean_encode
|
227
|
+
force_encoding("ISO-8859-1").encode("utf-8", replace: nil)
|
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
|
202
238
|
end
|
data/lib/conductor/version.rb
CHANGED
@@ -137,7 +137,7 @@ module YuiCompressor
|
|
137
137
|
##
|
138
138
|
## @return [String] css text with strings replaced
|
139
139
|
def process_comments_and_strings(css_text)
|
140
|
-
css = css_text.dup.
|
140
|
+
css = css_text.dup.clean_encode
|
141
141
|
|
142
142
|
start_index = 0
|
143
143
|
token = ""
|
@@ -155,7 +155,7 @@ module YuiCompressor
|
|
155
155
|
end
|
156
156
|
|
157
157
|
# preserve strings so their content doesn't get accidentally minified
|
158
|
-
css.gsub
|
158
|
+
css = css.gsub(/("([^\\"]|\\.|\\)*")|('([^\\']|\\.|\\)*')/) do |match|
|
159
159
|
quote = match[0, 1]
|
160
160
|
string = match.slice(1..-2)
|
161
161
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|
@@ -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)
|