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 +4 -4
- data/lib/mdless/console.rb +17 -10
- data/lib/mdless/converter.rb +2 -1
- data/lib/mdless/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccc91a0517db5cc507c8b0ff8c25eb6973374d8754c1b9e0eaa5c0b87c756c2b
|
4
|
+
data.tar.gz: 7fcb9c187a276e2b599c1446df99592b506f82fe808e896c2d12611619d1c666
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0875e8f64bbd79ca3d24a5510ea4a1a7034a2799a468b9d21a67dec592e56a766e4d622ea8c944928ef24e2ad8cf444922a1db2d99522b6662208980e9c8206
|
7
|
+
data.tar.gz: 5e8c1982080a3e273e1c0f9be224d9b9a5f8e4e059ae74f621d114e3a12371937beb4f141090103a4d25dc925d134c4a72abcf8b5b211376bc96ca0aedec7e34
|
data/lib/mdless/console.rb
CHANGED
@@ -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/)
|
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')}
|
541
|
+
line = "#{color('metadata marker')}#{'%' * longest }"
|
539
542
|
else
|
540
543
|
line.sub!(/^(.*?:)[ \t]+(\S)/, '\1 \2')
|
541
|
-
line = "#{color('metadata
|
544
|
+
line = "#{color('metadata color')}#{line}"
|
542
545
|
end
|
543
|
-
|
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/)
|
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
|
555
|
-
line +=
|
556
|
-
line
|
557
|
-
end.join("\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
|
data/lib/mdless/converter.rb
CHANGED
@@ -234,9 +234,10 @@ module CLIMarkdown
|
|
234
234
|
end
|
235
235
|
end
|
236
236
|
|
237
|
-
def get_headers(
|
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|
|
data/lib/mdless/version.rb
CHANGED