mdless 2.1.10 → 2.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/mdless/colors.rb +4 -2
- data/lib/mdless/console.rb +67 -30
- data/lib/mdless/converter.rb +2 -2
- data/lib/mdless/version.rb +1 -1
- data/lib/mdless.rb +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e103adb25eb7f60ff660cae6071863165cc8248d0d22a2aa673c240bc470f680
|
4
|
+
data.tar.gz: 4ec87e6815250971fbd3b536776137be756ccf324fac5dda2abac16ca786fb22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d45d4d1c865a9c00bc710739cf208c300c7e421ccc785d633715fe7350af81928fe79b28effe050be39cba6c33f4c64f472424e4c103c9e5225bd8dfd1b85fba
|
7
|
+
data.tar.gz: 29062adc822df60367956d417fb5e9851c03d149e81aec7cb439e3e8586c55fe9df5733d8774f587b8acae4ea91ebfff246b91734ea26473bd2f43859261228d
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
2.1.11
|
2
|
+
: Better regex for highlighting raw HTML
|
3
|
+
: Indentation in highlighted code blocks
|
4
|
+
: HTML Tag highlighting breaking pre/post color conversion
|
5
|
+
|
1
6
|
2.1.10
|
2
7
|
: Spinner while processing to indicate working
|
3
8
|
: Image links can now be converted to reference format, with correct coloring
|
data/lib/mdless/colors.rb
CHANGED
@@ -150,9 +150,11 @@ module CLIMarkdown
|
|
150
150
|
# input.gsub!(/\[.*?\]\(.*?\)/) do |link|
|
151
151
|
# link.gsub(/ /, "\u00A0")
|
152
152
|
# end
|
153
|
-
input.split(/\s
|
153
|
+
input.split(/\s/).each do |word|
|
154
154
|
last_ansi = line.last_color_code
|
155
|
-
if
|
155
|
+
if word =~ /[\s\t]/
|
156
|
+
line << word
|
157
|
+
elsif visible_width + word.size_clean >= width
|
156
158
|
lines << line + xc
|
157
159
|
visible_width = word.size_clean
|
158
160
|
line = last_ansi + word
|
data/lib/mdless/console.rb
CHANGED
@@ -66,14 +66,41 @@ module Redcarpet
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def hilite_code(code_block, language)
|
69
|
+
longest_line = code_block.uncolor.split(/\n/).longest_element.length + 4
|
70
|
+
longest_line = longest_line > MDLess.cols ? MDLess.cols : longest_line
|
71
|
+
|
72
|
+
# if MDLess.options[:syntax_higlight]
|
73
|
+
# formatter = Rouge::Formatters::Terminal256
|
74
|
+
# lexer = if language
|
75
|
+
# Object.const_get("Rouge::Lexers::#{language.capitalize}") rescue Rouge::Lexer.guess(source: code_block)
|
76
|
+
# else
|
77
|
+
# Rouge::Lexer.guess(source: code_block)
|
78
|
+
# end
|
79
|
+
# hilite = formatter.format(lexer.lex(code_block))
|
80
|
+
# hilite = xc + hilite.split(/\n/).map do |l|
|
81
|
+
# [
|
82
|
+
# color('code_block marker'),
|
83
|
+
# MDLess.theme['code_block']['character'],
|
84
|
+
# "#{color('code_block bg')}#{l.rstrip}#{xc}"
|
85
|
+
# ].join
|
86
|
+
# end.join("\n").blackout(MDLess.theme['code_block']['bg']) + "#{xc}\n"
|
87
|
+
# else
|
88
|
+
# hilite = code_block.split(/\n/).map do |line|
|
89
|
+
# [
|
90
|
+
# color('code_block marker'),
|
91
|
+
# MDLess.theme['code_block']['character'],
|
92
|
+
# color('code_block color'),
|
93
|
+
# line,
|
94
|
+
# xc
|
95
|
+
# ].join
|
96
|
+
# end.join("\n").blackout(MDLess.theme['code_block']['bg']) + "#{xc}\n"
|
97
|
+
# end
|
98
|
+
|
69
99
|
if MDLess.options[:syntax_higlight] && !exec_available('pygmentize')
|
70
100
|
MDLess.log.error('Syntax highlighting requested by pygmentize is not available')
|
71
101
|
MDLess.options[:syntax_higlight] = false
|
72
102
|
end
|
73
103
|
|
74
|
-
longest_line = code_block.uncolor.split(/\n/).longest_element.length + 4
|
75
|
-
longest_line = longest_line > MDLess.cols ? MDLess.cols : longest_line
|
76
|
-
|
77
104
|
if MDLess.options[:syntax_higlight]
|
78
105
|
pyg = TTY::Which.which('pygmentize')
|
79
106
|
lexer = language&.valid_lexer? ? "-l #{language}" : '-g'
|
@@ -93,15 +120,17 @@ module Redcarpet
|
|
93
120
|
].join(' ')
|
94
121
|
hilite, s = Open3.capture2(cmd,
|
95
122
|
stdin_data: code_block)
|
123
|
+
|
96
124
|
if s.success?
|
97
125
|
hilite = xc + hilite.split(/\n/).map do |l|
|
98
126
|
[
|
99
127
|
color('code_block marker'),
|
100
128
|
MDLess.theme['code_block']['character'],
|
101
|
-
"#{color('code_block bg')}#{l
|
129
|
+
"#{color('code_block bg')}#{l}#{xc}"
|
102
130
|
].join
|
103
131
|
end.join("\n").blackout(MDLess.theme['code_block']['bg']) + "#{xc}\n"
|
104
132
|
end
|
133
|
+
|
105
134
|
rescue StandardError => e
|
106
135
|
MDLess.log.error(e)
|
107
136
|
hilite = code_block
|
@@ -123,7 +152,6 @@ module Redcarpet
|
|
123
152
|
else
|
124
153
|
"--[ #{language} ]#{'-' * (longest_line - 6 - language.length)}"
|
125
154
|
end
|
126
|
-
|
127
155
|
[
|
128
156
|
xc,
|
129
157
|
color('code_block border'),
|
@@ -234,10 +262,15 @@ module Redcarpet
|
|
234
262
|
end
|
235
263
|
|
236
264
|
def paragraph(text)
|
237
|
-
if MDLess.options[:preserve_linebreaks]
|
238
|
-
|
265
|
+
out = if MDLess.options[:preserve_linebreaks]
|
266
|
+
"#{xc}#{text.gsub(/ +/, ' ').strip}#{xc}#{x}\n\n"
|
267
|
+
else
|
268
|
+
"#{xc}#{text.gsub(/ +/, ' ').gsub(/\n+(?![:-])/, ' ').strip}#{xc}#{x}\n\n"
|
269
|
+
end
|
270
|
+
if MDLess.options[:at_tags] || MDLess.options[:taskpaper]
|
271
|
+
highlight_tags(out)
|
239
272
|
else
|
240
|
-
|
273
|
+
out
|
241
274
|
end
|
242
275
|
end
|
243
276
|
|
@@ -481,7 +514,7 @@ module Redcarpet
|
|
481
514
|
end
|
482
515
|
|
483
516
|
def color_tags(html)
|
484
|
-
html.gsub(%r{(
|
517
|
+
html.gsub(%r{((?!<)</?\w+( [^>]+)?>)}, "#{color('html brackets')}\\1#{xc}")
|
485
518
|
end
|
486
519
|
|
487
520
|
def raw_html(raw_html)
|
@@ -580,26 +613,31 @@ module Redcarpet
|
|
580
613
|
end
|
581
614
|
|
582
615
|
def color_list_item(indent, content, type, counter)
|
583
|
-
case type
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
616
|
+
out = case type
|
617
|
+
when :unordered
|
618
|
+
[
|
619
|
+
indent,
|
620
|
+
color('list bullet'),
|
621
|
+
MDLess.theme['list']['ul_char'].strip,
|
622
|
+
' ',
|
623
|
+
color('list color'),
|
624
|
+
indent_lines(content, indent).strip,
|
625
|
+
xc
|
626
|
+
].join
|
627
|
+
when :ordered
|
628
|
+
[
|
629
|
+
indent,
|
630
|
+
color('list number'),
|
631
|
+
"#{counter}. ",
|
632
|
+
color('list color'),
|
633
|
+
indent_lines(content, indent).strip,
|
634
|
+
xc
|
635
|
+
].join
|
636
|
+
end
|
637
|
+
if MDLess.options[:at_tags] || MDLess.options[:taskpaper]
|
638
|
+
color_tags(out)
|
639
|
+
else
|
640
|
+
out
|
603
641
|
end
|
604
642
|
end
|
605
643
|
|
@@ -1035,7 +1073,6 @@ module Redcarpet
|
|
1035
1073
|
input = reference_links(input) if MDLess.options[:links] == :reference || MDLess.options[:links] == :paragraph
|
1036
1074
|
# lists
|
1037
1075
|
input = fix_lists(input)
|
1038
|
-
input = highlight_tags(input) if MDLess.options[:at_tags] || MDLess.options[:taskpaper]
|
1039
1076
|
fix_colors(input)
|
1040
1077
|
end
|
1041
1078
|
end
|
data/lib/mdless/converter.rb
CHANGED
@@ -105,8 +105,8 @@ module CLIMarkdown
|
|
105
105
|
end
|
106
106
|
|
107
107
|
default(:at_tags, false)
|
108
|
-
opts.on('-@', '--
|
109
|
-
MDLess.options[:at_tags] =
|
108
|
+
opts.on('-@', '--[no-]at-tags', 'Highlight @tags and values in the document') do |opt|
|
109
|
+
MDLess.options[:at_tags] = opt
|
110
110
|
end
|
111
111
|
|
112
112
|
opts.on('-v', '--version', 'Display version number') do
|
data/lib/mdless/version.rb
CHANGED
data/lib/mdless.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.1.
|
4
|
+
version: 2.1.11
|
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-12-
|
11
|
+
date: 2023-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redcarpet
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0.8'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rouge
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '4.2'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '4.2'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rake
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|