marked-conductor 1.0.12 → 1.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +4 -2
- data/bin/conductor +8 -0
- data/html/Conductor.html +10 -2
- data/html/Object.html +1 -1
- data/html/String.html +466 -0
- data/html/created.rid +5 -4
- data/html/index.html +1 -0
- data/html/js/search_index.js +1 -1
- data/html/js/search_index.js.gz +0 -0
- data/html/table_of_contents.html +105 -12
- data/lib/conductor/filter.rb +196 -0
- data/lib/conductor/version.rb +1 -1
- data/lib/conductor.rb +1 -0
- data/src/_README.md +4 -2
- data/test.sh +83 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55f1d24332aec42ce9808bd2cf18ba75cd69c89828930a97239bcfb9d9b9d629
|
4
|
+
data.tar.gz: 4995332673049ee5235307a2b938e0e3e71a8085748597789484efde02a4ec56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89fa260f9b5efc1edcc7cb18ebd50ea5b3ab63669639dce30e0b7d43bcf20434f3c693316f77deea811475dc8a6d2387dc1a45e0c04014fb30125a97d774524e
|
7
|
+
data.tar.gz: 259f9e19257859cf0efeb6b69299dde021100ea27775c948b0c8bbf869f389e58d78307deb7498abfb68969542a3c5e5b32c068d9e05c7a9847fe6c06621b8fe
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
### 1.0.13
|
2
|
+
|
3
|
+
2024-05-24 13:12
|
4
|
+
|
5
|
+
#### NEW
|
6
|
+
|
7
|
+
- New type of command -- filter: filterName(parameters), allows things like setStyle(github) or replace_all(regex, pattern) instead of having to write scripts for simple things like this. Can be run in sequences.
|
8
|
+
|
1
9
|
### 1.0.12
|
2
10
|
|
3
11
|
2024-05-01 13:06
|
data/README.md
CHANGED
@@ -142,8 +142,8 @@ A script run by Conductor already knows it has the right type of file with the e
|
|
142
142
|
## Tips
|
143
143
|
|
144
144
|
- Config file must be valid YAML. Any value containing colons, brackets, or other special characters should be quoted, e.g. (`condition: "text contains my:text"`)
|
145
|
-
- You can see what condition matched in Marked by opening
|
146
|
-
- To run [a custom processor for Bear](https://brettterpstra.com/2023/10/08/marked-and-bear/), use the condition `"text contains <!-- source: bear.app -->"
|
145
|
+
- You can see what condition matched in Marked by opening **Help->Show Custom Processor Log** and checking the STDERR output.
|
146
|
+
- To run [a custom processor for Bear](https://brettterpstra.com/2023/10/08/marked-and-bear/), use the condition `"text contains <!-- source: bear.app -->"`. You might consider running a commonmark CLI with Bear to support more of its syntax.
|
147
147
|
- To run a custom processor for Obsidian, use the condition `tree contains .obsidian`
|
148
148
|
|
149
149
|
## Testing
|
@@ -154,6 +154,8 @@ In Marked's Custom Processor Log, you can see both the STDOUT output and the STD
|
|
154
154
|
|
155
155
|
### From the command line
|
156
156
|
|
157
|
+
> There's a script included in the repo called [test.sh](https://github.com/ttscoff/marked-conductor/blob/main/test.sh) that will take a file path as an argument and set all of the environment variables for testing. Run `test.sh -h` for usage instructions.
|
158
|
+
|
157
159
|
In order to test from the command line, you'll need certain environment variables set. This can be done by exporting the following variables with your own definitions, or by running conductor with all of the variables preceding the command, e.g. `$ MARKED_ORIGIN=/path/to/markdown_file.md [...] conductor`.
|
158
160
|
|
159
161
|
The following need to be defined. Some can be left as empty or to defaults, such as `MARKED_INCLUDES` and `MARKED_OUTLINE`, but all need to be set to something.
|
data/bin/conductor
CHANGED
@@ -25,6 +25,10 @@ module Conductor
|
|
25
25
|
command = Command.new(cmd[:command])
|
26
26
|
|
27
27
|
res = command.run
|
28
|
+
elsif cmd[:filter]
|
29
|
+
filter = Filter.new(cmd[:filter])
|
30
|
+
|
31
|
+
res = filter.process
|
28
32
|
end
|
29
33
|
|
30
34
|
Conductor.stdin = res unless res.nil?
|
@@ -37,6 +41,10 @@ module Conductor
|
|
37
41
|
command = Command.new(track[:command])
|
38
42
|
|
39
43
|
Conductor.stdin = command.run
|
44
|
+
elsif track[:filter]
|
45
|
+
filter = Filter.new(track[:filter])
|
46
|
+
|
47
|
+
Conductor.stdin = filter.process
|
40
48
|
end
|
41
49
|
|
42
50
|
Conductor.stdin
|
data/html/Conductor.html
CHANGED
@@ -154,7 +154,7 @@ sub-tracks.</pre>
|
|
154
154
|
<p>@return [Array] result, matched condition(s)</p>
|
155
155
|
|
156
156
|
<div class="method-source-code" id="conduct-source">
|
157
|
-
<pre><span class="ruby-comment"># File bin/conductor, line
|
157
|
+
<pre><span class="ruby-comment"># File bin/conductor, line 64</span>
|
158
158
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">conduct</span>(<span class="ruby-identifier">tracks</span>, <span class="ruby-identifier">res</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">condition</span> = <span class="ruby-keyword">nil</span>)
|
159
159
|
<span class="ruby-identifier">tracks</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">track</span><span class="ruby-operator">|</span>
|
160
160
|
<span class="ruby-identifier">cond</span> = <span class="ruby-constant">Condition</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">track</span>[<span class="ruby-value">:condition</span>])
|
@@ -221,6 +221,10 @@ sub-tracks.</pre>
|
|
221
221
|
<span class="ruby-identifier">command</span> = <span class="ruby-constant">Command</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">cmd</span>[<span class="ruby-value">:command</span>])
|
222
222
|
|
223
223
|
<span class="ruby-identifier">res</span> = <span class="ruby-identifier">command</span>.<span class="ruby-identifier">run</span>
|
224
|
+
<span class="ruby-keyword">elsif</span> <span class="ruby-identifier">cmd</span>[<span class="ruby-value">:filter</span>]
|
225
|
+
<span class="ruby-identifier">filter</span> = <span class="ruby-constant">Filter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">cmd</span>[<span class="ruby-value">:filter</span>])
|
226
|
+
|
227
|
+
<span class="ruby-identifier">res</span> = <span class="ruby-identifier">filter</span>.<span class="ruby-identifier">process</span>
|
224
228
|
<span class="ruby-keyword">end</span>
|
225
229
|
|
226
230
|
<span class="ruby-constant">Conductor</span>.<span class="ruby-identifier">stdin</span> = <span class="ruby-identifier">res</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">res</span>.<span class="ruby-identifier">nil?</span>
|
@@ -233,6 +237,10 @@ sub-tracks.</pre>
|
|
233
237
|
<span class="ruby-identifier">command</span> = <span class="ruby-constant">Command</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">track</span>[<span class="ruby-value">:command</span>])
|
234
238
|
|
235
239
|
<span class="ruby-constant">Conductor</span>.<span class="ruby-identifier">stdin</span> = <span class="ruby-identifier">command</span>.<span class="ruby-identifier">run</span>
|
240
|
+
<span class="ruby-keyword">elsif</span> <span class="ruby-identifier">track</span>[<span class="ruby-value">:filter</span>]
|
241
|
+
<span class="ruby-identifier">filter</span> = <span class="ruby-constant">Filter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">track</span>[<span class="ruby-value">:filter</span>])
|
242
|
+
|
243
|
+
<span class="ruby-constant">Conductor</span>.<span class="ruby-identifier">stdin</span> = <span class="ruby-identifier">filter</span>.<span class="ruby-identifier">process</span>
|
236
244
|
<span class="ruby-keyword">end</span>
|
237
245
|
|
238
246
|
<span class="ruby-constant">Conductor</span>.<span class="ruby-identifier">stdin</span>
|
@@ -256,7 +264,7 @@ sub-tracks.</pre>
|
|
256
264
|
|
257
265
|
|
258
266
|
<div class="method-source-code" id="stdin-source">
|
259
|
-
<pre><span class="ruby-comment"># File lib/conductor.rb, line
|
267
|
+
<pre><span class="ruby-comment"># File lib/conductor.rb, line 27</span>
|
260
268
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">stdin</span>
|
261
269
|
<span class="ruby-identifier">warn</span> <span class="ruby-string">"input on STDIN required"</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">$stdin</span>.<span class="ruby-identifier">stat</span>.<span class="ruby-identifier">size</span>.<span class="ruby-identifier">positive?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">$stdin</span>.<span class="ruby-identifier">fcntl</span>(<span class="ruby-constant">Fcntl</span><span class="ruby-operator">::</span><span class="ruby-constant">F_GETFL</span>, <span class="ruby-value">0</span>).<span class="ruby-identifier">zero?</span>
|
262
270
|
<span class="ruby-ivar">@stdin</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">$stdin</span>.<span class="ruby-identifier">read</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-string">"utf-8"</span>)
|
data/html/Object.html
CHANGED
@@ -114,7 +114,7 @@
|
|
114
114
|
<p>@param condition The condition</p>
|
115
115
|
|
116
116
|
<div class="method-source-code" id="clean_condition-source">
|
117
|
-
<pre><span class="ruby-comment"># File bin/conductor, line
|
117
|
+
<pre><span class="ruby-comment"># File bin/conductor, line 127</span>
|
118
118
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">clean_condition</span>(<span class="ruby-identifier">condition</span>)
|
119
119
|
<span class="ruby-identifier">condition</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">""</span>).<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/ *(->|,) *$/</span>, <span class="ruby-string">""</span>)
|
120
120
|
<span class="ruby-keyword">end</span></pre>
|