mdless 2.1.44 → 2.1.46
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 +4 -4
- data/lib/mdless/console.rb +286 -274
- data/lib/mdless/converter.rb +143 -141
- data/lib/mdless/tables.rb +17 -16
- data/lib/mdless/version.rb +1 -1
- metadata +2 -2
data/lib/mdless/converter.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "fileutils"
|
2
|
+
require "yaml"
|
3
3
|
|
4
4
|
module CLIMarkdown
|
5
5
|
class Converter
|
@@ -17,37 +17,37 @@ module CLIMarkdown
|
|
17
17
|
MDLess.log.level = Logger::WARN
|
18
18
|
|
19
19
|
MDLess.options = {}
|
20
|
-
config = File.expand_path(
|
20
|
+
config = File.expand_path("~/.config/mdless/config.yml")
|
21
21
|
MDLess.options = YAML.load(IO.read(config)) if File.exist?(config)
|
22
22
|
|
23
23
|
optparse = OptionParser.new do |opts|
|
24
24
|
opts.banner = "#{version} by Brett Terpstra\n\n> Usage: #{CLIMarkdown::EXECUTABLE_NAME} [options] [path]\n\n"
|
25
25
|
|
26
26
|
default(:color, true)
|
27
|
-
opts.on(
|
27
|
+
opts.on("-c", "--[no-]color", "Colorize output (default on)") do |c|
|
28
28
|
MDLess.options[:color] = c
|
29
29
|
end
|
30
30
|
|
31
|
-
opts.on(
|
31
|
+
opts.on("-d", "--debug LEVEL", "Level of debug messages to output (1-4, 4 to see all messages)") do |level|
|
32
32
|
if level.to_i.positive? && level.to_i < 5
|
33
33
|
MDLess.log.level = 5 - level.to_i
|
34
34
|
else
|
35
|
-
puts
|
35
|
+
puts "Error: Debug level out of range (1-4)"
|
36
36
|
Process.exit 1
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
opts.on(
|
40
|
+
opts.on("-h", "--help", "Display this screen") do
|
41
41
|
puts opts
|
42
42
|
exit
|
43
43
|
end
|
44
44
|
|
45
45
|
default(:local_images, false)
|
46
46
|
default(:remote_images, false)
|
47
|
-
opts.on(
|
48
|
-
|
49
|
-
|
50
|
-
if exec_available(
|
47
|
+
opts.on("-i", "--images=TYPE",
|
48
|
+
"Include [local|remote (both)|none] images in output" \
|
49
|
+
" (requires chafa or imgcat, default none).") do |type|
|
50
|
+
if exec_available("imgcat") || exec_available("chafa")
|
51
51
|
case type
|
52
52
|
when /^(r|b|a)/i
|
53
53
|
MDLess.options[:local_images] = true
|
@@ -59,38 +59,38 @@ module CLIMarkdown
|
|
59
59
|
MDLess.options[:remote_images] = false
|
60
60
|
end
|
61
61
|
else
|
62
|
-
MDLess.log.warn(
|
62
|
+
MDLess.log.warn("images turned on but imgcat/chafa not found")
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
opts.on(
|
67
|
-
|
68
|
-
if exec_available(
|
66
|
+
opts.on("-I", "--all-images", "Include local and remote images in output" \
|
67
|
+
" (requires imgcat or chafa)") do
|
68
|
+
if exec_available("imgcat") || exec_available("chafa") # && ENV['TERM_PROGRAM'] == 'iTerm.app'
|
69
69
|
MDLess.options[:local_images] = true
|
70
70
|
MDLess.options[:remote_images] = true
|
71
71
|
else
|
72
|
-
MDLess.log.warn(
|
72
|
+
MDLess.log.warn("images turned on but imgcat/chafa not found")
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
76
|
default(:list, false)
|
77
|
-
opts.on(
|
77
|
+
opts.on("-l", "--list", "List headers in document and exit") do
|
78
78
|
MDLess.options[:list] = true
|
79
79
|
end
|
80
80
|
|
81
81
|
default(:pager, true)
|
82
|
-
opts.on(
|
82
|
+
opts.on("-p", "--[no-]pager", "Formatted output to pager (default on)") do |p|
|
83
83
|
MDLess.options[:pager] = p
|
84
84
|
end
|
85
85
|
|
86
86
|
default(:pager, true)
|
87
|
-
opts.on(
|
87
|
+
opts.on("-P", "Disable pager (same as --no-pager)") do
|
88
88
|
MDLess.options[:pager] = false
|
89
89
|
end
|
90
90
|
|
91
91
|
default(:section, nil)
|
92
|
-
opts.on(
|
93
|
-
|
92
|
+
opts.on("-s", "--section=NUMBER[,NUMBER]",
|
93
|
+
"Output only a headline-based section of the input (numeric from --list or text match)") do |section|
|
94
94
|
sections = section.split(/ *, */).map(&:strip)
|
95
95
|
MDLess.options[:section] = sections.map do |sect|
|
96
96
|
if sect =~ /^\d+$/
|
@@ -101,23 +101,23 @@ module CLIMarkdown
|
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
|
-
default(:theme,
|
105
|
-
opts.on(
|
104
|
+
default(:theme, "default")
|
105
|
+
opts.on("-t", "--theme=THEME_NAME", "Specify an alternate color theme to load") do |theme|
|
106
106
|
MDLess.options[:theme] = theme
|
107
107
|
end
|
108
108
|
|
109
109
|
default(:at_tags, false)
|
110
|
-
opts.on(
|
110
|
+
opts.on("-@", "--[no-]at-tags", "Highlight @tags and values in the document") do |opt|
|
111
111
|
MDLess.options[:at_tags] = opt
|
112
112
|
end
|
113
113
|
|
114
|
-
opts.on(
|
114
|
+
opts.on("-v", "--version", "Display version number") do
|
115
115
|
puts version
|
116
116
|
exit
|
117
117
|
end
|
118
118
|
|
119
119
|
default(:width, 0)
|
120
|
-
opts.on(
|
120
|
+
opts.on("-w", "--width=COLUMNS", "Column width to format for (default: 0 -> terminal width)") do |columns|
|
121
121
|
columns = columns.to_i
|
122
122
|
cols = TTY::Screen.cols
|
123
123
|
MDLess.cols = columns > 2 ? columns - 2 : cols
|
@@ -129,119 +129,119 @@ module CLIMarkdown
|
|
129
129
|
MDLess.cols = TTY::Screen.cols - 2 if MDLess.cols.zero?
|
130
130
|
|
131
131
|
default(:autolink, true)
|
132
|
-
opts.on(
|
132
|
+
opts.on("--[no-]autolink", "Convert bare URLs and emails to <links>") do |p|
|
133
133
|
MDLess.options[:autolink] = p
|
134
134
|
end
|
135
135
|
|
136
|
-
opts.on(
|
137
|
-
raise
|
136
|
+
opts.on("--config", "Open the config file in default editor") do
|
137
|
+
raise "No $EDITOR defined" unless ENV["EDITOR"]
|
138
138
|
|
139
|
-
`#{ENV[
|
139
|
+
`#{ENV["EDITOR"]} '#{File.expand_path("~/.config/mdless/config.yml")}'`
|
140
140
|
end
|
141
141
|
|
142
|
-
opts.on(
|
143
|
-
changelog = File.join(File.dirname(__FILE__),
|
142
|
+
opts.on("--changes", "Open the changelog to see recent updates") do
|
143
|
+
changelog = File.join(File.dirname(__FILE__), "..", "..", "CHANGELOG.md")
|
144
144
|
system "mdless --linebreaks '#{changelog}'"
|
145
145
|
Process.exit 0
|
146
146
|
end
|
147
147
|
|
148
|
-
opts.on(
|
149
|
-
|
150
|
-
raise
|
148
|
+
opts.on("--edit-theme", "Open the default/specified theme in default editor, " \
|
149
|
+
"populating a new theme if needed. Use after --theme in the command.") do
|
150
|
+
raise "No $EDITOR defined" unless ENV["EDITOR"]
|
151
151
|
|
152
|
-
theme = MDLess.options[:theme] =~ /default/ ?
|
152
|
+
theme = MDLess.options[:theme] =~ /default/ ? "mdless" : MDLess.options[:theme]
|
153
153
|
theme = File.expand_path("~/.config/mdless/#{theme}.theme")
|
154
|
-
File.open(theme,
|
155
|
-
`#{ENV[
|
154
|
+
File.open(theme, "w") { |f| f.puts(YAML.dump(MDLess.theme)) } unless File.exist?(theme)
|
155
|
+
`#{ENV["EDITOR"]} '#{theme}'`
|
156
156
|
Process.exit 0
|
157
157
|
end
|
158
158
|
|
159
159
|
default(:inline_footnotes, false)
|
160
|
-
opts.on(
|
161
|
-
|
160
|
+
opts.on("--[no-]inline-footnotes",
|
161
|
+
"Display footnotes immediately after the paragraph that references them") do |p|
|
162
162
|
MDLess.options[:inline_footnotes] = p
|
163
163
|
end
|
164
164
|
|
165
165
|
default(:intra_emphasis, true)
|
166
|
-
opts.on(
|
166
|
+
opts.on("--[no-]intra-emphasis", "Parse emphasis inside of words (e.g. Mark_down_)") do |opt|
|
167
167
|
MDLess.options[:intra_emphasis] = opt
|
168
168
|
end
|
169
169
|
|
170
170
|
default(:lax_spacing, true)
|
171
|
-
opts.on(
|
171
|
+
opts.on("--[no-]lax-spacing", "Allow lax spacing") do |opt|
|
172
172
|
MDLess.options[:lax_spacing] = opt
|
173
173
|
end
|
174
174
|
|
175
175
|
default(:links, :inline)
|
176
|
-
opts.on(
|
177
|
-
|
176
|
+
opts.on("--links=FORMAT",
|
177
|
+
"Link style ([*inline, reference, paragraph]," \
|
178
178
|
' "paragraph" will position reference links after each paragraph)') do |fmt|
|
179
179
|
MDLess.options[:links] = case fmt
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
180
|
+
when /^:?r/i
|
181
|
+
:reference
|
182
|
+
when /^:?p/i
|
183
|
+
:paragraph
|
184
|
+
else
|
185
|
+
:inline
|
186
|
+
end
|
187
187
|
end
|
188
188
|
|
189
189
|
default(:preserve_linebreaks, true)
|
190
|
-
opts.on(
|
190
|
+
opts.on("--[no-]linebreaks", "Preserve line breaks") do |opt|
|
191
191
|
MDLess.options[:preserve_linebreaks] = opt
|
192
192
|
end
|
193
193
|
|
194
194
|
default(:mmd_metadata, true)
|
195
|
-
opts.on(
|
195
|
+
opts.on("--[no-]metadata", "Replace [%key] with values from metadata") do |opt|
|
196
196
|
MDLess.options[:mmd_metadata] = opt
|
197
197
|
end
|
198
198
|
|
199
199
|
default(:syntax_higlight, false)
|
200
|
-
opts.on(
|
200
|
+
opts.on("--[no-]syntax", "Syntax highlight code blocks") do |opt|
|
201
201
|
MDLess.options[:syntax_higlight] = opt
|
202
202
|
end
|
203
203
|
|
204
204
|
MDLess.options[:taskpaper] = if MDLess.options[:taskpaper]
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
opts.on(
|
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
|
216
|
+
opts.on("--taskpaper=OPTION", "Highlight TaskPaper format (true|false|auto)") do |tp|
|
217
217
|
MDLess.options[:taskpaper] = case tp
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
218
|
+
when /^[ty1]/
|
219
|
+
true
|
220
|
+
when /^a/
|
221
|
+
:auto
|
222
|
+
else
|
223
|
+
false
|
224
|
+
end
|
225
225
|
end
|
226
226
|
|
227
227
|
default(:transclude, true)
|
228
|
-
opts.on(
|
228
|
+
opts.on("--[no-]transclude", "Transclude documents with {{filename}} syntax") do |opt|
|
229
229
|
MDLess.options[:transclude] = opt
|
230
230
|
end
|
231
231
|
|
232
232
|
default(:update_config, false)
|
233
|
-
opts.on(
|
234
|
-
|
233
|
+
opts.on("--update-config", "--update_config",
|
234
|
+
"Update the configuration file with new keys and current command line options") do
|
235
235
|
MDLess.options[:update_config] = true
|
236
236
|
end
|
237
237
|
|
238
238
|
default(:update_theme, false)
|
239
|
-
opts.on(
|
239
|
+
opts.on("--update-theme", "Update the current theme file with all available keys") do
|
240
240
|
MDLess.options[:update_theme] = true
|
241
241
|
end
|
242
242
|
|
243
243
|
default(:wiki_links, false)
|
244
|
-
opts.on(
|
244
|
+
opts.on("--[no-]wiki-links", "Highlight [[wiki links]]") do |opt|
|
245
245
|
MDLess.options[:wiki_links] = opt
|
246
246
|
end
|
247
247
|
end
|
@@ -256,17 +256,17 @@ module CLIMarkdown
|
|
256
256
|
if MDLess.options[:update_theme]
|
257
257
|
FileUtils.mkdir_p(File.dirname(config))
|
258
258
|
|
259
|
-
theme = MDLess.options[:theme] =~ /default/ ?
|
259
|
+
theme = MDLess.options[:theme] =~ /default/ ? "mdless" : MDLess.options[:theme]
|
260
260
|
theme = File.join(File.dirname(config), "#{theme}.theme")
|
261
261
|
contents = YAML.dump(MDLess.theme)
|
262
262
|
|
263
|
-
File.open(theme,
|
263
|
+
File.open(theme, "w") { |f| f.puts contents }
|
264
264
|
Process.exit 0
|
265
265
|
end
|
266
266
|
|
267
267
|
if !File.exist?(config) || MDLess.options[:update_config]
|
268
268
|
FileUtils.mkdir_p(File.dirname(config))
|
269
|
-
File.open(config,
|
269
|
+
File.open(config, "w") do |f|
|
270
270
|
opts = MDLess.options.dup
|
271
271
|
opts.delete(:list)
|
272
272
|
opts.delete(:section)
|
@@ -279,10 +279,10 @@ module CLIMarkdown
|
|
279
279
|
end
|
280
280
|
end
|
281
281
|
|
282
|
-
@output =
|
282
|
+
@output = ""
|
283
283
|
@setheaders = []
|
284
284
|
|
285
|
-
input =
|
285
|
+
input = ""
|
286
286
|
@ref_links = {}
|
287
287
|
@footnotes = {}
|
288
288
|
|
@@ -314,30 +314,30 @@ module CLIMarkdown
|
|
314
314
|
MDLess.file = file
|
315
315
|
|
316
316
|
begin
|
317
|
-
input = IO.read(file).force_encoding(
|
317
|
+
input = IO.read(file).force_encoding("utf-8")
|
318
318
|
rescue StandardError
|
319
319
|
input = IO.read(file)
|
320
320
|
end
|
321
|
-
raise
|
321
|
+
raise "Nil input" if input.nil?
|
322
322
|
|
323
323
|
input.scrub!
|
324
324
|
input.gsub!(/\r?\n/, "\n")
|
325
325
|
@headers = headers(input)
|
326
326
|
if MDLess.options[:taskpaper] == :auto
|
327
327
|
MDLess.options[:taskpaper] = if CLIMarkdown::TaskPaper.is_taskpaper?(input)
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
328
|
+
MDLess.log.info("TaskPaper detected")
|
329
|
+
true
|
330
|
+
else
|
331
|
+
false
|
332
|
+
end
|
333
333
|
end
|
334
334
|
|
335
335
|
if MDLess.options[:list]
|
336
336
|
@output << if MDLess.options[:taskpaper]
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
337
|
+
CLIMarkdown::TaskPaper.list_projects(input)
|
338
|
+
else
|
339
|
+
list_headers(input)
|
340
|
+
end
|
341
341
|
elsif MDLess.options[:taskpaper]
|
342
342
|
input = input.color_meta(MDLess.cols)
|
343
343
|
input = CLIMarkdown::TaskPaper.highlight(input)
|
@@ -360,11 +360,11 @@ module CLIMarkdown
|
|
360
360
|
|
361
361
|
if MDLess.options[:taskpaper] == :auto
|
362
362
|
MDLess.options[:taskpaper] = if CLIMarkdown::TaskPaper.is_taskpaper?(input)
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
363
|
+
MDLess.log.info("TaskPaper detected")
|
364
|
+
true
|
365
|
+
else
|
366
|
+
false
|
367
|
+
end
|
368
368
|
end
|
369
369
|
@headers = headers(input)
|
370
370
|
|
@@ -387,7 +387,7 @@ module CLIMarkdown
|
|
387
387
|
end
|
388
388
|
printout
|
389
389
|
else
|
390
|
-
warn
|
390
|
+
warn "No input"
|
391
391
|
Process.exit 1
|
392
392
|
end
|
393
393
|
end
|
@@ -437,9 +437,9 @@ module CLIMarkdown
|
|
437
437
|
title = h[2]
|
438
438
|
end
|
439
439
|
hs << [
|
440
|
-
|
440
|
+
"#" * hlevel,
|
441
441
|
title,
|
442
|
-
h[0]
|
442
|
+
h[0],
|
443
443
|
]
|
444
444
|
end
|
445
445
|
|
@@ -451,7 +451,7 @@ module CLIMarkdown
|
|
451
451
|
input.gsub!(/^(#+)/) do
|
452
452
|
m = Regexp.last_match
|
453
453
|
new_level = m[1].length - h_adjust
|
454
|
-
new_level.positive? ?
|
454
|
+
new_level.positive? ? "#" * new_level : ""
|
455
455
|
end
|
456
456
|
|
457
457
|
last_level = 0
|
@@ -466,21 +466,21 @@ module CLIMarkdown
|
|
466
466
|
last_level = level
|
467
467
|
|
468
468
|
subdoc = case level
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
469
|
+
when 0
|
470
|
+
""
|
471
|
+
when 1
|
472
|
+
"- "
|
473
|
+
when 2
|
474
|
+
"+ "
|
475
|
+
when 3
|
476
|
+
"* "
|
477
|
+
else
|
478
|
+
" "
|
479
|
+
end
|
480
480
|
headers_out.push format("%<c>s%<d>#{len}d: %<s>s",
|
481
481
|
c: c(%i[magenta]),
|
482
482
|
d: idx + 1,
|
483
|
-
s: "#{c(%i[x black])}#{
|
483
|
+
s: "#{c(%i[x black])}#{"." * level}#{c(%i[x yellow])}#{subdoc}#{title.strip}#{xc}")
|
484
484
|
end
|
485
485
|
|
486
486
|
headers_out.join("\n#{xc}")
|
@@ -496,30 +496,32 @@ module CLIMarkdown
|
|
496
496
|
input.gsub!(/^(\e\[[\d;]+m)?[%~] ?/, '\1')
|
497
497
|
# input.gsub!(/^(\e\[[\d;]+m)*>(\e\[[\d;]+m)?( +)/, ' \3\1\2')
|
498
498
|
# input.gsub!(/^(\e\[[\d;]+m)*>(\e\[[\d;]+m)?/, '\1\2')
|
499
|
-
input.gsub!(/(\e\[[\d;]+m)?@@@(\e\[[\d;]+m)?$/,
|
499
|
+
input.gsub!(/(\e\[[\d;]+m)?@@@(\e\[[\d;]+m)?$/, "")
|
500
500
|
input
|
501
501
|
end
|
502
502
|
|
503
503
|
def clean_escapes(input)
|
504
|
-
out = input.gsub(/\e\[m/,
|
505
|
-
last_escape =
|
504
|
+
out = input.gsub(/\e\[m/, "")
|
505
|
+
last_escape = ""
|
506
506
|
out.gsub!(/\e\[(?:(?:(?:[349]|10)[0-9]|[0-9])?;?)+m/) do |m|
|
507
507
|
if m == last_escape
|
508
|
-
|
508
|
+
""
|
509
509
|
else
|
510
510
|
last_escape = m
|
511
511
|
m
|
512
512
|
end
|
513
513
|
end
|
514
|
-
out.gsub(/\e\[0m/,
|
514
|
+
out.gsub(/\e\[0m/, "")
|
515
515
|
end
|
516
516
|
|
517
517
|
def update_inline_links(input)
|
518
518
|
links = {}
|
519
519
|
counter = 1
|
520
|
-
input.gsub!(/(?<=\])\((.*?)\)/) do
|
520
|
+
input.gsub!(/(?<=\])\((.*?)\)(#{CLIMarkdown::MDTableCleanup::PAD_CHAR}*)/) do
|
521
|
+
pp "***#{CLIMarkdown::MDTableCleanup::PAD_CHAR}***"
|
521
522
|
links[counter] = Regexp.last_match(1).uncolor
|
522
|
-
|
523
|
+
space = Regexp.last_match(2)
|
524
|
+
"[#{counter}]#{space}"
|
523
525
|
end
|
524
526
|
end
|
525
527
|
|
@@ -534,16 +536,16 @@ module CLIMarkdown
|
|
534
536
|
end
|
535
537
|
end
|
536
538
|
|
537
|
-
def pad_max(block, eol=
|
539
|
+
def pad_max(block, eol = "")
|
538
540
|
block.split(/\n/).map do |l|
|
539
|
-
new_code_line = l.gsub(/\t/,
|
541
|
+
new_code_line = l.gsub(/\t/, " ")
|
540
542
|
orig_length = new_code_line.size + 8 + eol.size
|
541
543
|
pad_count = [MDLess.cols - orig_length, 0].max
|
542
544
|
|
543
545
|
[
|
544
546
|
new_code_line,
|
545
547
|
eol,
|
546
|
-
|
548
|
+
" " * [pad_count - 1, 0].max,
|
547
549
|
].join
|
548
550
|
end.join("\n")
|
549
551
|
end
|
@@ -562,9 +564,9 @@ module CLIMarkdown
|
|
562
564
|
IO.select [input]
|
563
565
|
|
564
566
|
pager = which_pager
|
565
|
-
MDLess.log.info("Using `#{pager.join(
|
567
|
+
MDLess.log.info("Using `#{pager.join(" ")}` as pager")
|
566
568
|
begin
|
567
|
-
exec(pager.join(
|
569
|
+
exec(pager.join(" "))
|
568
570
|
rescue SystemCallError => e
|
569
571
|
MDLess.log.error(e)
|
570
572
|
exit 1
|
@@ -597,7 +599,7 @@ module CLIMarkdown
|
|
597
599
|
# end
|
598
600
|
|
599
601
|
unless out.size&.positive?
|
600
|
-
MDLess.log.warn
|
602
|
+
MDLess.log.warn "No results"
|
601
603
|
Process.exit
|
602
604
|
end
|
603
605
|
|
@@ -616,14 +618,14 @@ module CLIMarkdown
|
|
616
618
|
|
617
619
|
def which_pager
|
618
620
|
# pagers = [ENV['PAGER'], ENV['GIT_PAGER']]
|
619
|
-
pagers = ENV[
|
621
|
+
pagers = ENV["PAGER"] ? [ENV["PAGER"]] : []
|
620
622
|
|
621
623
|
# if exec_available('git')
|
622
624
|
# git_pager = `git config --get-all core.pager || true`.split.first
|
623
625
|
# git_pager && pagers.push(git_pager)
|
624
626
|
# end
|
625
627
|
|
626
|
-
pagers.concat([
|
628
|
+
pagers.concat(["less", "more", "cat", "pager"])
|
627
629
|
|
628
630
|
pagers.delete_if { |pg| !TTY::Which.exist?(pg) }
|
629
631
|
|
@@ -631,8 +633,8 @@ module CLIMarkdown
|
|
631
633
|
pg = f.split(/[ ]/)[0]
|
632
634
|
return false unless pg
|
633
635
|
|
634
|
-
if pg ==
|
635
|
-
MDLess.log.warn(
|
636
|
+
if pg == "most"
|
637
|
+
MDLess.log.warn("most not allowed as pager")
|
636
638
|
false
|
637
639
|
else
|
638
640
|
TTY::Which.which(pg)
|
@@ -641,15 +643,15 @@ module CLIMarkdown
|
|
641
643
|
|
642
644
|
pg = pagers.first
|
643
645
|
args = case pg
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
646
|
+
# when 'delta'
|
647
|
+
# ' --pager="less -FXr"'
|
648
|
+
when "less"
|
649
|
+
"-FXr"
|
650
|
+
# when 'bat'
|
651
|
+
# ' -p --pager="less -FXr"'
|
652
|
+
else
|
653
|
+
""
|
654
|
+
end
|
653
655
|
|
654
656
|
[pg, args]
|
655
657
|
end
|