marked-conductor 1.0.13 → 1.0.15

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: d289620d1960ec33f53d30e34fe0b2dda1590f59ab97f6c84dc1051ec59556e6
4
+ data.tar.gz: f8f52753f27e15303deaeb3558f9506c944b1d8c8de4883173e19c6ded4b975f
5
5
  SHA512:
6
- metadata.gz: 89fa260f9b5efc1edcc7cb18ebd50ea5b3ab63669639dce30e0b7d43bcf20434f3c693316f77deea811475dc8a6d2387dc1a45e0c04014fb30125a97d774524e
7
- data.tar.gz: 259f9e19257859cf0efeb6b69299dde021100ea27775c948b0c8bbf869f389e58d78307deb7498abfb68969542a3c5e5b32c068d9e05c7a9847fe6c06621b8fe
6
+ metadata.gz: f25710fb5a955089af61f9afd82a6e6c0a7ca2472f81d6063c130e806e92a29ab78b014887421acfc72253e8875b6537146a19cc4cbe2b7957e459725e988818
7
+ data.tar.gz: 0d88105def3581ba8c025a090a22d97ef60f89a3eaf5b06c04888a10b5f5470ae2239e5ebebbd65ca46d64a25d069726621698dd0b74f5e77442e4042df5673e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ### 1.0.15
2
+
3
+ 2024-05-25 11:14
4
+
5
+ #### NEW
6
+
7
+ - New filter insertTOC(max, after) to insert a table of contents, optionally with max levels and after (start, *h1, or h2)
8
+ - New filter prepend/appendFile(path) to include a file (also pre/appendRaw and pre/appendCode)
9
+
10
+ ### 1.0.14
11
+
12
+ 2024-05-25 06:41
13
+
14
+ #### NEW
15
+
16
+ - InsertTitle filter will extract title from metadata or filename and insert an H1 title into the content
17
+ - 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
18
+
1
19
  ### 1.0.13
2
20
 
3
21
  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,49 @@ 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
+ | `deleteMeta(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
+ | `insertTOC(max, after)` | insert TOC (max=max levels, after=start, \*h1, or h2) |
154
+ | `prepend/appendFile(path)` | insert a file as Markdown at beginning or end of content |
155
+ | `prepend/appendRaw(path)` | insert a file as raw HTML at beginning or end of content |
156
+ | `prepend/appendCode(path)` | insert a file as a code block at beginning or end of content |
157
+
158
+ 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.
159
+
160
+ 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`.
161
+
162
+ > Example:
163
+ >
164
+ > filter: setStyle(github)
165
+
166
+
167
+ > Filters can be camel case (replaceAll) or snake case (replace_all), either will work, case insensitive.
132
168
 
133
169
  ## Custom Processors
134
170
 
data/html/Filter.html ADDED
@@ -0,0 +1,262 @@
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 288</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 293</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">/(prepend|append|insert|inject)(raw|file|code)/</span>
193
+ <span class="ruby-identifier">m</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">last_match</span>
194
+
195
+ <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>
196
+ <span class="ruby-ivar">@params</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">normalize_position</span>
197
+ <span class="ruby-keyword">else</span>
198
+ <span class="ruby-identifier">m</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">normalize_position</span>
199
+ <span class="ruby-keyword">end</span>
200
+ <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>)
201
+ <span class="ruby-keyword">when</span> <span class="ruby-regexp">/inserttoc/</span>
202
+ <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>
203
+
204
+ <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>
205
+ <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>
206
+ <span class="ruby-keyword">else</span>
207
+ <span class="ruby-identifier">after</span> = <span class="ruby-value">:start</span>
208
+ <span class="ruby-keyword">end</span>
209
+
210
+ <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>)
211
+ <span class="ruby-keyword">when</span> <span class="ruby-regexp">/(add|set)meta/</span>
212
+ <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>
213
+ <span class="ruby-identifier">warn</span> <span class="ruby-node">&quot;Invalid filter parameters: #{@filter}(#{@params.join(&quot;,&quot;)})&quot;</span>
214
+ <span class="ruby-keyword">return</span> <span class="ruby-identifier">content</span>
215
+ <span class="ruby-keyword">end</span>
216
+
217
+ <span class="ruby-comment"># needs to test for existing meta, setting key if exists, adding if not</span>
218
+ <span class="ruby-comment"># should recognize yaml and mmd</span>
219
+ <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>)
220
+ <span class="ruby-keyword">when</span> <span class="ruby-regexp">/(strip|remove|delete)meta/</span>
221
+ <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>
222
+ <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>])
223
+ <span class="ruby-keyword">else</span>
224
+ <span class="ruby-identifier">content</span>.<span class="ruby-identifier">strip_meta</span>
225
+ <span class="ruby-keyword">end</span>
226
+ <span class="ruby-keyword">when</span> <span class="ruby-regexp">/setstyle/</span>
227
+ <span class="ruby-comment"># Should check for existing style first</span>
228
+ <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>)
229
+ <span class="ruby-keyword">when</span> <span class="ruby-regexp">/replaceall/</span>
230
+ <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>
231
+ <span class="ruby-identifier">warn</span> <span class="ruby-node">&quot;Invalid filter parameters: #{@filter}(#{@params.join(&quot;,&quot;)})&quot;</span>
232
+ <span class="ruby-keyword">return</span> <span class="ruby-identifier">content</span>
233
+ <span class="ruby-keyword">end</span>
234
+
235
+ <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>])
236
+ <span class="ruby-keyword">when</span> <span class="ruby-regexp">/replace$/</span>
237
+ <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>
238
+ <span class="ruby-identifier">warn</span> <span class="ruby-node">&quot;Invalid filter parameters: #{@filter}(#{@params.join(&quot;,&quot;)})&quot;</span>
239
+ <span class="ruby-keyword">return</span> <span class="ruby-identifier">content</span>
240
+ <span class="ruby-keyword">end</span>
241
+
242
+ <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>])
243
+ <span class="ruby-keyword">end</span>
244
+ <span class="ruby-keyword">end</span></pre>
245
+ </div>
246
+ </div>
247
+
248
+
249
+ </div>
250
+
251
+ </section>
252
+
253
+ </section>
254
+ </main>
255
+
256
+
257
+ <footer id="validator-badges" role="contentinfo">
258
+ <p><a href="https://validator.w3.org/check/referer">Validate</a>
259
+ <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.6.2.
260
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
261
+ </footer>
262
+