mdless 2.0.3 → 2.0.5

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: 5d7335d03b6ff9a4cd2453de9ecaf5eec3a60fe6dc10d2950cd7b33b298c2852
4
- data.tar.gz: b83ff9e51541d1baebb07a747a369e5a90bc073fc590ff5620fa33a320ebb888
3
+ metadata.gz: ccc91a0517db5cc507c8b0ff8c25eb6973374d8754c1b9e0eaa5c0b87c756c2b
4
+ data.tar.gz: 7fcb9c187a276e2b599c1446df99592b506f82fe808e896c2d12611619d1c666
5
5
  SHA512:
6
- metadata.gz: 20e2aa0e4c82a944fa07cdeed22ea77205387dac18b2393dbd2550620ead1bd1e8b3a9bc2ef130596c273325fa2913f8a0226154988df5cf4452cc004a73b067
7
- data.tar.gz: '053559f22fd9d96a802f0a4bb98f40512b37591715e977d1994e00a86698901dc39053f0ffb2ebe0ea455ec930feab1004548f139ed87e0be4511bc64696d5b1'
6
+ metadata.gz: e0875e8f64bbd79ca3d24a5510ea4a1a7034a2799a468b9d21a67dec592e56a766e4d622ea8c944928ef24e2ad8cf444922a1db2d99522b6662208980e9c8206
7
+ data.tar.gz: 5e8c1982080a3e273e1c0f9be224d9b9a5f8e4e059ae74f621d114e3a12371937beb4f141090103a4d25dc925d134c4a72abcf8b5b211376bc96ca0aedec7e34
@@ -530,17 +530,21 @@ module Redcarpet
530
530
  @log.info('Found YAML')
531
531
  # YAML
532
532
  in_yaml = true
533
- input.sub!(/(?i-m)^---[ \t]*\n([\s\S]*?)\n[-.]{3}[ \t]*\n/) do
533
+ input.sub!(/(?i-m)^---[ \t]*\n([\s\S]*?)\n[-.]{3}[ \t]*\n/m) do
534
534
  m = Regexp.last_match
535
535
  @log.info('Processing YAML Header')
536
- m[0].split(/\n/).map do |line|
536
+ lines = m[0].split(/\n/)
537
+ longest = lines.inject { |memo, word| memo.length > word.length ? memo : word }.length
538
+ longest = longest < @cols ? longest + 1 : @cols
539
+ lines.map do |line|
537
540
  if line =~ /^[-.]{3}\s*$/
538
- line = "#{color('metadata marker')}%% #{color('metadata border')}#{line}"
541
+ line = "#{color('metadata marker')}#{'%' * longest }"
539
542
  else
540
543
  line.sub!(/^(.*?:)[ \t]+(\S)/, '\1 \2')
541
- line = "#{color('metadata marker')}%% #{color('metadata color')}#{line}"
544
+ line = "#{color('metadata color')}#{line}"
542
545
  end
543
- line += ' ' * (@cols - line.uncolor.size) if (@cols - line.uncolor.size).positive?
546
+
547
+ line += ("\u00A0" * (longest - line.uncolor.strip.length) ) + xc
544
548
  line
545
549
  end.join("\n") + "#{xc}\n"
546
550
  end
@@ -549,12 +553,15 @@ module Redcarpet
549
553
  if !in_yaml && input.gsub(/\n/, ' ') =~ /(?i-m)^[\w ]+:\s+\S+/
550
554
  @log.info('Found MMD Headers')
551
555
  input.sub!(/(?i-m)^([\S ]+:[\s\S]*?)+(?=\n\n)/) do |mmd|
552
- mmd.split(/\n/).map do |line|
556
+ lines = mmd.split(/\n/)
557
+ longest = lines.inject { |memo, word| memo.length > word.length ? memo : word }.length
558
+ longest = longest < @cols ? longest + 1 : @cols
559
+ lines.map do |line|
553
560
  line.sub!(/^(.*?:)[ \t]+(\S)/, '\1 \2')
554
- line = "#{color('metadata marker')}%% #{color('metadata color')}#{line}"
555
- line += ' ' * (@cols - line.uncolor.size) if (@cols - line.uncolor.size).positive?
556
- line
557
- end.join("\n") + "#{' ' * @cols}#{xc}\n"
561
+ line = "#{color('metadata color')}#{line}"
562
+ line += "\u00A0" * (longest - line.uncolor.strip.length )
563
+ line + xc
564
+ end.join("\n") + "#{"\u00A0" * longest}#{xc}\n"
558
565
  end
559
566
 
560
567
  end
@@ -234,9 +234,10 @@ module CLIMarkdown
234
234
  end
235
235
  end
236
236
 
237
- def get_headers(input)
237
+ def get_headers(string)
238
238
  unless @headers && !@headers.empty?
239
239
  @headers = []
240
+ input = string.sub(/(?i-m)^---[ \t]*\n([\s\S]*?)\n[-.]{3}[ \t]*\n/m, '')
240
241
  headers = input.scan(/^((?!#!)(\#{1,6})\s*([^#]+?)(?: #+)?\s*|(\S.+)\n([=-]+))$/i)
241
242
 
242
243
  headers.each do |h|
@@ -1,3 +1,3 @@
1
1
  module CLIMarkdown
2
- VERSION = '2.0.3'
2
+ VERSION = '2.0.5'
3
3
  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.0.3
4
+ version: 2.0.5
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-22 00:00:00.000000000 Z
11
+ date: 2023-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redcarpet