mdless 2.1.6 → 2.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b310c064653d3fce972b3c3e91a134b9549d7595787ed9bd57efb8486780cbc5
4
- data.tar.gz: 5379beea590a35d1a9fa8b034d008d3552d07b6fc1e3f56592ee9e38ae5a1b8d
3
+ metadata.gz: 3a7d200fbf2d90da97cf6ae65beecac52643ec377d2a60f7d8503ca2411694ea
4
+ data.tar.gz: f35b88bdf439f3436ddf2e6cf0b835e8a23d5d5553721b0c35d75954af43013e
5
5
  SHA512:
6
- metadata.gz: 42cbc5c4366b3a7914f07409fcaf322741d3def2f23c578b956d1cad4683b905e9b02af7523bfd68988627feaaa314c6c772ada0f56b2b99b493838ec319a547
7
- data.tar.gz: 15615f5222dae1e812a9cf252b7ba730a11ad06e19aac9397236768a4d396cd57ea307da0a0678ab5f2e3f5ceeea2b6f02a8de628b2cf168099165b8af787c72
6
+ metadata.gz: 906870b0032f1cba0a1c90be6ac2cb80f82c1abcb331470f75b02598d05d965996b2d2eb0a076b2651e32e9ae567334b693a9dffd702b517e15c5b8048f2e172
7
+ data.tar.gz: e1874c241362b44607a357ec4e125bdc463ae3b3ab906bdf7237e1b782a6122b6f90d664210cf7dd1b964bf843adb1056adbacdd93b816f0bb31db4d92ad1cf5
data/CHANGELOG.md CHANGED
@@ -1,14 +1,9 @@
1
- 2.1.6
2
- : In addition to color names, you can now use 3 or 6-digit hex codes, prefix with "bg" or "on_" to affect background color
3
- : Better highlighting of h1/h2 when header contains a link
4
- : List items with multiple paragraphs incorrectly highlighted
1
+ 2.1.7
2
+ : Dedup and remove empty escape codes before output
3
+ : Tables losing column alignment
4
+ : Unneccessarily long table cells
5
5
 
6
- 2.1.5
7
- : In addition to color names, you can now use 3 or 6-digit hex codes, prefix with "bg" or "on_" to affect background color
8
- : Better highlighting of h1/h2 when header contains a link
9
- : List items with multiple paragraphs incorrectly highlighted
10
-
11
- 2.1.4
6
+ 2.1.6
12
7
  : In addition to color names, you can now use 3 or 6-digit hex codes, prefix with "bg" or "on_" to affect background color
13
8
  : Better highlighting of h1/h2 when header contains a link
14
9
  : List items with multiple paragraphs incorrectly highlighted
data/lib/mdless/colors.rb CHANGED
@@ -58,6 +58,10 @@ module CLIMarkdown
58
58
  self.unpad.gsub(/\e\[[\d;]+m/,'')
59
59
  end
60
60
 
61
+ def remove_pre_post
62
+ gsub(/<<(pre|post)\d+>>/, '')
63
+ end
64
+
61
65
  def unpad
62
66
  self.gsub(/\u00A0/, ' ')
63
67
  end
@@ -155,10 +159,13 @@ module CLIMarkdown
155
159
  line = last_ansi + word
156
160
  else
157
161
  visible_width += word.size_clean + 1
158
- line << " " << last_ansi + word
162
+ line << ' ' << last_ansi + word
159
163
  end
160
164
  end
161
165
  lines << line + match(/\s*$/)[0] + xc(foreground) if line
166
+ lines.map!.with_index do |l, i|
167
+ (i.positive? ? l[i - 1].last_color_code : '') + l
168
+ end
162
169
  lines.join("\n").gsub(/\[.*?\]\(.*?\)/) do |link|
163
170
  link.gsub(/\u00A0/, ' ')
164
171
  end
@@ -263,13 +263,13 @@ module Redcarpet
263
263
  end
264
264
 
265
265
  def table(header, body)
266
- @header_row = []
267
266
  formatted = CLIMarkdown::MDTableCleanup.new([
268
267
  "#{header}",
269
268
  table_header_row,
270
269
  "|\n",
271
270
  "#{body}\n\n"
272
271
  ].join(''))
272
+ @header_row = []
273
273
  res = formatted.to_md
274
274
  "#{color_table(res)}\n\n"
275
275
  # res
@@ -555,7 +555,8 @@ module Redcarpet
555
555
  [
556
556
  indent,
557
557
  color('list bullet'),
558
- "* ",
558
+ MDLess.theme['list']['ul_char'],
559
+ ' ',
559
560
  color('list color'),
560
561
  indent_lines(content, indent).strip,
561
562
  xc
@@ -460,6 +460,20 @@ module CLIMarkdown
460
460
  input
461
461
  end
462
462
 
463
+ def clean_escapes(input)
464
+ out = input.gsub(/\e\[m/, '')
465
+ last_escape = ''
466
+ out.gsub!(/\e\[(?:(?:(?:[349]|10)[0-9]|[0-9])?;?)+m/) do |m|
467
+ if m == last_escape
468
+ ''
469
+ else
470
+ last_escape = m
471
+ m
472
+ end
473
+ end
474
+ out.gsub(/\e\[0m/, '')
475
+ end
476
+
463
477
  def update_inline_links(input)
464
478
  links = {}
465
479
  counter = 1
@@ -544,6 +558,7 @@ module CLIMarkdown
544
558
  end
545
559
 
546
560
  out = clean_markers(out)
561
+ out = clean_escapes(out)
547
562
  out = "#{out.gsub(/\n{2,}/m, "\n\n")}#{xc}"
548
563
 
549
564
  out.uncolor! unless MDLess.options[:color]
data/lib/mdless/tables.rb CHANGED
@@ -72,7 +72,7 @@ module CLIMarkdown
72
72
 
73
73
  table.each do |row|
74
74
  @format_row.each_with_index do |_, i|
75
- length = row[i].strip.length
75
+ length = row[i].uncolor.remove_pre_post.strip.length
76
76
  @widths[i] = length if length > @widths[i]
77
77
  end
78
78
  end
data/lib/mdless/theme.rb CHANGED
@@ -48,6 +48,7 @@ module CLIMarkdown
48
48
  'url' => 'u yellow'
49
49
  },
50
50
  'list' => {
51
+ 'ul_char' => '*',
51
52
  'bullet' => 'b intense_red',
52
53
  'number' => 'b intense_blue',
53
54
  'color' => 'intense_white'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CLIMarkdown
4
- VERSION = '2.1.6'
4
+ VERSION = '2.1.7'
5
5
  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: 2.1.6
4
+ version: 2.1.7
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-30 00:00:00.000000000 Z
11
+ date: 2023-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redcarpet