marked-conductor 1.0.28 → 1.0.30

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: 333d82d6ed153da7c528506348ac3faff3852fef0614f0009bbcc0a963907a7f
4
- data.tar.gz: c24154363d7035cc4bcd1539abe117276f1955231fa0f7af27f49678164cf1db
3
+ metadata.gz: 4960753920594bf8bc9a5abf999c6a40b9d0d2b88c2aadcb6b3c05db659af3bd
4
+ data.tar.gz: efb3cb83e50415a108d68e58468469b8b78132ad231825fff7f6fb3c2918d364
5
5
  SHA512:
6
- metadata.gz: 323227fde6789d933d412afe287a9784c18ac2610e2d50e5050c14840b8045ce9c2b380fe714aa658c009eaa7dd038b6a6d88f0f648719f4dcd5f0958a862ef2
7
- data.tar.gz: ebdef901d6a9407adb9cfeb7412f0a21ac01eeeb89f38593556269594e58d32737cf426849d74a9f485e9d865646bbafa16a6b5c25430ed4f98391139d5265e7
6
+ metadata.gz: ff89946ef72b83902d598685e1c455384fba1e453674672d94c116a4598a29c19d65a2d0e51b1fc6f898d2c14799417f8bb3171b2a6d00d2d13e32b80e76cf3d
7
+ data.tar.gz: 8dd2b41b6750edd993e05c19c95b1fd98b9c4b969a6bedef6c8e56a43b98d06a6cce06eacf6cabd37887c3791562b9bdd1a440b9d138f72f48a2521dc55411a9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ### 1.0.30
2
+
3
+ 2024-07-29 11:47
4
+
5
+ ### 1.0.29
6
+
7
+ 2024-07-28 09:57
8
+
9
+ #### NEW
10
+
11
+ - Increase/decreaseHeaders(count) filter
12
+
1
13
  ### 1.0.28
2
14
 
3
15
  2024-07-27 14:54
data/README.md CHANGED
@@ -107,6 +107,8 @@ Available conditions are:
107
107
  - `includes` are files included in the document with special syntax (Marked, IA Writer, etc.)
108
108
  - `includes contain file` or `includes not contains file` will test all included files for filename matches
109
109
  - `includes contain path` or `includes not contains path` will test all included files for fragment matches anywhere in the path
110
+ - `env:KEY matches VALUE` will test for matching values in a environment key. All string matching operators are available, and `env[KEY]` syntax will also work.
111
+ - `env contains KEY` tests just for the existence of an environment variable key (can include variables set by Marked).
110
112
  - The following keywords act as a catchall and can be used as the last track in the config to act on any documents that aren't matched by preceding rules:
111
113
  - `any`
112
114
  - `else`
@@ -167,6 +169,8 @@ The action can be `script`, `command`, or `filter`.
167
169
  | `insertCSS(path)` | insert custom CSS into document |
168
170
  | `autoLink()` | Turn bare URLs into \<self-linked\> urls |
169
171
  | `fixHeaders()` | Reorganize headline levels to semantic order |
172
+ | `increaseHeaders(count) | Increase header levels by count (default 1) |
173
+ | `decreaseHeaders(count) | Decrease header levels by count (default 1) |
170
174
 
171
175
  For `replace` and `replaceAll`: If *search* is surrounded with forward slashes followed by optional flags (*i* for case-insensitive, *m* to make dot match newlines), e.g. `/contribut(ing)?/i`, it will be interpreted as a regular expression. The *replace* value can include numeric capture groups, e.g. `Follow$2`.
172
176
 
data/bin/conductor CHANGED
@@ -4,9 +4,20 @@
4
4
  require_relative "../lib/conductor"
5
5
  require "optparse"
6
6
 
7
+ options = {
8
+ config_file: nil
9
+ }
10
+
7
11
  optparse = OptionParser.new do |opts|
8
12
  opts.banner = "Called from Marked 2 as a Custom Pre/Processor"
9
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
+
10
21
  opts.on("-v", "--version", "Show version number") do
11
22
  puts "conductor v#{Conductor::VERSION}"
12
23
  Process.exit 0
@@ -21,6 +32,7 @@ end
21
32
  optparse.parse!
22
33
 
23
34
  config = Conductor::Config.new
35
+ config.config_file = options[:config_file] if options[:config_file]
24
36
  res = config.configure
25
37
 
26
38
  Process.exit 0 unless res
@@ -184,6 +184,11 @@ module Conductor
184
184
 
185
185
  val2 = val2.to_s.dup.force_encoding("utf-8")
186
186
 
187
+ if val2.bool?
188
+ res = val2.to_bool == val1.to_bool
189
+ return operator === :not_equal ? !res : res
190
+ end
191
+
187
192
  if val1.date?
188
193
  if val2.time?
189
194
  date1 = val1.to_date
@@ -276,6 +281,26 @@ module Conductor
276
281
  operator == :not_equal ? !res : res
277
282
  end
278
283
 
284
+ ##
285
+ ## Test for environment variable
286
+ ##
287
+ ## @param value [String] The value (test for existence of key if
288
+ ## nil)
289
+ ## @param key [String] The key
290
+ ## @param operator [Symbol] The operator
291
+ ##
292
+ ## @return [Boolean] test result
293
+ ##
294
+ def test_env(value, key, operator)
295
+ env = Env.env.merge(ENV)
296
+ if key.nil?
297
+ res = !env[value].nil?
298
+ return operator == :not_contains ? !res : res
299
+ end
300
+
301
+ return test_string(env[key], value, operator)
302
+ end
303
+
279
304
  ##
280
305
  ## Test for presence of yaml, optionall for
281
306
  ## a key, optionally for a key's value
@@ -391,6 +416,9 @@ module Conductor
391
416
  end
392
417
 
393
418
  case type
419
+ when /^env(?:ironment)?(?:[:\[\()](.*?)[\]\)]?)?$/i
420
+ key = Regexp.last_match(1) || nil
421
+ test_env(value, key, operator)
394
422
  when /^include/i
395
423
  test_includes(@env[:includes], value, operator) ? true : false
396
424
  when /^ext/i
@@ -41,8 +41,12 @@ module Conductor
41
41
  config_file ||= @config_file
42
42
  config_dir = File.dirname(config_file)
43
43
  scripts_dir = File.dirname(File.join(config_dir, "scripts"))
44
+ styles_dir = File.dirname(File.join(config_dir, "css"))
45
+ js_dir = File.dirname(File.join(config_dir, "js"))
44
46
  FileUtils.mkdir_p(config_dir) unless File.directory?(config_dir)
45
47
  FileUtils.mkdir_p(scripts_dir) unless File.directory?(scripts_dir)
48
+ FileUtils.mkdir_p(styles_dir) unless File.directory?(styles_dir)
49
+ FileUtils.mkdir_p(js_dir) unless File.directory?(js_dir)
46
50
  unless File.exist?(config_file)
47
51
  File.open(config_file, "w") { |f| f.puts sample_config }
48
52
  puts "Sample config created at #{config_file}"
data/lib/conductor/env.rb CHANGED
@@ -7,7 +7,7 @@ module Conductor
7
7
  ## Define @env using Marked environment variables
8
8
  ##
9
9
  def self.env
10
- if ENV["CONDUCTOR_TEST"] == "true"
10
+ if ENV["CONDUCTOR_TEST"].to_bool
11
11
  load_test_env
12
12
  else
13
13
  @env ||= {
@@ -135,7 +135,7 @@ class ::String
135
135
  ## @param amt [Integer] The amount to decrease
136
136
  ##
137
137
  def decrease_headers(amt = 1)
138
- gsub(/^(\#{1,6})(?!=#)/) do
138
+ normalize_headers.gsub(/^(\#{1,6})(?!=#)/) do
139
139
  m = Regexp.last_match
140
140
  level = m[1].size
141
141
  level -= amt
@@ -152,7 +152,7 @@ class ::String
152
152
  ## @return [String] content with headers increased
153
153
  ##
154
154
  def increase_headers(amt = 1)
155
- gsub(/^#/, "#{"#" * amt}#").gsub(/^\#{7,}/, "######")
155
+ normalize_headers.gsub(/^#/, "#{"#" * amt}#").gsub(/^\#{7,}/, "######")
156
156
  end
157
157
 
158
158
  ##
@@ -764,6 +764,9 @@ module Conductor
764
764
  content.autolink
765
765
  when /fix(head(lines|ers)|hierarchy)/
766
766
  content.fix_hierarchy
767
+ when /(increase|decrease)headers/
768
+ count = @params ? @params[0].to_i : 1
769
+ @filter =~ /^inc/ ? content.increase_headers(count) : content.decrease_headers(count)
767
770
  else
768
771
  content
769
772
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Conductor
4
- VERSION = "1.0.28"
4
+ VERSION = '1.0.30'
5
5
  end
data/src/_README.md CHANGED
@@ -107,6 +107,8 @@ Available conditions are:
107
107
  - `includes` are files included in the document with special syntax (Marked, IA Writer, etc.)
108
108
  - `includes contain file` or `includes not contains file` will test all included files for filename matches
109
109
  - `includes contain path` or `includes not contains path` will test all included files for fragment matches anywhere in the path
110
+ - `env:KEY matches VALUE` will test for matching values in a environment key. All string matching operators are available, and `env[KEY]` syntax will also work.
111
+ - `env contains KEY` tests just for the existence of an environment variable key (can include variables set by Marked).
110
112
  - The following keywords act as a catchall and can be used as the last track in the config to act on any documents that aren't matched by preceding rules:
111
113
  - `any`
112
114
  - `else`
@@ -167,6 +169,8 @@ The action can be `script`, `command`, or `filter`.
167
169
  | `insertCSS(path)` | insert custom CSS into document |
168
170
  | `autoLink()` | Turn bare URLs into \<self-linked\> urls |
169
171
  | `fixHeaders()` | Reorganize headline levels to semantic order |
172
+ | `increaseHeaders(count) | Increase header levels by count (default 1) |
173
+ | `decreaseHeaders(count) | Decrease header levels by count (default 1) |
170
174
 
171
175
  For `replace` and `replaceAll`: If *search* is surrounded with forward slashes followed by optional flags (*i* for case-insensitive, *m* to make dot match newlines), e.g. `/contribut(ing)?/i`, it will be interpreted as a regular expression. The *replace* value can include numeric capture groups, e.g. `Follow$2`.
172
176
 
data/test.sh CHANGED
@@ -23,6 +23,7 @@ fi
23
23
 
24
24
  PHASE="PREPROCESS"
25
25
  STD="BOTH"
26
+ CONFIG=""
26
27
 
27
28
  while getopts "h?p:o:d" opt; do
28
29
  case "$opt" in
@@ -32,6 +33,8 @@ while getopts "h?p:o:d" opt; do
32
33
  ;;
33
34
  p) PHASE=$OPTARG
34
35
  ;;
36
+ c) CMD="$CMD -c \"$OPTARG\""
37
+ ;;
35
38
  o) STD=$OPTARG
36
39
  ;;
37
40
  d)
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.28
4
+ version: 1.0.30
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-27 00:00:00.000000000 Z
11
+ date: 2024-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print