mdless 2.0.4 → 2.0.5

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: 2e50c4e915aa31ffff9b159763d18828ffb1f639588773b45a3aa7528a897cf3
4
- data.tar.gz: b6de738b4cd1f6fd6aa208d4a6607354faa143a5a7f2943147f2a244ba9204b1
3
+ metadata.gz: ccc91a0517db5cc507c8b0ff8c25eb6973374d8754c1b9e0eaa5c0b87c756c2b
4
+ data.tar.gz: 7fcb9c187a276e2b599c1446df99592b506f82fe808e896c2d12611619d1c666
5
5
  SHA512:
6
- metadata.gz: 7df9141901628641895a5d3ac76d37c5af99c30cc94f8fd7e2a1e506b62e9da48267c8173418de66fe139456b120e3b082437d497eb32609a2e4105b1bfa969e
7
- data.tar.gz: eabe40a67402c2a9db8488f74b33b7d48295190e6788690375f71a121b934a6659b10e3c8d8e05c5ae9b1de0aa791ea5d405cf85340c913d317e2d3f50fb7392
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.4'
2
+ VERSION = '2.0.5'
3
3
  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.4
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra