marked-conductor 1.0.17 → 1.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -0
  3. data/README.md +2 -0
  4. data/lib/conductor/filter.rb +43 -23
  5. data/lib/conductor/version.rb +1 -1
  6. data/src/_README.md +2 -0
  7. metadata +1 -62
  8. data/html/Array.html +0 -160
  9. data/html/Conductor/Command.html +0 -271
  10. data/html/Conductor/Condition.html +0 -791
  11. data/html/Conductor/Config.html +0 -170
  12. data/html/Conductor/Env.html +0 -220
  13. data/html/Conductor/Script.html +0 -288
  14. data/html/Conductor.html +0 -363
  15. data/html/FalseClass.html +0 -138
  16. data/html/Filter.html +0 -269
  17. data/html/Hash.html +0 -160
  18. data/html/Object.html +0 -138
  19. data/html/README_rdoc.html +0 -86
  20. data/html/String.html +0 -1409
  21. data/html/TrueClass.html +0 -138
  22. data/html/YuiCompressor/Yui.html +0 -447
  23. data/html/YuiCompressor.html +0 -93
  24. data/html/created.rid +0 -16
  25. data/html/css/fonts.css +0 -167
  26. data/html/css/rdoc.css +0 -687
  27. data/html/fonts/Lato-Light.ttf +0 -0
  28. data/html/fonts/Lato-LightItalic.ttf +0 -0
  29. data/html/fonts/Lato-Regular.ttf +0 -0
  30. data/html/fonts/Lato-RegularItalic.ttf +0 -0
  31. data/html/fonts/SourceCodePro-Bold.ttf +0 -0
  32. data/html/fonts/SourceCodePro-Regular.ttf +0 -0
  33. data/html/images/add.png +0 -0
  34. data/html/images/arrow_up.png +0 -0
  35. data/html/images/brick.png +0 -0
  36. data/html/images/brick_link.png +0 -0
  37. data/html/images/bug.png +0 -0
  38. data/html/images/bullet_black.png +0 -0
  39. data/html/images/bullet_toggle_minus.png +0 -0
  40. data/html/images/bullet_toggle_plus.png +0 -0
  41. data/html/images/date.png +0 -0
  42. data/html/images/delete.png +0 -0
  43. data/html/images/find.png +0 -0
  44. data/html/images/loadingAnimation.gif +0 -0
  45. data/html/images/macFFBgHack.png +0 -0
  46. data/html/images/package.png +0 -0
  47. data/html/images/page_green.png +0 -0
  48. data/html/images/page_white_text.png +0 -0
  49. data/html/images/page_white_width.png +0 -0
  50. data/html/images/plugin.png +0 -0
  51. data/html/images/ruby.png +0 -0
  52. data/html/images/tag_blue.png +0 -0
  53. data/html/images/tag_green.png +0 -0
  54. data/html/images/transparent.png +0 -0
  55. data/html/images/wrench.png +0 -0
  56. data/html/images/wrench_orange.png +0 -0
  57. data/html/images/zoom.png +0 -0
  58. data/html/index.html +0 -110
  59. data/html/js/darkfish.js +0 -97
  60. data/html/js/navigation.js +0 -105
  61. data/html/js/navigation.js.gz +0 -0
  62. data/html/js/search.js +0 -110
  63. data/html/js/search_index.js +0 -1
  64. data/html/js/search_index.js.gz +0 -0
  65. data/html/js/searcher.js +0 -229
  66. data/html/js/searcher.js.gz +0 -0
  67. data/html/table_of_contents.html +0 -539
  68. data/test.md +0 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a78acbdf0f9693636a7456265dca72cf53cfa771aaa4fe0e2ad848c4b3526612
4
- data.tar.gz: c913dc807337b977cc0caa4b843512991df890f48cff913a06fe660831aa0f53
3
+ metadata.gz: 07cc317b99e30de42235572b6444e09b6a958b79bc2eda7fdb8fa9b88d608b3f
4
+ data.tar.gz: 31b568475ab2a17c310d5279e8c356d10d4c8217ecb112a667edde4e6a6425a5
5
5
  SHA512:
6
- metadata.gz: b2c6979fcb015ac31d51895772ed83c9aad4644bb8b3f151f31e6e5015ca0fda4ca0b1a994adef1c388fe5c557747cd787da8a9325a2bb543295ac3bcaddbb18
7
- data.tar.gz: c4759af9e3af7495e659464018eaf8eb858d6d10fdb93ed8b137c85c01b71fec23d3d062b91ba1deedcc4859b6ee832064e91a476929cb89e5898d62fbdba469
6
+ metadata.gz: cb5b28f08d4de3b9e2574564302f390d519dbeab569b84e08a6eac7f432053235a53bf6cf31f9742384eb978618b5cf73d24661f22fc1f9b91e1e18a4686d7eb
7
+ data.tar.gz: 9067a2196bf46d104bc62a0152908a14cee90e1b7c27434a24452d85a2da20abcfd19499947e65503fdde7051e9e023a3c5829930e0451b28041c5fdf4d1713a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ### 1.0.18
2
+
3
+ 2024-07-02 11:08
4
+
5
+ #### NEW
6
+
7
+ - InsertScript or insertCSS arguments that are URLs will be inserted properly
8
+
9
+ #### FIXED
10
+
11
+ - When prepending styles/files/titles, always inject AFTER existing metadata (YAML or MMD)
12
+
1
13
  ### 1.0.17
2
14
 
3
15
  2024-07-02 10:27
data/README.md CHANGED
@@ -170,6 +170,8 @@ For `insertScript`, if path is just a filename it will look for a match in `~/.c
170
170
 
171
171
  For `insertCSS`, if path is just a filename (with or without .css extension), the file will be searched for in `~/.config/conductor/css` or `~/.config/conductor/files` and injected. CSS will be compressed using the YUI algorithm and inserted at the top of the document, but after any existing metadata.
172
172
 
173
+ If the path for `insertScript` or `insertCSS` is a URL instead of a filename, the URL will be properly inserted instead of a file path. Inserted scripts will be surrounded with `<div>` tags, which fixes a quirk with javascript in Marked.
174
+
173
175
  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.
174
176
 
175
177
  For `autoLink`, any URL that's not contained in parenthesis or following a `[]: url` pattern will be autolinked (surrounded by angle brackets). URLs must contain `//` to be recognized, but any protocol will work, e.g. `x-marked://refresh`.
@@ -78,7 +78,7 @@ class ::String
78
78
  when :h1
79
79
  first_h1.positive? ? first_h1 + 1 : 0
80
80
  else
81
- 0
81
+ meta_insert_point.positive? ? meta_insert_point + 1 : 0
82
82
  end
83
83
 
84
84
  lines.insert(line, "\n<!--toc#{max}-->\n").join("\n")
@@ -92,7 +92,13 @@ class ::String
92
92
  end
93
93
  end
94
94
 
95
+ def insert_stylesheet(path)
96
+ inject_after_meta(%(<link rel="stylesheet" href="#{path.strip}">))
97
+ end
98
+
95
99
  def insert_css(path)
100
+ return insert_stylesheet(path) if path.strip =~ /^http/
101
+
96
102
  path.sub!(/(\.css)?$/, '.css')
97
103
 
98
104
  if path =~ %r{^[~/]}
@@ -109,17 +115,21 @@ class ::String
109
115
  content = IO.read(path)
110
116
  yui = YuiCompressor::Yui.new
111
117
  content = yui.compress(content)
112
- lines = split(/\n/)
113
- insert_point = meta_insert_point
114
- insert_at = insert_point.positive? ? insert_point + 1 : 0
115
- lines.insert(insert_at, "#{content.wrap_style}\n\n")
116
- lines.join("\n")
118
+ inject_after_meta(content.wrap_style)
117
119
  else
118
120
  warn "File not found (#{path})"
119
121
  self
120
122
  end
121
123
  end
122
124
 
125
+ def inject_after_meta(content)
126
+ lines = split(/\n/)
127
+ insert_point = meta_insert_point
128
+ insert_at = insert_point.positive? ? insert_point + 1 : 0
129
+ lines.insert(insert_at, "#{content}\n\n")
130
+ lines.join("\n")
131
+ end
132
+
123
133
  def insert_file(path, type = :file, position = :end)
124
134
  path.strip!
125
135
 
@@ -142,7 +152,7 @@ class ::String
142
152
 
143
153
  case position
144
154
  when :start
145
- "#{out}\n#{self}"
155
+ inject_after_meta(out)
146
156
  when :h1
147
157
  split(/\n/).insert(first_h1 + 1, out).join("\n")
148
158
  else
@@ -154,9 +164,19 @@ class ::String
154
164
  "#{self}\n#{string}"
155
165
  end
156
166
 
167
+ def append!(string)
168
+ replace append(string)
169
+ end
170
+
171
+ def insert_javascript(path)
172
+ %(#{self}\n<script type="javascript" src="#{path.strip}"></script>\n)
173
+ end
174
+
157
175
  def insert_script(path)
158
176
  path.strip!
159
- path = "#{path}.js" unless path =~ /\.js$/
177
+ return insert_javascript(path) if path =~ /^http/
178
+
179
+ path.sub!(/(\.js)?$/, '.js')
160
180
 
161
181
  if path =~ %r{^[~/]}
162
182
  path = File.expand_path(path)
@@ -172,7 +192,7 @@ class ::String
172
192
  path = new_path if File.exist?(new_path)
173
193
  end
174
194
 
175
- %(#{self}\n<script type="javascript" src="#{path}"></script>\n)
195
+ insert_javascript(path)
176
196
  end
177
197
 
178
198
  def title_from_slug
@@ -297,12 +317,12 @@ class ::String
297
317
  gsub(regex.to_rx, pattern.to_pattern)
298
318
  end
299
319
 
300
- def replace(regex, pattern)
320
+ def replace_one(regex, pattern)
301
321
  sub(regex.to_rx, pattern.to_pattern)
302
322
  end
303
323
 
304
324
  def autolink
305
- gsub(%r{(?mi)(?<!\(|]: )\b((?:[\w-]+?://)[-a-zA-Z0-9@:%._+~#=]{2,256}\b(?:[-a-zA-Z0-9@:%_+.~#?&/=]*))},
325
+ gsub(%r{(?mi)(?<!\(|\]: |")\b((?:[\w-]+?://)[-a-zA-Z0-9@:%._+~#=]{2,256}\b(?:[-a-zA-Z0-9@:%_+.~#?&/=]*))},
306
326
  '<\1>')
307
327
  end
308
328
 
@@ -343,7 +363,7 @@ class Filter < String
343
363
  when /(insert|add|inject)title/
344
364
  content.insert_title
345
365
  when /(insert|add|inject)script/
346
- content = content.append("\n\n<div>")
366
+ content.append!("\n\n<div>")
347
367
  @params.each do |script|
348
368
  content = content.insert_script(script)
349
369
  end
@@ -352,19 +372,19 @@ class Filter < String
352
372
  m = Regexp.last_match
353
373
 
354
374
  position = if @params.count == 2
355
- @params[1].normalize_position
356
- else
357
- m[1].normalize_position
358
- end
375
+ @params[1].normalize_position
376
+ else
377
+ m[1].normalize_position
378
+ end
359
379
  content.insert_file(@params[0], m[2].normalize_include_type, position)
360
380
  when /inserttoc/
361
381
  max = @params.count.positive? ? @params[0] : nil
362
382
 
363
- if @params.count == 2
364
- after = @params[1] =~ /2/ ? :h2 : :h1
365
- else
366
- after = :start
367
- end
383
+ after = if @params.count == 2
384
+ @params[1] =~ /2/ ? :h2 : :h1
385
+ else
386
+ :start
387
+ end
368
388
 
369
389
  content.insert_toc(max, after)
370
390
  when /(add|set)meta/
@@ -377,7 +397,7 @@ class Filter < String
377
397
  # should recognize yaml and mmd
378
398
  content.set_meta(@params[0], @params[1], style: content.meta_type)
379
399
  when /(strip|remove|delete)meta/
380
- if @params&.count.positive?
400
+ if @params.count.positive?
381
401
  content.delete_meta(@params[0])
382
402
  else
383
403
  content.strip_meta
@@ -398,7 +418,7 @@ class Filter < String
398
418
  return content
399
419
  end
400
420
 
401
- content.replace(@params[0], @params[1])
421
+ content.replace_one(@params[0], @params[1])
402
422
  when /(auto|self)link/
403
423
  content.autolink
404
424
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Conductor
4
- VERSION = '1.0.17'
4
+ VERSION = '1.0.18'
5
5
  end
data/src/_README.md CHANGED
@@ -170,6 +170,8 @@ For `insertScript`, if path is just a filename it will look for a match in `~/.c
170
170
 
171
171
  For `insertCSS`, if path is just a filename (with or without .css extension), the file will be searched for in `~/.config/conductor/css` or `~/.config/conductor/files` and injected. CSS will be compressed using the YUI algorithm and inserted at the top of the document, but after any existing metadata.
172
172
 
173
+ If the path for `insertScript` or `insertCSS` is a URL instead of a filename, the URL will be properly inserted instead of a file path. Inserted scripts will be surrounded with `<div>` tags, which fixes a quirk with javascript in Marked.
174
+
173
175
  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.
174
176
 
175
177
  For `autoLink`, any URL that's not contained in parenthesis or following a `[]: url` pattern will be autolinked (surrounded by angle brackets). URLs must contain `//` to be recognized, but any protocol will work, e.g. `x-marked://refresh`.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marked-conductor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.17
4
+ version: 1.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra
@@ -204,66 +204,6 @@ files:
204
204
  - README.rdoc
205
205
  - Rakefile
206
206
  - bin/conductor
207
- - html/Array.html
208
- - html/Conductor.html
209
- - html/Conductor/Command.html
210
- - html/Conductor/Condition.html
211
- - html/Conductor/Config.html
212
- - html/Conductor/Env.html
213
- - html/Conductor/Script.html
214
- - html/FalseClass.html
215
- - html/Filter.html
216
- - html/Hash.html
217
- - html/Object.html
218
- - html/README_rdoc.html
219
- - html/String.html
220
- - html/TrueClass.html
221
- - html/YuiCompressor.html
222
- - html/YuiCompressor/Yui.html
223
- - html/created.rid
224
- - html/css/fonts.css
225
- - html/css/rdoc.css
226
- - html/fonts/Lato-Light.ttf
227
- - html/fonts/Lato-LightItalic.ttf
228
- - html/fonts/Lato-Regular.ttf
229
- - html/fonts/Lato-RegularItalic.ttf
230
- - html/fonts/SourceCodePro-Bold.ttf
231
- - html/fonts/SourceCodePro-Regular.ttf
232
- - html/images/add.png
233
- - html/images/arrow_up.png
234
- - html/images/brick.png
235
- - html/images/brick_link.png
236
- - html/images/bug.png
237
- - html/images/bullet_black.png
238
- - html/images/bullet_toggle_minus.png
239
- - html/images/bullet_toggle_plus.png
240
- - html/images/date.png
241
- - html/images/delete.png
242
- - html/images/find.png
243
- - html/images/loadingAnimation.gif
244
- - html/images/macFFBgHack.png
245
- - html/images/package.png
246
- - html/images/page_green.png
247
- - html/images/page_white_text.png
248
- - html/images/page_white_width.png
249
- - html/images/plugin.png
250
- - html/images/ruby.png
251
- - html/images/tag_blue.png
252
- - html/images/tag_green.png
253
- - html/images/transparent.png
254
- - html/images/wrench.png
255
- - html/images/wrench_orange.png
256
- - html/images/zoom.png
257
- - html/index.html
258
- - html/js/darkfish.js
259
- - html/js/navigation.js
260
- - html/js/navigation.js.gz
261
- - html/js/search.js
262
- - html/js/search_index.js
263
- - html/js/search_index.js.gz
264
- - html/js/searcher.js
265
- - html/js/searcher.js.gz
266
- - html/table_of_contents.html
267
207
  - images/preferences.jpg
268
208
  - lib/conductor.rb
269
209
  - lib/conductor/array.rb
@@ -280,7 +220,6 @@ files:
280
220
  - lib/conductor/yui-compressor.rb
281
221
  - marked-conductor.gemspec
282
222
  - src/_README.md
283
- - test.md
284
223
  - test.sh
285
224
  homepage: https://github.com/ttscoff/marked-conductor
286
225
  licenses:
data/html/Array.html DELETED
@@ -1,160 +0,0 @@
1
- <!DOCTYPE html>
2
-
3
- <html>
4
- <head>
5
- <meta charset="UTF-8">
6
-
7
- <title>class Array - 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="Object.html">Object</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 ><a href="#method-i-symbolize_keys">#symbolize_keys</a>
76
- <li ><a href="#method-i-symbolize_keys-21">#symbolize_keys!</a>
77
- </ul>
78
- </div>
79
-
80
- </div>
81
- </nav>
82
-
83
- <main role="main" aria-labelledby="class-Array">
84
- <h1 id="class-Array" class="class">
85
- class Array
86
- </h1>
87
-
88
- <section class="description">
89
-
90
- </section>
91
-
92
- <section id="5Buntitled-5D" class="documentation-section">
93
-
94
-
95
-
96
-
97
-
98
- <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
99
- <header>
100
- <h3>Public Instance Methods</h3>
101
- </header>
102
-
103
- <div id="method-i-symbolize_keys" class="method-detail ">
104
- <div class="method-header">
105
- <div class="method-heading">
106
- <span class="method-name">symbolize_keys</span><span
107
- class="method-args">()</span>
108
- <span class="method-click-advice">click to toggle source</span>
109
- </div>
110
- </div>
111
-
112
- <div class="method-description">
113
-
114
-
115
- <div class="method-source-code" id="symbolize_keys-source">
116
- <pre><span class="ruby-comment"># File lib/conductor/array.rb, line 8</span>
117
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">symbolize_keys</span>
118
- <span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">h</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>.<span class="ruby-identifier">symbolize_keys</span> }
119
- <span class="ruby-keyword">end</span></pre>
120
- </div>
121
- </div>
122
-
123
-
124
- </div>
125
-
126
- <div id="method-i-symbolize_keys-21" class="method-detail ">
127
- <div class="method-header">
128
- <div class="method-heading">
129
- <span class="method-name">symbolize_keys!</span><span
130
- class="method-args">()</span>
131
- <span class="method-click-advice">click to toggle source</span>
132
- </div>
133
- </div>
134
-
135
- <div class="method-description">
136
-
137
-
138
- <div class="method-source-code" id="symbolize_keys-21-source">
139
- <pre><span class="ruby-comment"># File lib/conductor/array.rb, line 4</span>
140
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">symbolize_keys!</span>
141
- <span class="ruby-identifier">replace</span> <span class="ruby-identifier">symbolize_keys</span>
142
- <span class="ruby-keyword">end</span></pre>
143
- </div>
144
- </div>
145
-
146
-
147
- </div>
148
-
149
- </section>
150
-
151
- </section>
152
- </main>
153
-
154
-
155
- <footer id="validator-badges" role="contentinfo">
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.7.0.
158
- <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
159
- </footer>
160
-