mdless 2.1.26 → 2.1.28

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1fb1a921f8fba70376fd696f457190e28222c5c07419dd13aad328323f29622
4
- data.tar.gz: fb42bcba760484824b3ab6516206645890b8ddbe1274817894fc42780fac42fc
3
+ metadata.gz: 7be9ab30b8078d94b965d0f45094cd1b8e737210daaf1baa5030b54fac95c66a
4
+ data.tar.gz: aec7cf2e130cfd6d66b9482d417c1cb479e80c8e76c919f3b393524f68dc768d
5
5
  SHA512:
6
- metadata.gz: 4325d830a288a4ba59fe4810f350de7c0259ec54a6aade29b440f4d5a71d542cc4b99de1f453d5b6c0f0aba50c5dc833b2311180c1cf8f7865d3c5ca2a6fb419
7
- data.tar.gz: bbe50fdaa45cf08c2a77b19d3902ed82e72fde33b190b8fc62c98adbec96171b91f7f7d9aad213505ddcf7fa93c03603f4f7e8fcefffe5ee75084e58bce55263
6
+ metadata.gz: 66ebe7c5ee11c2266ecfb214058b71225c5842b81cf200e5c76854da9f0c3bdbd83fe34241a7dc7198b818203fb557cc0c4b4b642a95eb59e1190f7ae15d633d
7
+ data.tar.gz: 870ced12acb6fbbd687ea2159a7a88ac983e0fc058db27c367b6be626b778407a71a5b78c35e3775bbb08f6edc668821f02cf8826da46acef98df4ceb1abe41a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  2.1.26
2
2
 
3
+ 2.1.28
4
+ : Default to 0 width, which makes the width the column width of the terminal
5
+ : Don't save a --width setting to config, require that to be manually updated if desired
6
+
7
+ 2.1.27
8
+ : Error handling when YAML can't be processed
9
+
3
10
  2.1.25
4
11
  : YAML loading issues caused by safe_load
5
12
 
@@ -751,8 +751,17 @@ module Redcarpet
751
751
  in_yaml = true
752
752
  input.sub!(/(?i-m)^---[ \t]*\n(?<content>(?:[\s\S]*?))\n[-.]{3}[ \t]*\n/m) do
753
753
  m = Regexp.last_match
754
- MDLess.log.info('Processing YAML Header')
755
- MDLess.meta = YAML.load(m['content']).map { |k, v| "#{k.downcase}" => v }
754
+ MDLess.log.info('Processing YAML header')
755
+ begin
756
+ MDLess.meta = YAML.load(m['content']).map { |k, v| "#{k.downcase}" => v }
757
+ rescue Psych::DisallowedClass => e
758
+ @log.error('Error reading YAML header')
759
+ @log.error(e)
760
+ MDLess.meta = {}
761
+ rescue StandardError => e
762
+ @log.error("StandardError: #{e}")
763
+ end
764
+
756
765
  lines = m[0].split(/\n/)
757
766
  longest = lines.longest_element.length
758
767
  longest = longest < MDLess.cols ? longest + 1 : MDLess.cols
@@ -114,11 +114,18 @@ module CLIMarkdown
114
114
  exit
115
115
  end
116
116
 
117
- default(:width, TTY::Screen.cols)
118
- opts.on('-w', '--width=COLUMNS', 'Column width to format for (default: terminal width)') do |columns|
119
- MDLess.options[:width] = columns.to_i
117
+ default(:width, 0)
118
+ opts.on('-w', '--width=COLUMNS', 'Column width to format for (default: 0 -> terminal width)') do |columns|
119
+ columns = columns.to_i
120
120
  cols = TTY::Screen.cols
121
- MDLess.options[:width] = cols if MDLess.options[:width] > cols
121
+ MDLess.cols = columns > 2 ? columns - 2 : cols
122
+
123
+ MDLess.options[:width] = columns > cols ? cols - 2 : columns - 2
124
+ end
125
+
126
+ MDLess.cols = MDLess.options[:width]
127
+ if MDLess.cols == 0
128
+ MDLess.cols = TTY::Screen.cols - 2
122
129
  end
123
130
 
124
131
  default(:autolink, true)
@@ -195,26 +202,26 @@ module CLIMarkdown
195
202
  end
196
203
 
197
204
  MDLess.options[:taskpaper] = if MDLess.options[:taskpaper]
198
- case MDLess.options[:taskpaper].to_s
199
- when /^[ty1]/
200
- true
201
- when /^a/
202
- :auto
203
- else
204
- false
205
- end
206
- else
207
- false
208
- end
205
+ case MDLess.options[:taskpaper].to_s
206
+ when /^[ty1]/
207
+ true
208
+ when /^a/
209
+ :auto
210
+ else
211
+ false
212
+ end
213
+ else
214
+ false
215
+ end
209
216
  opts.on('--taskpaper=OPTION', 'Highlight TaskPaper format (true|false|auto)') do |tp|
210
217
  MDLess.options[:taskpaper] = case tp
211
- when /^[ty1]/
212
- true
213
- when /^a/
214
- :auto
215
- else
216
- false
217
- end
218
+ when /^[ty1]/
219
+ true
220
+ when /^a/
221
+ :auto
222
+ else
223
+ false
224
+ end
218
225
  end
219
226
 
220
227
  default(:transclude, true)
@@ -223,7 +230,8 @@ module CLIMarkdown
223
230
  end
224
231
 
225
232
  default(:update_config, false)
226
- opts.on('--update-config', '--update_config', 'Update the configuration file with new keys and current command line options') do
233
+ opts.on('--update-config', '--update_config',
234
+ 'Update the configuration file with new keys and current command line options') do
227
235
  MDLess.options[:update_config] = true
228
236
  end
229
237
 
@@ -264,15 +272,13 @@ module CLIMarkdown
264
272
  opts.delete(:section)
265
273
  opts.delete(:update_config)
266
274
  opts.delete(:update_theme)
267
- opts.delete(:width)
275
+ opts[:width] = 0
268
276
  opts = opts.keys.map(&:to_s).sort.map { |k| [k.to_sym, opts[k.to_sym]] }.to_h
269
277
  f.puts YAML.dump(opts)
270
278
  warn "Config file saved to #{config}"
271
279
  end
272
280
  end
273
281
 
274
- MDLess.cols = MDLess.options[:width] - 2
275
-
276
282
  @output = ''
277
283
  @headers = []
278
284
  @setheaders = []
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CLIMarkdown
4
- VERSION = '2.1.26'
4
+ VERSION = '2.1.28'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mdless
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.26
4
+ version: 2.1.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra