mdless 1.0.25 → 1.0.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mdless/converter.rb +28 -25
- data/lib/mdless/version.rb +1 -1
- metadata +4 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a69b03a6efd774409146752f36c9afecc2cb2c3efa5f2359138400b269f6eb44
|
4
|
+
data.tar.gz: 855a0a8c4d71e2ff946324768d335c8403dd94d70c52a55a661e5c37c835e1ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdb73be6939bf9584c0dc4c2615b2df1cfe020d8a6596d84351ac8caff9c2e94a9baa63ea73f69b200fe473f157c209d9409db767bb224d2c0c7da68970324f7
|
7
|
+
data.tar.gz: 839937da5fc9ef1343d777303f86ed9db2ffd23356c3c743ca90d5af1d8cea41bd3c3f98ada940882faa1fedb930f4e4bf8c9850e6ef20700b83bd931906addf
|
data/lib/mdless/converter.rb
CHANGED
@@ -811,8 +811,8 @@ module CLIMarkdown
|
|
811
811
|
end
|
812
812
|
|
813
813
|
# misc html
|
814
|
-
line.gsub!(
|
815
|
-
line.gsub!(
|
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
|
825
|
+
last || xc
|
826
826
|
].join
|
827
827
|
end
|
828
828
|
|
829
829
|
# inline code spans
|
830
|
-
line.gsub!(/`(.*?)`/) do
|
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
|
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
|
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(
|
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.
|
907
|
-
pre = match[2].
|
908
|
-
post = 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 =
|
910
|
+
img = `chafa "#{img_path}"`
|
911
911
|
elsif exec_available('imgcat')
|
912
|
-
img =
|
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
|
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.
|
948
|
+
if File.exist?(File.expand_path(cli))
|
950
949
|
File.executable?(File.expand_path(cli))
|
951
950
|
else
|
952
|
-
system "which #{cli}", :
|
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(
|
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
|
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['
|
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
|
|
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: 1.0.
|
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:
|
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:
|
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:
|
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
|