marked-conductor 1.0.14 → 1.0.16

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: 69c655b0c85492536b091259aeb5000c04c5830cc1296cb241ceeb507210bd7d
4
- data.tar.gz: 42ed08e2e792dc85945e4c3dbcb0facfbbad2eb1f51553d5999843d042a00703
3
+ metadata.gz: 6f209ada6b97abd9b51e73fef5c26ef265ebaab7ef534b949fa25ce537735133
4
+ data.tar.gz: 27ed686709dee1e38e6516170d47243177eded3070744e4110304ed4ce558399
5
5
  SHA512:
6
- metadata.gz: 003ec761e335649d21c3bdc209cca365ce6de2152678f896bf623e422f9e161f4d7466231b8915949cdff535874465de4b3ba773f6683780895897a8caf09f47
7
- data.tar.gz: 6bc9fd32c5a46fca3c7b11184b95dc62c31ade54b5cbd4802e2c3f3e4bef6cfe73c01631fe50a6761a3e804786f567ae897d387e304e265fec5b5689168b8039
6
+ metadata.gz: 8699203cb1a9a6338ebea63dc8fbf20ca212dd5e0278127d952fd1975c1cc60f89a38c3c7372a9b298b05be7548a72127291c91f8a6da3e186636ab1f7efdef1
7
+ data.tar.gz: 2806880345adbe1859d93ffbf6b6dd9b803b30458e4133468f5bf0f8ea0033a9a10891946ec5f259b67171817909ced4015fe1032d064037ba318132ba16fb96
data/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ### 1.0.16
2
+
3
+ 2024-06-28 12:40
4
+
5
+ #### NEW
6
+
7
+ - New insertCSS filter to inject a stylesheet
8
+ - YUI compression for injected CSS
9
+
10
+ ### 1.0.15
11
+
12
+ 2024-05-25 11:14
13
+
14
+ #### NEW
15
+
16
+ - New filter insertTOC(max, after) to insert a table of contents, optionally with max levels and after (start, *h1, or h2)
17
+ - New filter prepend/appendFile(path) to include a file (also pre/appendRaw and pre/appendCode)
18
+
1
19
  ### 1.0.14
2
20
 
3
21
  2024-05-25 06:41
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  # Marked Conductor
5
5
 
6
- A "train conductor" for [Marked 2](https://marked2app.com). Conductor can be set up as a Custom Preprocessor or Custom Processor for Marked, and can run different commands and scripts based on conditions in a YAML configuration file, allowing you to have multiple processors that run based on predicates.
6
+ A "train conductor" for [Marked 2](https://marked2app.com) (Mac only). Conductor can be set up as a Custom Preprocessor or Custom Processor for Marked, and can run different commands and scripts based on conditions in a YAML configuration file, allowing you to have multiple processors that run based on predicates.
7
7
 
8
8
  ## Installation
9
9
 
@@ -124,12 +124,16 @@ Conditions can be combined with AND or OR (must be uppercase) and simple parenth
124
124
 
125
125
  The action can be `script`, `command`, or `filter`.
126
126
 
127
+ #### Scripts
128
+
127
129
  **Scripts** are located in `~/.config/conductor/scripts/` and should be executable files that take input on STDIN (unless `$file` is specified in the `script` definition). If a script is defined starting with `~` or `/`, that will be interpreted as a full path to an alternate location.
128
130
 
129
131
  > Example:
130
132
  >
131
133
  > script: github_pre
132
134
 
135
+ #### Commands
136
+
133
137
  **Commands** are interpreted as shell commands. If a command exists in the `$PATH`, a full path will automatically be determined, so a command can be as simple as just `pandoc`. Add any arguments needed after the command.
134
138
 
135
139
  > Example:
@@ -139,21 +143,30 @@ The action can be `script`, `command`, or `filter`.
139
143
 
140
144
  > Using `$file` as an argument to a script or command will bypass processing of STDIN input, and instead use the value of $MARKED_PATH to read the contents of the specified file.
141
145
 
146
+ #### Filters
147
+
142
148
  **Filters** are simple actions that can be run on the content without having to write a separate script for it. Available filters are:
149
+
143
150
  | filter | description |
144
151
  | :---- | :---------- |
145
152
  | `setMeta(key, value)` | adds or updates a meta key, aware of YAML and MMD |
146
153
  | `stripMeta` | strips all metadata (YAML or MMD) from the content |
147
- | `stripMeta(key)` | removes a specific key (YAML or MMD) |
148
- | `setStyle(name)` | sets the Marked preview style to a preconfigured Style name
154
+ | `deleteMeta(key)` | removes a specific key (YAML or MMD) |
155
+ | `setStyle(name)` | sets the Marked preview style to a preconfigured Style name |
149
156
  | `replace(search, replace)` | performs a (single) search and replace on content |
150
157
  | `replaceAll(search, replace)` | global version of `replaceAll`) |
151
158
  | `insertTitle` | adds a title to the document, either from metadata or filename |
152
159
  | `insertScript(path[,path])` | injects javascript(s) |
160
+ | `insertTOC(max, after)` | insert TOC (max=max levels, after=start, \*h1, or h2) |
161
+ | `prepend/appendFile(path)` | insert a file as Markdown at beginning or end of content |
162
+ | `prepend/appendRaw(path)` | insert a file as raw HTML at beginning or end of content |
163
+ | `prepend/appendCode(path)` | insert a file as a code block at beginning or end of content |
164
+
165
+ 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`.
153
166
 
154
167
  For `insertScript`, if path is just a filename it will look for a match in `~/.config/conductor/javascript` or `~/.config/conductor/scripts` and turn that into an absolute path if the file is found.
155
168
 
156
- 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`.
169
+ For all of the prepend/append file filters, you can store files in `~/.config/conductor/files` and reference them with just a filename. Otherwise a full path will be assumed.
157
170
 
158
171
  > Example:
159
172
  >
@@ -176,7 +189,7 @@ A script run by Conductor already knows it has the right type of file with the e
176
189
  - 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"`)
177
190
  - You can see what condition matched in Marked by opening **Help->Show Custom Processor Log** and checking the STDERR output.
178
191
  - 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.
179
- - To run a custom processor for Obsidian, use the condition `tree contains .obsidian`
192
+ - To run a [custom processor for Obsidian](https://brettterpstra.com/2024/05/16/marked-2-and-obsidian/), use the condition `tree contains .obsidian`
180
193
 
181
194
  ## Testing
182
195
 
data/html/Array.html CHANGED
@@ -154,7 +154,7 @@
154
154
 
155
155
  <footer id="validator-badges" role="contentinfo">
156
156
  <p><a href="https://validator.w3.org/check/referer">Validate</a>
157
- <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.6.2.
157
+ <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.7.0.
158
158
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
159
159
  </footer>
160
160
 
@@ -265,7 +265,7 @@
265
265
 
266
266
  <footer id="validator-badges" role="contentinfo">
267
267
  <p><a href="https://validator.w3.org/check/referer">Validate</a>
268
- <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.6.2.
268
+ <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.7.0.
269
269
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
270
270
  </footer>
271
271
 
@@ -785,7 +785,7 @@
785
785
 
786
786
  <footer id="validator-badges" role="contentinfo">
787
787
  <p><a href="https://validator.w3.org/check/referer">Validate</a>
788
- <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.6.2.
788
+ <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.7.0.
789
789
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
790
790
  </footer>
791
791
 
@@ -164,7 +164,7 @@
164
164
 
165
165
  <footer id="validator-badges" role="contentinfo">
166
166
  <p><a href="https://validator.w3.org/check/referer">Validate</a>
167
- <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.6.2.
167
+ <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.7.0.
168
168
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
169
169
  </footer>
170
170
 
@@ -214,7 +214,7 @@
214
214
 
215
215
  <footer id="validator-badges" role="contentinfo">
216
216
  <p><a href="https://validator.w3.org/check/referer">Validate</a>
217
- <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.6.2.
217
+ <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.7.0.
218
218
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
219
219
  </footer>
220
220
 
@@ -282,7 +282,7 @@
282
282
 
283
283
  <footer id="validator-badges" role="contentinfo">
284
284
  <p><a href="https://validator.w3.org/check/referer">Validate</a>
285
- <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.6.2.
285
+ <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.7.0.
286
286
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
287
287
  </footer>
288
288
 
data/html/Conductor.html CHANGED
@@ -264,7 +264,7 @@ sub-tracks.</pre>
264
264
 
265
265
 
266
266
  <div class="method-source-code" id="stdin-source">
267
- <pre><span class="ruby-comment"># File lib/conductor.rb, line 27</span>
267
+ <pre><span class="ruby-comment"># File lib/conductor.rb, line 28</span>
268
268
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">stdin</span>
269
269
  <span class="ruby-identifier">warn</span> <span class="ruby-string">&quot;input on STDIN required&quot;</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>
270
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">&quot;utf-8&quot;</span>)
@@ -357,7 +357,7 @@ sub-tracks.</pre>
357
357
 
358
358
  <footer id="validator-badges" role="contentinfo">
359
359
  <p><a href="https://validator.w3.org/check/referer">Validate</a>
360
- <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.6.2.
360
+ <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.7.0.
361
361
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
362
362
  </footer>
363
363
 
data/html/FalseClass.html CHANGED
@@ -132,7 +132,7 @@
132
132
 
133
133
  <footer id="validator-badges" role="contentinfo">
134
134
  <p><a href="https://validator.w3.org/check/referer">Validate</a>
135
- <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.6.2.
135
+ <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.7.0.
136
136
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
137
137
  </footer>
138
138
 
data/html/Filter.html CHANGED
@@ -145,7 +145,7 @@
145
145
  </div>
146
146
 
147
147
  <div class="method-source-code" id="new-source">
148
- <pre><span class="ruby-comment"># File lib/conductor/filter.rb, line 221</span>
148
+ <pre><span class="ruby-comment"># File lib/conductor/filter.rb, line 324</span>
149
149
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">filter</span>)
150
150
  <span class="ruby-ivar">@filter</span>, <span class="ruby-ivar">@params</span> = <span class="ruby-identifier">filter</span>.<span class="ruby-identifier">normalize_filter</span>
151
151
  <span class="ruby-keyword">super</span>
@@ -176,11 +176,16 @@
176
176
 
177
177
 
178
178
  <div class="method-source-code" id="process-source">
179
- <pre><span class="ruby-comment"># File lib/conductor/filter.rb, line 226</span>
179
+ <pre><span class="ruby-comment"># File lib/conductor/filter.rb, line 329</span>
180
180
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">process</span>
181
181
  <span class="ruby-identifier">content</span> = <span class="ruby-constant">Conductor</span>.<span class="ruby-identifier">stdin</span>
182
182
 
183
183
  <span class="ruby-keyword">case</span> <span class="ruby-ivar">@filter</span>
184
+ <span class="ruby-keyword">when</span> <span class="ruby-regexp">/(insert|add|inject)(css|style)/</span>
185
+ <span class="ruby-ivar">@params</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">css</span><span class="ruby-operator">|</span>
186
+ <span class="ruby-identifier">content</span> = <span class="ruby-identifier">content</span>.<span class="ruby-identifier">insert_css</span>(<span class="ruby-identifier">css</span>)
187
+ <span class="ruby-keyword">end</span>
188
+ <span class="ruby-identifier">content</span>
184
189
  <span class="ruby-keyword">when</span> <span class="ruby-regexp">/(insert|add|inject)title/</span>
185
190
  <span class="ruby-identifier">content</span>.<span class="ruby-identifier">insert_title</span>
186
191
  <span class="ruby-keyword">when</span> <span class="ruby-regexp">/(insert|add|inject)script/</span>
@@ -189,6 +194,25 @@
189
194
  <span class="ruby-identifier">content</span> = <span class="ruby-identifier">content</span>.<span class="ruby-identifier">insert_script</span>(<span class="ruby-identifier">script</span>)
190
195
  <span class="ruby-keyword">end</span>
191
196
  <span class="ruby-node">&quot;#{content}&lt;/div&gt;&quot;</span>
197
+ <span class="ruby-keyword">when</span> <span class="ruby-regexp">/(prepend|append|insert|inject)(raw|file|code)/</span>
198
+ <span class="ruby-identifier">m</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">last_match</span>
199
+
200
+ <span class="ruby-identifier">position</span> = <span class="ruby-keyword">if</span> <span class="ruby-ivar">@params</span>.<span class="ruby-identifier">count</span> <span class="ruby-operator">==</span> <span class="ruby-value">2</span>
201
+ <span class="ruby-ivar">@params</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">normalize_position</span>
202
+ <span class="ruby-keyword">else</span>
203
+ <span class="ruby-identifier">m</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">normalize_position</span>
204
+ <span class="ruby-keyword">end</span>
205
+ <span class="ruby-identifier">content</span>.<span class="ruby-identifier">insert_file</span>(<span class="ruby-ivar">@params</span>[<span class="ruby-value">0</span>], <span class="ruby-identifier">m</span>[<span class="ruby-value">2</span>].<span class="ruby-identifier">normalize_include_type</span>, <span class="ruby-identifier">position</span>)
206
+ <span class="ruby-keyword">when</span> <span class="ruby-regexp">/inserttoc/</span>
207
+ <span class="ruby-identifier">max</span> = <span class="ruby-ivar">@params</span>.<span class="ruby-identifier">count</span>.<span class="ruby-identifier">positive?</span> <span class="ruby-operator">?</span> <span class="ruby-ivar">@params</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">:</span> <span class="ruby-keyword">nil</span>
208
+
209
+ <span class="ruby-keyword">if</span> <span class="ruby-ivar">@params</span>.<span class="ruby-identifier">count</span> <span class="ruby-operator">==</span> <span class="ruby-value">2</span>
210
+ <span class="ruby-identifier">after</span> = <span class="ruby-ivar">@params</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">=~</span> <span class="ruby-regexp">/2/</span> <span class="ruby-operator">?</span> <span class="ruby-value">:h2</span> <span class="ruby-operator">:</span> <span class="ruby-value">:h1</span>
211
+ <span class="ruby-keyword">else</span>
212
+ <span class="ruby-identifier">after</span> = <span class="ruby-value">:start</span>
213
+ <span class="ruby-keyword">end</span>
214
+
215
+ <span class="ruby-identifier">content</span>.<span class="ruby-identifier">insert_toc</span>(<span class="ruby-identifier">max</span>, <span class="ruby-identifier">after</span>)
192
216
  <span class="ruby-keyword">when</span> <span class="ruby-regexp">/(add|set)meta/</span>
193
217
  <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@params</span>.<span class="ruby-identifier">count</span> <span class="ruby-operator">==</span> <span class="ruby-value">2</span>
194
218
  <span class="ruby-identifier">warn</span> <span class="ruby-node">&quot;Invalid filter parameters: #{@filter}(#{@params.join(&quot;,&quot;)})&quot;</span>
@@ -198,8 +222,8 @@
198
222
  <span class="ruby-comment"># needs to test for existing meta, setting key if exists, adding if not</span>
199
223
  <span class="ruby-comment"># should recognize yaml and mmd</span>
200
224
  <span class="ruby-identifier">content</span>.<span class="ruby-identifier">set_meta</span>(<span class="ruby-ivar">@params</span>[<span class="ruby-value">0</span>], <span class="ruby-ivar">@params</span>[<span class="ruby-value">1</span>], <span class="ruby-value">style:</span> <span class="ruby-identifier">content</span>.<span class="ruby-identifier">meta_type</span>)
201
- <span class="ruby-keyword">when</span> <span class="ruby-regexp">/(strip|remove)meta/</span>
202
- <span class="ruby-keyword">if</span> <span class="ruby-ivar">@params</span>
225
+ <span class="ruby-keyword">when</span> <span class="ruby-regexp">/(strip|remove|delete)meta/</span>
226
+ <span class="ruby-keyword">if</span> <span class="ruby-ivar">@params</span>&amp;.<span class="ruby-identifier">count</span>.<span class="ruby-identifier">positive?</span>
203
227
  <span class="ruby-identifier">content</span>.<span class="ruby-identifier">delete_meta</span>(<span class="ruby-ivar">@params</span>[<span class="ruby-value">0</span>])
204
228
  <span class="ruby-keyword">else</span>
205
229
  <span class="ruby-identifier">content</span>.<span class="ruby-identifier">strip_meta</span>
@@ -237,7 +261,7 @@
237
261
 
238
262
  <footer id="validator-badges" role="contentinfo">
239
263
  <p><a href="https://validator.w3.org/check/referer">Validate</a>
240
- <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.6.2.
264
+ <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.7.0.
241
265
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
242
266
  </footer>
243
267
 
data/html/Hash.html CHANGED
@@ -154,7 +154,7 @@
154
154
 
155
155
  <footer id="validator-badges" role="contentinfo">
156
156
  <p><a href="https://validator.w3.org/check/referer">Validate</a>
157
- <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.6.2.
157
+ <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.7.0.
158
158
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
159
159
  </footer>
160
160
 
data/html/Object.html CHANGED
@@ -132,7 +132,7 @@
132
132
 
133
133
  <footer id="validator-badges" role="contentinfo">
134
134
  <p><a href="https://validator.w3.org/check/referer">Validate</a>
135
- <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.6.2.
135
+ <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.7.0.
136
136
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
137
137
  </footer>
138
138
 
@@ -80,7 +80,7 @@
80
80
 
81
81
  <footer id="validator-badges" role="contentinfo">
82
82
  <p><a href="https://validator.w3.org/check/referer">Validate</a>
83
- <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.6.2.
83
+ <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.7.0.
84
84
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
85
85
  </footer>
86
86