mdless 2.0.7 → 2.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mdless/console.rb +14 -9
- data/lib/mdless/converter.rb +6 -2
- data/lib/mdless/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef90f38be64fdcd4e3666782b957ac2a27ec4346103fa79a1760626977051a8f
|
4
|
+
data.tar.gz: 856113d17ab7217c28de2f2c2405acd185e99cdc4ca0370fbb73053371babab1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f291d6eef35c904afc13adecc673db8736b002e556fc55f311cae6721685868f709cc285cf2a2906657933a05f385ce5168190e8672f16a672b8dd41f3bb7d1c
|
7
|
+
data.tar.gz: 75c67e0498a10ff7c26d2b9f9d43808174826807369650b33918ba0b63342cfaf1ae359530f957db2b9c403026918783d3411a291f92b732e6a2921efccd15b0
|
data/lib/mdless/console.rb
CHANGED
@@ -349,9 +349,9 @@ module Redcarpet
|
|
349
349
|
end
|
350
350
|
elsif exec_available('chafa')
|
351
351
|
@log.info('Using chafa for image rendering')
|
352
|
-
term = '
|
353
|
-
term = ENV['
|
354
|
-
term = ENV['
|
352
|
+
term = ''
|
353
|
+
term = ENV['TERM_PROGRAM'] =~ /iterm/i ? '-f iterm' : term
|
354
|
+
term = ENV['TERM_PROGRAM'] =~ /kitty/i ? '-f kitty' : term
|
355
355
|
FileUtils.rm_r '.mdless_tmp', force: true if File.directory?('.mdless_tmp')
|
356
356
|
Dir.mkdir('.mdless_tmp')
|
357
357
|
Dir.chdir('.mdless_tmp')
|
@@ -377,11 +377,13 @@ module Redcarpet
|
|
377
377
|
pre = !alt_text.nil? ? " #{c(%i[d blue])}[#{alt_text.strip}]\n" : ''
|
378
378
|
post = !title.nil? ? "\n #{c(%i[b blue])}-- #{title} --" : ''
|
379
379
|
if exec_available('imgcat')
|
380
|
-
img = `imgcat "#{img_path}"`
|
380
|
+
img = `imgcat -p "#{img_path}"`
|
381
|
+
@log.info("Rendering image with `imgcat -p #{img_path}`")
|
381
382
|
elsif exec_available('chafa')
|
382
|
-
term = '
|
383
|
-
term = ENV['
|
384
|
-
term = ENV['
|
383
|
+
term = ''
|
384
|
+
term = ENV['TERM_PROGRAM'] =~ /iterm/i ? '-f iterm' : term
|
385
|
+
term = ENV['TERM_PROGRAM'] =~ /kitty/i ? '-f kitty' : term
|
386
|
+
@log.info("Rendering image with `chafa #{term} #{img_path}`")
|
385
387
|
img = `chafa #{term} "#{img_path}"`
|
386
388
|
end
|
387
389
|
result = pre + img + post
|
@@ -572,7 +574,8 @@ module Redcarpet
|
|
572
574
|
|
573
575
|
def preprocess(input)
|
574
576
|
in_yaml = false
|
575
|
-
|
577
|
+
first_line = input.split("\n").first
|
578
|
+
if first_line =~ /(?i-m)^---[ \t]*?$/
|
576
579
|
@log.info('Found YAML')
|
577
580
|
# YAML
|
578
581
|
in_yaml = true
|
@@ -596,10 +599,12 @@ module Redcarpet
|
|
596
599
|
end
|
597
600
|
end
|
598
601
|
|
599
|
-
if !in_yaml &&
|
602
|
+
if !in_yaml && first_line =~ /(?i-m)^[\w ]+:\s+\S+/
|
600
603
|
@log.info('Found MMD Headers')
|
601
604
|
input.sub!(/(?i-m)^([\S ]+:[\s\S]*?)+(?=\n\n)/) do |mmd|
|
602
605
|
lines = mmd.split(/\n/)
|
606
|
+
return mmd if lines.count > 20
|
607
|
+
|
603
608
|
longest = lines.inject { |memo, word| memo.length > word.length ? memo : word }.length
|
604
609
|
longest = longest < @cols ? longest + 1 : @cols
|
605
610
|
lines.map do |line|
|
data/lib/mdless/converter.rb
CHANGED
@@ -47,11 +47,15 @@ module CLIMarkdown
|
|
47
47
|
opts.on('-i', '--images=TYPE',
|
48
48
|
'Include [local|remote (both)] images in output (requires chafa or imgcat, default NONE).') do |type|
|
49
49
|
if exec_available('imgcat') || exec_available('chafa')
|
50
|
-
|
50
|
+
case type
|
51
|
+
when /^(r|b|a)/i
|
51
52
|
@options[:local_images] = true
|
52
53
|
@options[:remote_images] = true
|
53
|
-
|
54
|
+
when /^l/i
|
54
55
|
@options[:local_images] = true
|
56
|
+
when /^n/
|
57
|
+
@options[:local_images] = false
|
58
|
+
@options[:remote_images] = false
|
55
59
|
end
|
56
60
|
else
|
57
61
|
@log.warn('images turned on but imgcat/chafa not found')
|
data/lib/mdless/version.rb
CHANGED
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.0.
|
4
|
+
version: 2.0.8
|
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-11-
|
11
|
+
date: 2023-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redcarpet
|