mdless 2.1.27 → 2.1.29

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: e2ff8e5c411b2dca9194b32e684495ee5a43376da035e427365c7c8c305abc3d
4
- data.tar.gz: 7de7a979e5aeeb61cb92d3e0dfd1166aec6ac63f446422592a3a005cd6ec8755
3
+ metadata.gz: 1e5c2be4377b1bad77f8c7f3e0ab932a16ca9339332c91e3bc5f0b7db8c71df2
4
+ data.tar.gz: f540f256c1117dab4a9ef0e758f940d3f79a848abe2f15f5b2866e5f2e052656
5
5
  SHA512:
6
- metadata.gz: 0b458218411a7a4952652aa807c2b98cb2ea298b3f3051b4743acf1afb670c914b690e7ce97e5185cb0a86c83bdf2b3c552d7b2d8075454324ce39fef9629f9c
7
- data.tar.gz: d44ebccb7cb2230713c7250e0dcc904961b0f7b9f0fd2f146cbaa24ca7580a748e4282dd23c8e367f6d1bb5176c4c0efa08457cc7bde02481b66c5db722bdde9
6
+ metadata.gz: b52a6501909c93927e508419298a767aeb759c661b45c877feb33b72caa9f512146ab5fc67a41530666328e5e37ebc53bf25979b0340ee50666433e85f2df920
7
+ data.tar.gz: da7f8a1949c56474461847ca9b66fccc1dea888552976b2e00b3dea12a250ba3c28cc70bf2496a1293171c4c17300779f68c228ff24ddf9068ff08046492db6e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  2.1.26
2
2
 
3
+ 2.1.29
4
+ : More code cleanup, help output improvements
5
+ : Line breaks in help output
6
+ : This release should fix an error on Ruby 2.7 in string.rb
7
+
8
+ 2.1.28
9
+ : Default to 0 width, which makes the width the column width of the terminal
10
+ : Don't save a --width setting to config, require that to be manually updated if desired
11
+
3
12
  2.1.27
4
13
  : Error handling when YAML can't be processed
5
14
 
data/bin/mdless CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby -W1
1
+ #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'mdless'
@@ -45,7 +45,8 @@ module CLIMarkdown
45
45
  default(:local_images, false)
46
46
  default(:remote_images, false)
47
47
  opts.on('-i', '--images=TYPE',
48
- 'Include [local|remote (both)|none] images in output (requires chafa or imgcat, default none).') do |type|
48
+ 'Include [local|remote (both)|none] images in output'\
49
+ ' (requires chafa or imgcat, default none).') do |type|
49
50
  if exec_available('imgcat') || exec_available('chafa')
50
51
  case type
51
52
  when /^(r|b|a)/i
@@ -62,7 +63,8 @@ module CLIMarkdown
62
63
  end
63
64
  end
64
65
 
65
- opts.on('-I', '--all-images', 'Include local and remote images in output (requires imgcat or chafa)') do
66
+ opts.on('-I', '--all-images', 'Include local and remote images in output'\
67
+ ' (requires imgcat or chafa)') do
66
68
  if exec_available('imgcat') || exec_available('chafa') # && ENV['TERM_PROGRAM'] == 'iTerm.app'
67
69
  MDLess.options[:local_images] = true
68
70
  MDLess.options[:remote_images] = true
@@ -114,13 +116,18 @@ module CLIMarkdown
114
116
  exit
115
117
  end
116
118
 
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
119
+ default(:width, 0)
120
+ opts.on('-w', '--width=COLUMNS', 'Column width to format for (default: 0 -> terminal width)') do |columns|
121
+ columns = columns.to_i
120
122
  cols = TTY::Screen.cols
121
- MDLess.options[:width] = cols if MDLess.options[:width] > cols
123
+ MDLess.cols = columns > 2 ? columns - 2 : cols
124
+
125
+ MDLess.options[:width] = columns > cols ? cols - 2 : columns - 2
122
126
  end
123
127
 
128
+ MDLess.cols = MDLess.options[:width]
129
+ MDLess.cols = TTY::Screen.cols - 2 if MDLess.cols.zero?
130
+
124
131
  default(:autolink, true)
125
132
  opts.on('--[no-]autolink', 'Convert bare URLs and emails to <links>') do |p|
126
133
  MDLess.options[:autolink] = p
@@ -138,8 +145,9 @@ module CLIMarkdown
138
145
  Process.exit 0
139
146
  end
140
147
 
141
- opts.on('--edit-theme', ["Open the default or specified theme file in #{ENV['EDITOR'] || 'default editor'}. ",
142
- "If theme doesn't exist, a new theme file will be populated and opened."].join) do
148
+ opts.on('--edit-theme', 'Open the default/specified theme in ' \
149
+ "#{File.basename(ENV['EDITOR']) || 'default editor'}, "\
150
+ 'populating a new theme if needed. Use after --theme in the command.') do
143
151
  raise 'No $EDITOR defined' unless ENV['EDITOR']
144
152
 
145
153
  theme = MDLess.options[:theme] =~ /default/ ? 'mdless' : MDLess.options[:theme]
@@ -150,7 +158,7 @@ module CLIMarkdown
150
158
  end
151
159
 
152
160
  default(:inline_footnotes, false)
153
- opts.on('--[no-]inline_footnotes',
161
+ opts.on('--[no-]inline-footnotes',
154
162
  'Display footnotes immediately after the paragraph that references them') do |p|
155
163
  MDLess.options[:inline_footnotes] = p
156
164
  end
@@ -167,8 +175,8 @@ module CLIMarkdown
167
175
 
168
176
  default(:links, :inline)
169
177
  opts.on('--links=FORMAT',
170
- 'Link style ([inline, reference, paragraph], default inline,
171
- "paragraph" will position reference links after each paragraph)') do |fmt|
178
+ 'Link style ([*inline, reference, paragraph],'\
179
+ ' "paragraph" will position reference links after each paragraph)') do |fmt|
172
180
  MDLess.options[:links] = case fmt
173
181
  when /^:?r/i
174
182
  :reference
@@ -195,26 +203,26 @@ module CLIMarkdown
195
203
  end
196
204
 
197
205
  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
206
+ case MDLess.options[:taskpaper].to_s
207
+ when /^[ty1]/
208
+ true
209
+ when /^a/
210
+ :auto
211
+ else
212
+ false
213
+ end
214
+ else
215
+ false
216
+ end
209
217
  opts.on('--taskpaper=OPTION', 'Highlight TaskPaper format (true|false|auto)') do |tp|
210
218
  MDLess.options[:taskpaper] = case tp
211
- when /^[ty1]/
212
- true
213
- when /^a/
214
- :auto
215
- else
216
- false
217
- end
219
+ when /^[ty1]/
220
+ true
221
+ when /^a/
222
+ :auto
223
+ else
224
+ false
225
+ end
218
226
  end
219
227
 
220
228
  default(:transclude, true)
@@ -223,7 +231,8 @@ module CLIMarkdown
223
231
  end
224
232
 
225
233
  default(:update_config, false)
226
- opts.on('--update-config', '--update_config', 'Update the configuration file with new keys and current command line options') do
234
+ opts.on('--update-config', '--update_config',
235
+ 'Update the configuration file with new keys and current command line options') do
227
236
  MDLess.options[:update_config] = true
228
237
  end
229
238
 
@@ -264,15 +273,13 @@ module CLIMarkdown
264
273
  opts.delete(:section)
265
274
  opts.delete(:update_config)
266
275
  opts.delete(:update_theme)
267
- opts.delete(:width)
276
+ opts[:width] = 0
268
277
  opts = opts.keys.map(&:to_s).sort.map { |k| [k.to_sym, opts[k.to_sym]] }.to_h
269
278
  f.puts YAML.dump(opts)
270
279
  warn "Config file saved to #{config}"
271
280
  end
272
281
  end
273
282
 
274
- MDLess.cols = MDLess.options[:width] - 2
275
-
276
283
  @output = ''
277
284
  @headers = []
278
285
  @setheaders = []
data/lib/mdless/string.rb CHANGED
@@ -67,7 +67,7 @@ class ::String
67
67
  input.sub!(/(?i-m)^---[ \t]*\n(?<content>[\s\S]*?)\n[-.]{3}[ \t]*\n/m) do
68
68
  m = Regexp.last_match
69
69
  MDLess.log.info('Processing YAML Header')
70
- MDLess.meta = YAML.load(m['content']).map { |k, v| "#{k.downcase}" => v }
70
+ YAML.load(m['content']).map { |k, v| MDLess.meta[k.downcase] = v }
71
71
  lines = m['content'].split(/\n/)
72
72
  longest = lines.inject { |memo, word| memo.length > word.length ? memo : word }.length
73
73
  longest = longest < @cols ? longest + 1 : @cols
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CLIMarkdown
4
- VERSION = '2.1.27'
4
+ VERSION = '2.1.29'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mdless
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.27
4
+ version: 2.1.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-05 00:00:00.000000000 Z
11
+ date: 2023-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redcarpet
@@ -158,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
158
  - !ruby/object:Gem::Version
159
159
  version: '0'
160
160
  requirements: []
161
- rubygems_version: 3.2.16
161
+ rubygems_version: 3.4.0.dev
162
162
  signing_key:
163
163
  specification_version: 4
164
164
  summary: A pager like less, but for Markdown files