mdless 2.0.19 → 2.0.21

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: '094b8ac8273e025bee23c350cc7aee02682b2445d22523d216b4e621d067ff9b'
4
- data.tar.gz: 495dc941df5b4235c9bb5d7cccb37739e1cc783679d276d026d36a7a9dafc937
3
+ metadata.gz: 24d135c2a8c4e8591a7751cea47743a88c2c727f7f589200ea8c4058f3c60dca
4
+ data.tar.gz: 1ae18541f3fe42b5bea17fddf6a3f6865119c74a3ad71c103b25012adeffaf67
5
5
  SHA512:
6
- metadata.gz: f15d9fc92d6286708adc3060dfbc265a4064419eceecb25dfe4de3f7d60e1f033f7e2f157a34ef2940130ca1caea565e9fe43a2f5cab5f611c8f0d864830f54b
7
- data.tar.gz: 9db7cd9e9914bd37bc1a97362e27ef169d899f89fcae0e2e8004da3bd48cffe539518e61396e0f325953a5008adbbb8b37debcbabffdce1d08268a7b73b27f2c
6
+ metadata.gz: f719c51af95220cc95fe0d3ceb8ecd7669e039c08133d5306d8882c6ee8756e4afabc988fbce455b50aa8293f04c1bf396240922ceaa0bbe7152495ce67c0866
7
+ data.tar.gz: 00ca7d0cdc6c5b20651ad7d0e26f0b2d40630173036dda68247b9fc11f884f788522ccd5a029b6a8c661a549ae2589463d4df552fa3da72ac1d28dc279bf284c
@@ -229,7 +229,11 @@ module Redcarpet
229
229
  end
230
230
 
231
231
  def paragraph(text)
232
- "#{xc}#{text}#{xc}#{x}\n\n"
232
+ if MDLess.options[:preserve_linebreaks]
233
+ "#{xc}#{text.gsub(/ +/, ' ').strip}#{xc}#{x}\n\n"
234
+ else
235
+ "#{xc}#{text.gsub(/ +/, ' ').gsub(/\n+/, ' ').strip}#{xc}#{x}\n\n"
236
+ end
233
237
  end
234
238
 
235
239
  @table_cols = nil
@@ -250,6 +254,7 @@ module Redcarpet
250
254
  end
251
255
 
252
256
  def table(header, body)
257
+ @header_row = []
253
258
  formatted = CLIMarkdown::MDTableCleanup.new([
254
259
  "#{header}",
255
260
  table_header_row,
@@ -257,7 +262,7 @@ module Redcarpet
257
262
  "#{body}\n\n"
258
263
  ].join(''))
259
264
  res = formatted.to_md
260
- "#{color_table(res)}\n"
265
+ "#{color_table(res)}\n\n"
261
266
  # res
262
267
  end
263
268
 
@@ -426,7 +431,7 @@ module Redcarpet
426
431
  end
427
432
 
428
433
  def link(link, title, content)
429
- res = color_link(link, title, content)
434
+ res = color_link(link, title&.strip, content&.strip)
430
435
  @@links << {
431
436
  link: res,
432
437
  url: link,
@@ -580,7 +585,7 @@ module Redcarpet
580
585
  end.join("\n"), indent)
581
586
  next if list.nil?
582
587
 
583
- "<<main#{m['id']}>>#{list}<</main#{m['id']}>>"
588
+ "<<main#{m['id']}>>#{list}<</main#{m['id']}>>\n\n"
584
589
  end
585
590
 
586
591
  input.gsub(/^(?<indent> +)<<main(?<id>\d+)>>(?<content>.*?)<<\/main\k<id>>>/m) do
@@ -785,11 +790,11 @@ module Redcarpet
785
790
  links_added = false
786
791
 
787
792
  @@links.each do |link|
788
- if graf =~ /#{Regexp.escape(link[:link])}/
793
+ if graf =~ /#{Regexp.escape(link[:link].gsub(/\n/, ' '))}/
789
794
  url = link[:url].uncolor
790
795
  content = link[:content]
791
796
  title = link[:title]&.uncolor
792
- graf.gsub!(/#{Regexp.escape(link[:link])}/, color_link_reference(url, counter, content))
797
+ graf.gsub!(/#{Regexp.escape(link[:link].gsub(/\n/, ' '))}/, color_link_reference(url, counter, content))
793
798
  if MDLess.options[:links] == :paragraph
794
799
  if links_added
795
800
  graf += "\n#{color_reference_link(url, title, counter)}"
@@ -156,9 +156,14 @@ module CLIMarkdown
156
156
  end
157
157
  end
158
158
 
159
+ default(:preserve_linebreaks, false)
160
+ opts.on('--[no-]linebreaks', 'Preserve line breaks') do |opt|
161
+ MDLess.options[:preserve_linebreaks] = opt
162
+ end
163
+
159
164
  default(:syntax_higlight, false)
160
- opts.on('--[no-]syntax', 'Syntax highlight code blocks') do |p|
161
- MDLess.options[:syntax_higlight] = p
165
+ opts.on('--[no-]syntax', 'Syntax highlight code blocks') do |opt|
166
+ MDLess.options[:syntax_higlight] = opt
162
167
  end
163
168
 
164
169
  MDLess.options[:taskpaper] = if MDLess.options[:taskpaper]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CLIMarkdown
4
- VERSION = '2.0.19'
4
+ VERSION = '2.0.21'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mdless
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.19
4
+ version: 2.0.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra