mdless 1.0.26 → 1.0.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -3
- data/lib/mdless/converter.rb +27 -26
- 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: 379923deb11ea6811d911e3bc0f1ddacbdc6bbb22ee736997e2bbab70fdb2406
|
4
|
+
data.tar.gz: 7fcafa17a1fc67a956a96f8d78ebb29df1b3d5e265ee5265cbd09155894b82c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06e5f6aa1559b74e033f64bd7837ee0a60822e54f8f635214fdddeaf39f24a22374c694789f01eba42e854861af00ddac76b789ecc442a0693edf02d888a5fd5
|
7
|
+
data.tar.gz: ae01fc4be978252f20be52a42b687d248755a908fd9701d218ce40ae27b7e3b9ded398023b3e4fed2a706532d326bd4bb8ef6c4f62b741761f6d7a5788a517fd
|
data/README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
# mdless
|
2
2
|
|
3
|
+
<!--README-->
|
3
4
|
`mdless` is a utility that provides a formatted and highlighted view of Markdown files in Terminal.
|
4
5
|
|
5
6
|
I often use iTerm2 in visor mode, so `qlmanage -p` is annoying. I still wanted a way to view Markdown files quickly and without cruft.
|
6
7
|
|
7
|
-
|
8
|
+
<!--GITHUB-->![mdless screenshot](screenshots/mdless.png)<!--END GITHUB-->
|
9
|
+
<!--JEKYLL {% gif /uploads/2015/08/mdless.gif %} -->
|
8
10
|
|
9
11
|
## Features
|
10
12
|
|
@@ -34,7 +36,7 @@ Some OSs are missing `tput`, which is necessary for mdless.
|
|
34
36
|
apt install ruby ncurses-utils
|
35
37
|
gem install mdless
|
36
38
|
|
37
|
-
## Usage
|
39
|
+
## Usage
|
38
40
|
|
39
41
|
`mdless [options] path` or `cat [path] | mdless`
|
40
42
|
|
@@ -112,4 +114,4 @@ Use 'r' to reverse foreground and background colors. `r white on_black` would di
|
|
112
114
|
To set a background color, use `on_[color]` with one of the 8 colors. This can be used with foreground colors in the same setting, e.g. `white on_black`.
|
113
115
|
|
114
116
|
Use 'd' (dark) to indicate the darker version of a foreground color. On macOS (and possibly other systems) you can use the brighter version of a color by prefixing with "intense", e.g. `intense_red` or `on_intense_black`.
|
115
|
-
|
117
|
+
<!--END README-->
|
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
|
|
@@ -1010,12 +1009,12 @@ module CLIMarkdown
|
|
1010
1009
|
if @options[:pager]
|
1011
1010
|
page(out)
|
1012
1011
|
else
|
1013
|
-
$stdout.
|
1012
|
+
$stdout.print (out.rstrip)
|
1014
1013
|
end
|
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'
|
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.30
|
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-08-02 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
|