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 +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +4 -0
- data/bin/conductor +12 -0
- data/lib/conductor/condition.rb +28 -0
- data/lib/conductor/config.rb +4 -0
- data/lib/conductor/env.rb +1 -1
- data/lib/conductor/filter.rb +5 -2
- data/lib/conductor/version.rb +1 -1
- data/src/_README.md +4 -0
- data/test.sh +3 -0
- 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: 4960753920594bf8bc9a5abf999c6a40b9d0d2b88c2aadcb6b3c05db659af3bd
|
4
|
+
data.tar.gz: efb3cb83e50415a108d68e58468469b8b78132ad231825fff7f6fb3c2918d364
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff89946ef72b83902d598685e1c455384fba1e453674672d94c116a4598a29c19d65a2d0e51b1fc6f898d2c14799417f8bb3171b2a6d00d2d13e32b80e76cf3d
|
7
|
+
data.tar.gz: 8dd2b41b6750edd993e05c19c95b1fd98b9c4b969a6bedef6c8e56a43b98d06a6cce06eacf6cabd37887c3791562b9bdd1a440b9d138f72f48a2521dc55411a9
|
data/CHANGELOG.md
CHANGED
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
|
data/lib/conductor/condition.rb
CHANGED
@@ -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
|
data/lib/conductor/config.rb
CHANGED
@@ -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
data/lib/conductor/filter.rb
CHANGED
@@ -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
|
data/lib/conductor/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2024-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|