marked-conductor 1.0.13 → 1.0.14

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: 55f1d24332aec42ce9808bd2cf18ba75cd69c89828930a97239bcfb9d9b9d629
4
- data.tar.gz: 4995332673049ee5235307a2b938e0e3e71a8085748597789484efde02a4ec56
3
+ metadata.gz: 69c655b0c85492536b091259aeb5000c04c5830cc1296cb241ceeb507210bd7d
4
+ data.tar.gz: 42ed08e2e792dc85945e4c3dbcb0facfbbad2eb1f51553d5999843d042a00703
5
5
  SHA512:
6
- metadata.gz: 89fa260f9b5efc1edcc7cb18ebd50ea5b3ab63669639dce30e0b7d43bcf20434f3c693316f77deea811475dc8a6d2387dc1a45e0c04014fb30125a97d774524e
7
- data.tar.gz: 259f9e19257859cf0efeb6b69299dde021100ea27775c948b0c8bbf869f389e58d78307deb7498abfb68969542a3c5e5b32c068d9e05c7a9847fe6c06621b8fe
6
+ metadata.gz: 003ec761e335649d21c3bdc209cca365ce6de2152678f896bf623e422f9e161f4d7466231b8915949cdff535874465de4b3ba773f6683780895897a8caf09f47
7
+ data.tar.gz: 6bc9fd32c5a46fca3c7b11184b95dc62c31ade54b5cbd4802e2c3f3e4bef6cfe73c01631fe50a6761a3e804786f567ae897d387e304e265fec5b5689168b8039
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ### 1.0.14
2
+
3
+ 2024-05-25 06:41
4
+
5
+ #### NEW
6
+
7
+ - InsertTitle filter will extract title from metadata or filename and insert an H1 title into the content
8
+ - InsertScript will inject a javascript at the end of the content, allows passing multiple scripts separated by comma, and if the path is just a filename, it will look for it in ~/.config/conductor/javascript and insert an absolute path
9
+
1
10
  ### 1.0.13
2
11
 
3
12
  2024-05-24 13:12
data/README.md CHANGED
@@ -23,7 +23,7 @@ If you use Homebrew, you can run
23
23
 
24
24
  To use Conductor, you need to set up a configuration file in `~/.config/conductor/tracks.yaml`. Run `conductor` once to create the directory and an empty configuration. See [Configuration](#configuration) below for details on setting up your "tracks."
25
25
 
26
- Once configured, you can set up conductor as a Custom Processor in Marked. Run `which conductor | pbcopy` to get the full path to the binary and copy it, then open <b>Marked Preferences > Advanced</b> and select either Custom Processor or Custom Preprocessor (or both) and paste into the <b>Path:</b> field. You can select <i>Automatically enable for new windows</i> to have the processor enabled by default when opening documents.
26
+ Once configured, you can set up conductor as a Custom Processor in Marked. Run `which conductor | pbcopy` to get the full path to the binary and copy it, then open **Marked Preferences > Advanced** and select either Custom Processor or Custom Preprocessor (or both) and paste into the **Path:** field. You can select *Automatically enable for new windows* to have the processor enabled by default when opening documents.
27
27
 
28
28
 
29
29
  ![Marked preferences](images/preferences.jpg)
@@ -122,13 +122,45 @@ Conditions can be combined with AND or OR (must be uppercase) and simple parenth
122
122
 
123
123
  ### Actions
124
124
 
125
- The action can be either `script` or `command`.
125
+ The action can be `script`, `command`, or `filter`.
126
126
 
127
- 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.
127
+ **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
128
 
129
- 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.
129
+ > Example:
130
+ >
131
+ > script: github_pre
130
132
 
131
- 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.
133
+ **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
+
135
+ > Example:
136
+ >
137
+ > command: multimarkdown
138
+
139
+
140
+ > 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
+
142
+ **Filters** are simple actions that can be run on the content without having to write a separate script for it. Available filters are:
143
+ | filter | description |
144
+ | :---- | :---------- |
145
+ | `setMeta(key, value)` | adds or updates a meta key, aware of YAML and MMD |
146
+ | `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
149
+ | `replace(search, replace)` | performs a (single) search and replace on content |
150
+ | `replaceAll(search, replace)` | global version of `replaceAll`) |
151
+ | `insertTitle` | adds a title to the document, either from metadata or filename |
152
+ | `insertScript(path[,path])` | injects javascript(s) |
153
+
154
+ 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
+
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`.
157
+
158
+ > Example:
159
+ >
160
+ > filter: setStyle(github)
161
+
162
+
163
+ > Filters can be camel case (replaceAll) or snake case (replace_all), either will work, case insensitive.
132
164
 
133
165
  ## Custom Processors
134
166
 
data/html/Filter.html ADDED
@@ -0,0 +1,243 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>class Filter - Marked Conductor</title>
8
+
9
+ <script type="text/javascript">
10
+ var rdoc_rel_prefix = "./";
11
+ var index_rel_prefix = "./";
12
+ </script>
13
+
14
+ <script src="./js/navigation.js" defer></script>
15
+ <script src="./js/search.js" defer></script>
16
+ <script src="./js/search_index.js" defer></script>
17
+ <script src="./js/searcher.js" defer></script>
18
+ <script src="./js/darkfish.js" defer></script>
19
+
20
+ <link href="./css/fonts.css" rel="stylesheet">
21
+ <link href="./css/rdoc.css" rel="stylesheet">
22
+
23
+
24
+ <body id="top" role="document" class="class">
25
+ <nav role="navigation">
26
+ <div id="project-navigation">
27
+ <div id="home-section" role="region" title="Quick navigation" class="nav-section">
28
+ <h2>
29
+ <a href="./index.html" rel="home">Home</a>
30
+ </h2>
31
+
32
+ <div id="table-of-contents-navigation">
33
+ <a href="./table_of_contents.html#pages">Pages</a>
34
+ <a href="./table_of_contents.html#classes">Classes</a>
35
+ <a href="./table_of_contents.html#methods">Methods</a>
36
+ </div>
37
+ </div>
38
+
39
+ <div id="search-section" role="search" class="project-section initially-hidden">
40
+ <form action="#" method="get" accept-charset="utf-8">
41
+ <div id="search-field-wrapper">
42
+ <input id="search-field" role="combobox" aria-label="Search"
43
+ aria-autocomplete="list" aria-controls="search-results"
44
+ type="text" name="search" placeholder="Search (/) for a class, method, ..." spellcheck="false"
45
+ title="Type to search, Up and Down to navigate, Enter to load">
46
+ </div>
47
+
48
+ <ul id="search-results" aria-label="Search Results"
49
+ aria-busy="false" aria-expanded="false"
50
+ aria-atomic="false" class="initially-hidden"></ul>
51
+ </form>
52
+ </div>
53
+
54
+ </div>
55
+
56
+
57
+
58
+ <div id="class-metadata">
59
+
60
+
61
+ <div id="parent-class-section" class="nav-section">
62
+ <h3>Parent</h3>
63
+
64
+ <p class="link"><a href="String.html">String</a>
65
+ </div>
66
+
67
+
68
+
69
+
70
+ <!-- Method Quickref -->
71
+ <div id="method-list-section" class="nav-section">
72
+ <h3>Methods</h3>
73
+
74
+ <ul class="link-list" role="directory">
75
+ <li class="calls-super" ><a href="#method-c-new">::new</a>
76
+ <li ><a href="#method-i-process">#process</a>
77
+ </ul>
78
+ </div>
79
+
80
+ </div>
81
+ </nav>
82
+
83
+ <main role="main" aria-labelledby="class-Filter">
84
+ <h1 id="class-Filter" class="class">
85
+ class Filter
86
+ </h1>
87
+
88
+ <section class="description">
89
+
90
+ <p><a href="String.html"><code>String</code></a> filtering</p>
91
+
92
+ </section>
93
+
94
+ <section id="5Buntitled-5D" class="documentation-section">
95
+
96
+
97
+
98
+ <section class="attribute-method-details" class="method-section">
99
+ <header>
100
+ <h3>Attributes</h3>
101
+ </header>
102
+
103
+ <div id="attribute-i-filter" class="method-detail">
104
+ <div class="method-heading attribute-method-heading">
105
+ <span class="method-name">filter</span><span
106
+ class="attribute-access-type">[R]</span>
107
+ </div>
108
+
109
+ <div class="method-description">
110
+
111
+ </div>
112
+ </div>
113
+ <div id="attribute-i-params" class="method-detail">
114
+ <div class="method-heading attribute-method-heading">
115
+ <span class="method-name">params</span><span
116
+ class="attribute-access-type">[R]</span>
117
+ </div>
118
+
119
+ <div class="method-description">
120
+
121
+ </div>
122
+ </div>
123
+ </section>
124
+
125
+
126
+ <section id="public-class-5Buntitled-5D-method-details" class="method-section">
127
+ <header>
128
+ <h3>Public Class Methods</h3>
129
+ </header>
130
+
131
+ <div id="method-c-new" class="method-detail ">
132
+ <div class="method-header">
133
+ <div class="method-heading">
134
+ <span class="method-name">new</span><span
135
+ class="method-args">(filter)</span>
136
+ <span class="method-click-advice">click to toggle source</span>
137
+ </div>
138
+ </div>
139
+
140
+ <div class="method-description">
141
+
142
+ <div class="method-calls-super">
143
+ Calls superclass method
144
+
145
+ </div>
146
+
147
+ <div class="method-source-code" id="new-source">
148
+ <pre><span class="ruby-comment"># File lib/conductor/filter.rb, line 221</span>
149
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">filter</span>)
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
+ <span class="ruby-keyword">super</span>
152
+ <span class="ruby-keyword">end</span></pre>
153
+ </div>
154
+ </div>
155
+
156
+
157
+ </div>
158
+
159
+ </section>
160
+
161
+ <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
162
+ <header>
163
+ <h3>Public Instance Methods</h3>
164
+ </header>
165
+
166
+ <div id="method-i-process" class="method-detail ">
167
+ <div class="method-header">
168
+ <div class="method-heading">
169
+ <span class="method-name">process</span><span
170
+ class="method-args">()</span>
171
+ <span class="method-click-advice">click to toggle source</span>
172
+ </div>
173
+ </div>
174
+
175
+ <div class="method-description">
176
+
177
+
178
+ <div class="method-source-code" id="process-source">
179
+ <pre><span class="ruby-comment"># File lib/conductor/filter.rb, line 226</span>
180
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">process</span>
181
+ <span class="ruby-identifier">content</span> = <span class="ruby-constant">Conductor</span>.<span class="ruby-identifier">stdin</span>
182
+
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)title/</span>
185
+ <span class="ruby-identifier">content</span>.<span class="ruby-identifier">insert_title</span>
186
+ <span class="ruby-keyword">when</span> <span class="ruby-regexp">/(insert|add|inject)script/</span>
187
+ <span class="ruby-identifier">content</span> = <span class="ruby-identifier">content</span>.<span class="ruby-identifier">append</span>(<span class="ruby-string">&quot;\n\n&lt;div&gt;&quot;</span>)
188
+ <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">script</span><span class="ruby-operator">|</span>
189
+ <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
+ <span class="ruby-keyword">end</span>
191
+ <span class="ruby-node">&quot;#{content}&lt;/div&gt;&quot;</span>
192
+ <span class="ruby-keyword">when</span> <span class="ruby-regexp">/(add|set)meta/</span>
193
+ <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
+ <span class="ruby-identifier">warn</span> <span class="ruby-node">&quot;Invalid filter parameters: #{@filter}(#{@params.join(&quot;,&quot;)})&quot;</span>
195
+ <span class="ruby-keyword">return</span> <span class="ruby-identifier">content</span>
196
+ <span class="ruby-keyword">end</span>
197
+
198
+ <span class="ruby-comment"># needs to test for existing meta, setting key if exists, adding if not</span>
199
+ <span class="ruby-comment"># should recognize yaml and mmd</span>
200
+ <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>
203
+ <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
+ <span class="ruby-keyword">else</span>
205
+ <span class="ruby-identifier">content</span>.<span class="ruby-identifier">strip_meta</span>
206
+ <span class="ruby-keyword">end</span>
207
+ <span class="ruby-keyword">when</span> <span class="ruby-regexp">/setstyle/</span>
208
+ <span class="ruby-comment"># Should check for existing style first</span>
209
+ <span class="ruby-identifier">content</span>.<span class="ruby-identifier">set_meta</span>(<span class="ruby-string">&quot;marked style&quot;</span>, <span class="ruby-ivar">@params</span>[<span class="ruby-value">0</span>], <span class="ruby-value">style:</span> <span class="ruby-value">:comment</span>)
210
+ <span class="ruby-keyword">when</span> <span class="ruby-regexp">/replaceall/</span>
211
+ <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>
212
+ <span class="ruby-identifier">warn</span> <span class="ruby-node">&quot;Invalid filter parameters: #{@filter}(#{@params.join(&quot;,&quot;)})&quot;</span>
213
+ <span class="ruby-keyword">return</span> <span class="ruby-identifier">content</span>
214
+ <span class="ruby-keyword">end</span>
215
+
216
+ <span class="ruby-identifier">content</span>.<span class="ruby-identifier">replace_all</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>])
217
+ <span class="ruby-keyword">when</span> <span class="ruby-regexp">/replace$/</span>
218
+ <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>
219
+ <span class="ruby-identifier">warn</span> <span class="ruby-node">&quot;Invalid filter parameters: #{@filter}(#{@params.join(&quot;,&quot;)})&quot;</span>
220
+ <span class="ruby-keyword">return</span> <span class="ruby-identifier">content</span>
221
+ <span class="ruby-keyword">end</span>
222
+
223
+ <span class="ruby-identifier">content</span>.<span class="ruby-identifier">replace</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>])
224
+ <span class="ruby-keyword">end</span>
225
+ <span class="ruby-keyword">end</span></pre>
226
+ </div>
227
+ </div>
228
+
229
+
230
+ </div>
231
+
232
+ </section>
233
+
234
+ </section>
235
+ </main>
236
+
237
+
238
+ <footer id="validator-badges" role="contentinfo">
239
+ <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.
241
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
242
+ </footer>
243
+