mdless 2.1.8 → 2.1.9

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: 0f08302d14bfa27b06fd821e56f46b6a04049009df87ab024c368e7776209810
4
- data.tar.gz: c14bd96efedeaa61eba790a1f2e2664df39f85839ad914ffccfe323ef3312ee5
3
+ metadata.gz: 7b6335a8f0eb1e43af37924810a1e8e6b94f5b2da35b745824f3ce735536777d
4
+ data.tar.gz: 54643d669cfef096d92405e4b1ed2a216c749a67c3fb2f03dc32ad91e7a5f98a
5
5
  SHA512:
6
- metadata.gz: 633007f423725e003e3c7154262801738bf22b79485d09b99caf06a83486fdca50a0e8b91f7d9a4118dd43c2bd0404cccc31a55486a8db00500e82a95007edeb
7
- data.tar.gz: 870af2c74618556db8a6621016f9cc603f424956adda3441f0e8043f661bb2fac22b7c6f0e1aaa655570b0d7234e2d6e12c625d5a8af89599f2061db42e622ec
6
+ metadata.gz: 8a3d3fc7ee471da0cd3b882deba060a19728492a2493c06cca461029ce7d664940e8e0f602a324c71ede7d8e0b617365e7375cb4702cd7b19a91d440fda32a24
7
+ data.tar.gz: be3fc65aca571dcc96af250f8bc0faf0e5c8be3a7ed1a2b30229fd5fd501e6087a8990bcc43f5d8f60b21599167833f55381a759a54e7765a3be4db729e16de4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ 2.1.9
2
+ : Code block prefix configurable, can be left empty to make more copyable code blocks
3
+ : Remove empty lines from block quotes
4
+ : Infinite loop when calculating ANSI emphasis
5
+ : Don't accept colors or semicolons inside of @tag names
6
+
1
7
  2.1.8
2
8
  : --update-theme option to add any missing keys to your theme file
3
9
  : Strip ul_char of any spaces before inserting
data/lib/mdless/colors.rb CHANGED
@@ -92,6 +92,7 @@ module CLIMarkdown
92
92
  bg = nil
93
93
  rgbb = c
94
94
  else
95
+ em = []
95
96
  c.split(/;/).each do |i|
96
97
  x = i.to_i
97
98
  if x <= 9
@@ -113,10 +114,13 @@ module CLIMarkdown
113
114
  end
114
115
  end
115
116
 
116
- escape = "\e[#{em.join(';')}m"
117
+ escape = ''
118
+ escape += "\e[#{em.join(';')}m" unless em.empty?
117
119
  escape += "\e[#{rgbb}m" if rgbb
118
120
  escape += "\e[#{rgbf}m" if rgbf
119
- escape + "\e[#{[fg, bg].delete_if(&:nil?).join(';')}m"
121
+ fg_bg = [fg, bg].delete_if(&:nil?).join(';')
122
+ escape += "\e[#{fg_bg}m" unless fg_bg.empty?
123
+ escape
120
124
  end
121
125
 
122
126
  def blackout(bgcolor)
@@ -133,25 +137,23 @@ module CLIMarkdown
133
137
  self.uncolor.size
134
138
  end
135
139
 
136
- def wrap(width=78,foreground=:x)
137
- if self.uncolor =~ /(^([%~] |\s*>)| +[=\-]{5,})/
138
- return self
139
- end
140
+ def wrap(width=78, foreground=:x)
141
+ return self if uncolor =~ /(^([%~] |\s*>)| +[=-]{5,})/
140
142
 
141
143
  visible_width = 0
142
144
  lines = []
143
145
  line = ''
144
146
  last_ansi = ''
145
147
 
146
- line += self.match(/^\s*/)[0].gsub(/\t/,' ')
147
- input = self.dup # .gsub(/(\w-)(\w)/,'\1 \2')
148
+ line += match(/^\s*/)[0].gsub(/\t/, ' ')
149
+ input = dup # .gsub(/(\w-)(\w)/,'\1 \2')
148
150
  # input.gsub!(/\[.*?\]\(.*?\)/) do |link|
149
151
  # link.gsub(/ /, "\u00A0")
150
152
  # end
151
153
  input.split(/\s+/).each do |word|
152
- last_ansi = line.scan(/\e\[[\d;]+m/)[-1] || ''
154
+ last_ansi = line.last_color_code
153
155
  if visible_width + word.size_clean >= width
154
- lines << line + xc(foreground)
156
+ lines << line + xc
155
157
  visible_width = word.size_clean
156
158
  line = last_ansi + word
157
159
  elsif line.empty?
@@ -162,7 +164,7 @@ module CLIMarkdown
162
164
  line << ' ' << last_ansi + word
163
165
  end
164
166
  end
165
- lines << line + match(/\s*$/)[0] + xc(foreground) if line
167
+ lines << line + match(/\s*$/)[0] + xc if line
166
168
  lines.map!.with_index do |l, i|
167
169
  (i.positive? ? l[i - 1].last_color_code : '') + l
168
170
  end
@@ -97,8 +97,8 @@ module Redcarpet
97
97
  hilite = xc + hilite.split(/\n/).map do |l|
98
98
  [
99
99
  color('code_block marker'),
100
- '> ',
101
- "#{color('code_block bg')}#{l.strip}#{xc}"
100
+ MDLess.theme['code_block']['character'],
101
+ "#{color('code_block bg')}#{l.rstrip}#{xc}"
102
102
  ].join
103
103
  end.join("\n").blackout(MDLess.theme['code_block']['bg']) + "#{xc}\n"
104
104
  end
@@ -110,7 +110,7 @@ module Redcarpet
110
110
  hilite = code_block.split(/\n/).map do |line|
111
111
  [
112
112
  color('code_block marker'),
113
- '> ',
113
+ MDLess.theme['code_block']['character'],
114
114
  color('code_block color'),
115
115
  line,
116
116
  xc
@@ -172,7 +172,7 @@ module Redcarpet
172
172
 
173
173
  def block_quote(quote)
174
174
  ret = "\n\n"
175
- quote.wrap(MDLess.cols, color('blockquote color')).split(/\n/).each do |line|
175
+ quote.strip.wrap(MDLess.cols, color('blockquote color')).split(/\n/).each do |line|
176
176
  ret += [
177
177
  color('blockquote marker color'),
178
178
  MDLess.theme['blockquote']['marker']['character'],
@@ -941,7 +941,7 @@ module Redcarpet
941
941
  def highlight_tags(input)
942
942
  tag_color = color('at_tags tag')
943
943
  value_color = color('at_tags value')
944
- input.gsub(/(?<pre>\s|m)(?<tag>@[^ \].?!,("']+)(?:(?<lparen>\()(?<value>.*?)(?<rparen>\)))?/) do
944
+ input.gsub(/(?<pre>\s|m)(?<tag>@[^ \]:;.?!,("'\n]+)(?:(?<lparen>\()(?<value>.*?)(?<rparen>\)))?/) do
945
945
  m = Regexp.last_match
946
946
  last_color = m.pre_match.last_color_code
947
947
  [
data/lib/mdless/string.rb CHANGED
@@ -107,7 +107,7 @@ class ::String
107
107
  log = MDLess.log
108
108
  tag_color = color('at_tags tag')
109
109
  value_color = color('at_tags value')
110
- gsub(/(?<pre>\s|m)(?<tag>@[^ \].?!,("'\n]+)(?:(?<lparen>\()(?<value>.*?)(?<rparen>\)))?/) do
110
+ gsub(/(?<pre>\s|m)(?<tag>@[^ \]:;.?!,("'\n]+)(?:(?<lparen>\()(?<value>.*?)(?<rparen>\)))?(?=[ ;!,.?]|$)/) do
111
111
  m = Regexp.last_match
112
112
  last_color = m.pre_match.last_color_code
113
113
  [
data/lib/mdless/theme.rb CHANGED
@@ -66,6 +66,7 @@ module CLIMarkdown
66
66
  },
67
67
  'code_block' => {
68
68
  'marker' => 'intense_black',
69
+ 'character' => '>',
69
70
  'bg' => 'on_black',
70
71
  'color' => 'white on_black',
71
72
  'border' => 'blue',
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CLIMarkdown
4
- VERSION = '2.1.8'
4
+ VERSION = '2.1.9'
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.8
4
+ version: 2.1.9
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-01 00:00:00.000000000 Z
11
+ date: 2023-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redcarpet