marked-conductor 1.0.32 → 1.0.33

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7db6a6044dabe2b2487ae53119d385822269ef5a188727e37976310e5b47e54e
4
- data.tar.gz: 6d054087984dcd36038705e7ae7fd4b9fc94cc2194899a9e3eb01903ee44f93f
3
+ metadata.gz: 3a27e45e5fc64335fa1278d3fd33aff4fd691bbae6edac649689f42d9d8425a2
4
+ data.tar.gz: e5b70aaa3cf17036e20caa856e4629aa55023ba3dae53be8dbdff3fcd2bef955
5
5
  SHA512:
6
- metadata.gz: acd13153ea7b8401fd2e602f3935178eceee61359d8a32e1f228f1adbb4459b76330a4d98440511dca85cd92ae7ff731725102a39e56cd68327f9c756904cc62
7
- data.tar.gz: 60c139677c180c043c5aaeddf9cfe6df338e9f62e6eb8ef0384c15accc1f666763259b3f94abd5374b86a60fa486f67b821ddd484edc1112e78fa3f9c05a553e
6
+ metadata.gz: 31c5b37a272d7f2caf66016d5696308a7c1a0a666ed80e5900274c26ab0ba5fc485ad4f09f3380459255cec68e07ac86124fb9ae2e61662a018297a9edbad0c0
7
+ data.tar.gz: e87f4cd7548948a33098717f657dfcab0ec14a7411615754b7dc0af00a511f0155e9c404d2a7bd3a892296300120d73bae513b2b503ebafd41b35c1aa5d1bd74
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ### 1.0.33
2
+
3
+ 2024-08-22 06:35
4
+
5
+ #### IMPROVED
6
+
7
+ - Clean up string encoding in filters
8
+
1
9
  ### 1.0.32
2
10
 
3
11
  2024-07-31 11:12
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- marked-conductor (1.0.28)
4
+ marked-conductor (1.0.33)
5
5
  chronic (~> 0.10.2)
6
6
  tty-which (~> 0.5.0)
7
7
 
data/bin/conductor CHANGED
@@ -1,65 +1,29 @@
1
- #!/usr/bin/env ruby -W1
1
+ #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require_relative "../lib/conductor"
5
- require "optparse"
6
-
7
- options = {
8
- config_file: nil
9
- }
10
-
11
- optparse = OptionParser.new do |opts|
12
- opts.banner = "Called from Marked 2 as a Custom Pre/Processor"
13
-
14
- opts.on("-c", "--config", "Specify alternate config file") do |file|
15
- config = File.expand_path(file)
16
- raise "Config file not found" unless File.exist?(config)
17
-
18
- options[:config_file] = file
19
- end
20
-
21
- opts.on("-v", "--version", "Show version number") do
22
- puts "conductor v#{Conductor::VERSION}"
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
- optparse.parse!
26
+ require "rubygems"
27
+ require "bundler/setup"
33
28
 
34
- config = Conductor::Config.new
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")
@@ -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 = clean_encode.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 = clean_encode.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 = clean_encode.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 = clean_encode.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
+ clean_encode.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
+ clean_encode.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 = clean_encode.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.force_encoding('utf-8'))
241
+ content = yui.compress(content.clean_encode)
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 = clean_encode.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
+ clean_encode.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
+ clean_encode.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
+ clean_encode.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
+ clean_encode.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.clean_encode
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
+ clean_encode.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 = clean_encode.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 = clean_encode.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 = clean_encode.split(/\n/)
510
510
  lines[meta_insert_point..].join("\n")
511
511
  when :pandoc
512
- lines = split(/\n/)
512
+ lines = clean_encode.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, '')
@@ -199,4 +199,13 @@ class ::String
199
199
  def to_pattern
200
200
  gsub(/\$(\d+)/, '\\\\\1').gsub(/(^["']|["']$)/, "")
201
201
  end
202
+
203
+ ##
204
+ ## Get a clean UTF-8 string by forcing an ISO encoding and then re-encoding
205
+ ##
206
+ ## @return [String] UTF-8 string
207
+ ##
208
+ def clean_encode
209
+ force_encoding("ISO-8859-1").encode("utf-8", replace: nil)
210
+ end
202
211
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Conductor
4
- VERSION = '1.0.32'
4
+ VERSION = '1.0.33'
5
5
  end
@@ -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.force_encoding("ISO-8859-1").encode("utf-8", replace: nil)
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!(/("([^\\"]|\\.|\\)*")|('([^\\']|\\.|\\)*')/) do |match|
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.32
4
+ version: 1.0.33
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-07-31 00:00:00.000000000 Z
11
+ date: 2024-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print