mdless 1.0.27 → 1.0.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: 155e4a600259101069f5c7fa7a2c142a31ad0a6b7ea12a3185bf4f5477ae0e09
4
- data.tar.gz: b19dadf9f8ae825f22aeeab2ba1b2044d0e3830d27ecd7a98aab6fa966c3488c
3
+ metadata.gz: a69b03a6efd774409146752f36c9afecc2cb2c3efa5f2359138400b269f6eb44
4
+ data.tar.gz: 855a0a8c4d71e2ff946324768d335c8403dd94d70c52a55a661e5c37c835e1ab
5
5
  SHA512:
6
- metadata.gz: da901c9f4224ff23bf23dc71163db735ea1e4ac6a997b5f4d61f61124cea2809468a98e8035264733a68ec4c5d4f3b21711901a4eef8e77464c58e1694089561
7
- data.tar.gz: ddd59266c9f67885ad271cc89effa782ddd1f47fdcc201d0d7194e0bfb23a01ea00c4f88073c3fadebdff94b0a9e1fbf9b29500c1cc5f2935aa5a58fd2920c7c
6
+ metadata.gz: fdb73be6939bf9584c0dc4c2615b2df1cfe020d8a6596d84351ac8caff9c2e94a9baa63ea73f69b200fe473f157c209d9409db767bb224d2c0c7da68970324f7
7
+ data.tar.gz: 839937da5fc9ef1343d777303f86ed9db2ffd23356c3c743ca90d5af1d8cea41bd3c3f98ada940882faa1fedb930f4e4bf8c9850e6ef20700b83bd931906addf
@@ -811,8 +811,8 @@ module CLIMarkdown
811
811
  end
812
812
 
813
813
  # misc html
814
- line.gsub!(/<br\/?>/, "\n")
815
- line.gsub!(/(?i-m)((<\/?)(\w+[\s\S]*?)(>))/) do |tag|
814
+ line.gsub!(%r{<br/?>}, "\n")
815
+ line.gsub!(%r{(?i-m)((</?)(\w+[\s\S]*?)(>))}) do
816
816
  match = Regexp.last_match
817
817
  last = find_color(match.pre_match)
818
818
  [
@@ -822,12 +822,12 @@ module CLIMarkdown
822
822
  match[3],
823
823
  color('html brackets'),
824
824
  match[4],
825
- last ? last : xc
825
+ last || xc
826
826
  ].join
827
827
  end
828
828
 
829
829
  # inline code spans
830
- line.gsub!(/`(.*?)`/) do |m|
830
+ line.gsub!(/`(.*?)`/) do
831
831
  match = Regexp.last_match
832
832
  last = find_color(match.pre_match, true)
833
833
  [
@@ -837,7 +837,7 @@ module CLIMarkdown
837
837
  match[1],
838
838
  color('code_span marker'),
839
839
  '`',
840
- last ? last : xc
840
+ last || xc
841
841
  ].join
842
842
  end
843
843
  end
@@ -853,7 +853,7 @@ module CLIMarkdown
853
853
  input = lines.join("\n")
854
854
 
855
855
  # images
856
- input.gsub!(/^(.*?)!\[(.*)?\]\((.*?\.(?:png|gif|jpg))( +.*)?\)/) do |m|
856
+ input.gsub!(/^(.*?)!\[(.*)?\]\((.*?\.(?:png|gif|jpg))( +.*)?\)/) do
857
857
  match = Regexp.last_match
858
858
  if match[1].uncolor =~ /^( {4,}|\t)+/
859
859
  match[0]
@@ -893,23 +893,23 @@ module CLIMarkdown
893
893
  @log.error(e)
894
894
  end
895
895
  else
896
- @log.warn("No viewer for remote images")
896
+ @log.warn('No viewer for remote images')
897
897
  end
898
898
  end
899
899
  else
900
- if img_path =~ /^[~\/]/
900
+ if img_path =~ %r{^[~/]}
901
901
  img_path = File.expand_path(img_path)
902
902
  elsif @file
903
903
  base = File.expand_path(File.dirname(@file))
904
- img_path = File.join(base,img_path)
904
+ img_path = File.join(base, img_path)
905
905
  end
906
- if File.exists?(img_path)
907
- pre = match[2].size > 0 ? " #{c(%i[d blue])}[#{match[2].strip}]\n" : ''
908
- post = tail.size > 0 ? "\n #{c(%i[b blue])}-- #{tail} --" : ''
906
+ if File.exist?(img_path)
907
+ pre = !match[2].empty? ? " #{c(%i[d blue])}[#{match[2].strip}]\n" : ''
908
+ post = !tail.empty? ? "\n #{c(%i[b blue])}-- #{tail} --" : ''
909
909
  if exec_available('chafa')
910
- img = %x{chafa "#{img_path}"}
910
+ img = `chafa "#{img_path}"`
911
911
  elsif exec_available('imgcat')
912
- img = %x{imgcat "#{img_path}"}
912
+ img = `imgcat "#{img_path}"`
913
913
  end
914
914
  result = pre + img + post
915
915
  end
@@ -924,32 +924,31 @@ module CLIMarkdown
924
924
  end
925
925
  end
926
926
 
927
- @footnotes.each {|t, v|
927
+ @footnotes.each do |t, v|
928
928
  input += [
929
929
  "\n\n",
930
930
  color('footnote brackets'),
931
- "[",
931
+ '[',
932
932
  color('footnote caret'),
933
- "^",
933
+ '^',
934
934
  color('footnote title'),
935
935
  t,
936
936
  color('footnote brackets'),
937
- "]: ",
937
+ ']: ',
938
938
  color('footnote note'),
939
939
  v,
940
940
  xc
941
941
  ].join
942
- }
942
+ end
943
943
 
944
944
  @output += input
945
-
946
945
  end
947
946
 
948
947
  def exec_available(cli)
949
- if File.exists?(File.expand_path(cli))
948
+ if File.exist?(File.expand_path(cli))
950
949
  File.executable?(File.expand_path(cli))
951
950
  else
952
- system "which #{cli}", :out => File::NULL, :err => File::NULL
951
+ system "which #{cli}", out: File::NULL, err: File::NULL
953
952
  end
954
953
  end
955
954
 
@@ -967,7 +966,7 @@ module CLIMarkdown
967
966
  IO.select [input]
968
967
 
969
968
  pager = which_pager
970
- @log.info(%{Using #{pager} as pager})
969
+ @log.info("Using #{pager} as pager")
971
970
  begin
972
971
  exec(pager.join(' '))
973
972
  rescue SystemCallError => e
@@ -980,7 +979,7 @@ module CLIMarkdown
980
979
  read_io.close
981
980
  write_io.write(text)
982
981
  write_io.close
983
- rescue SystemCallError => e
982
+ rescue SystemCallError
984
983
  exit 1
985
984
  end
986
985
 
@@ -1015,7 +1014,7 @@ module CLIMarkdown
1015
1014
  end
1016
1015
 
1017
1016
  def which_pager
1018
- pagers = [ENV['GIT_PAGER'], ENV['PAGER']]
1017
+ pagers = [ENV['PAGER'], ENV['GIT_PAGER']]
1019
1018
 
1020
1019
  if exec_available('git')
1021
1020
  git_pager = `git config --get-all core.pager || true`.split.first
@@ -1041,6 +1040,8 @@ module CLIMarkdown
1041
1040
 
1042
1041
  pg = pagers.first
1043
1042
  args = case pg
1043
+ when 'delta'
1044
+ ' --pager="less -Xr"'
1044
1045
  when 'more'
1045
1046
  ' -r'
1046
1047
  when 'less'
@@ -1051,6 +1052,8 @@ module CLIMarkdown
1051
1052
  ''
1052
1053
  end
1053
1054
 
1055
+ puts [pg, args]
1056
+
1054
1057
  [pg, args]
1055
1058
  end
1056
1059
 
@@ -1,3 +1,3 @@
1
1
  module CLIMarkdown
2
- VERSION = '1.0.27'
2
+ VERSION = '1.0.28'
3
3
  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: 1.0.27
4
+ version: 1.0.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-19 00:00:00.000000000 Z
11
+ date: 2022-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -28,22 +28,16 @@ dependencies:
28
28
  name: rdoc
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '4.1'
34
31
  - - ">="
35
32
  - !ruby/object:Gem::Version
36
- version: 4.1.1
33
+ version: 6.3.1
37
34
  type: :development
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
- - - "~>"
42
- - !ruby/object:Gem::Version
43
- version: '4.1'
44
38
  - - ">="
45
39
  - !ruby/object:Gem::Version
46
- version: 4.1.1
40
+ version: 6.3.1
47
41
  description: A CLI that provides a formatted and highlighted view of Markdown files
48
42
  in a terminal
49
43
  email: me@brettterpstra.com