mdless 0.0.13 → 0.0.14

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: 571d64e2a21dcfe0c1673a038cbb90977a4ca1aa36992ecef63bc5f7d94ee8bd
4
- data.tar.gz: 972c19e2023a96d9c3905bd0ded7984d2a0d36ac15846ddfc1a303acdea4eba3
3
+ metadata.gz: 0a4f667f7783166c9dd1d60ae77698058d9c240d014cd911ac27c4cce2b616b7
4
+ data.tar.gz: f1db62b7e655e58a2c391fa3092e2497f69ba36b31b327686ed7e79846fdd3a0
5
5
  SHA512:
6
- metadata.gz: 74cce597c475876b429a603b5619f837cbb709af2e44e021a5ec63b09b4cfe3ef5a1d69a96980dd37164c5df5ca3eda3722da85ba2daa55362c33c362b88c8f1
7
- data.tar.gz: efd3b25c653f16fbdbd2d32fb9e60d998a712caf4cd5cf1b7abba42eef18f42fbcb75ad4089d7e0c259fa412d4988717433c2f96d07276fcd777cb404d39a006
6
+ metadata.gz: 3ee079617708ae07d18265be581c983631c01ef19187079e137d2244493b09fef7ce6048c0104fb2fc4123a8fce46abadc301d46d391180e1d2f8c2fd6443bfd
7
+ data.tar.gz: 1710ad0309375ef8728521c1d883a7f2b13c7bef2cf5ac5325f497de27b690d36b208f706ec8a8f9fec178a994f0abef698619636815c5d5425b949c6722e708
data/lib/mdless/colors.rb CHANGED
@@ -5,6 +5,10 @@ module CLIMarkdown
5
5
  self.gsub(/\e\[[\d;]+m/,'')
6
6
  end
7
7
 
8
+ def blackout
9
+ self.gsub(/(^|$)/,"\e[40m").gsub(/3([89])m/,"40;3\\1m")
10
+ end
11
+
8
12
  def uncolor!
9
13
  self.replace self.uncolor
10
14
  end
@@ -10,7 +10,7 @@ module CLIMarkdown
10
10
 
11
11
  def initialize(args)
12
12
  @log = Logger.new(STDERR)
13
- @log.level = Logger::FATAL
13
+ @log.level = Logger::ERROR
14
14
 
15
15
  @options = {}
16
16
  optparse = OptionParser.new do |opts|
@@ -75,7 +75,7 @@ module CLIMarkdown
75
75
  if level.to_i > 0 && level.to_i < 5
76
76
  @log.level = 5 - level.to_i
77
77
  else
78
- $stderr.puts "Log level out of range (1-4)"
78
+ $stderr.puts "Error: Log level out of range (1-4)"
79
79
  Process.exit 1
80
80
  end
81
81
  end
@@ -185,7 +185,7 @@ module CLIMarkdown
185
185
  ' '
186
186
  end
187
187
  line_no = '%2d: ' % (idx + 1)
188
- headers_out.push(%Q{#{line_no}#{c([:x, :black])}#{".."*level}#{c([:x, :yellow])}#{subdoc}#{title.strip}#{xc}}.strip)
188
+ headers_out.push(%Q{#{line_no}#{c(%i[x black])}#{".."*level}#{c(%i[x yellow])}#{subdoc}#{title.strip}#{xc}}.strip)
189
189
  end
190
190
 
191
191
  @output += headers_out.join("\n")
@@ -205,12 +205,12 @@ module CLIMarkdown
205
205
  input.split(/\n/).map{|line|
206
206
  if first
207
207
  first = false
208
- line.gsub!(/\|/, "#{c([:d,:black])}|#{c([:x,:yellow])}")
208
+ line.gsub!(/\|/, "#{c(%i[d black])}|#{c(%i[x yellow])}")
209
209
  elsif line.strip =~ /^[|:\- ]+$/
210
- line.gsub!(/^(.*)$/, "#{c([:d,:black])}\\1#{c([:x,:white])}")
211
- line.gsub!(/([:\-]+)/,"#{c([:b,:black])}\\1#{c([:d,:black])}")
210
+ line.gsub!(/^(.*)$/, "#{c(%i[d black])}\\1#{c(%i[x white])}")
211
+ line.gsub!(/([:\-]+)/,"#{c(%i[b black])}\\1#{c(%i[d black])}")
212
212
  else
213
- line.gsub!(/\|/, "#{c([:d,:black])}|#{c([:x,:white])}")
213
+ line.gsub!(/\|/, "#{c(%i[d black])}|#{c(%i[x white])}")
214
214
  end
215
215
  }.join("\n")
216
216
  end
@@ -289,32 +289,63 @@ module CLIMarkdown
289
289
  end
290
290
 
291
291
  def color_link(line, text, url)
292
- out = c([:b,:black])
293
- out += "[#{c([:u,:blue])}#{text}"
294
- out += c([:b,:black])
292
+ out = c(%i[b black])
293
+ out += "[#{c(%i[u blue])}#{text}"
294
+ out += c(%i[b black])
295
295
  out += "]("
296
- out += c([:x,:cyan])
296
+ out += c(%i[x cyan])
297
297
  out += url
298
- out += c([:b,:black])
298
+ out += c(%i[b black])
299
299
  out += ")"
300
300
  out += find_color(line)
301
301
  out
302
302
  end
303
303
 
304
304
  def color_image(line, text, url)
305
- text.gsub!(/\e\[0m/,c([:x,:cyan]))
305
+ text.gsub!(/\e\[0m/,c(%i[x cyan]))
306
306
 
307
- "#{c([:x,:red])}!#{c([:b,:black])}[#{c([:x,:cyan])}#{text}#{c([:b,:black])}](#{c([:u,:yellow])}#{url}#{c([:b,:black])})" + find_color(line)
307
+ "#{c(%i[x red])}!#{c(%i[b black])}[#{c(%i[x cyan])}#{text}#{c(%i[b black])}](#{c(%i[u yellow])}#{url}#{c(%i[b black])})" + find_color(line)
308
308
  end
309
309
 
310
- def hiliteCode(language, codeBlock, leader, block)
311
- if exec_available('pygmentize')
312
- lexer = language.nil? ? '-g' : "-l #{language}"
313
- begin
314
- hilite, s = Open3.capture2(%Q{pygmentize #{lexer} 2> /dev/null}, :stdin_data=>codeBlock)
310
+ def valid_lexer?(language)
311
+ lexers = %w(Clipper XBase Cucumber cucumber Gherkin gherkin RobotFramework robotframework abap ada ada95ada2005 ahk antlr-as antlr-actionscript antlr-cpp antlr-csharp antlr-c# antlr-java antlr-objc antlr-perl antlr-python antlr-ruby antlr-rb antlr apacheconf aconf apache applescript as actionscript as3 actionscript3 aspectj aspx-cs aspx-vb asy asymptote autoit Autoit awk gawk mawk nawk basemake bash sh ksh bat bbcode befunge blitzmax bmax boo brainfuck bf bro bugs winbugs openbugs c-objdump c ca65 cbmbas ceylon cfengine3 cf3 cfm cfs cheetah spitfire clojure clj cmake cobol cobolfree coffee-script coffeescript common-lisp cl console control coq cpp c++ cpp-objdump c++-objdumb cxx-objdump croc csharp c# css+django css+jinja css+erb css+ruby css+genshitext css+genshi css+lasso css+mako css+myghty css+php css+smarty css cuda cu cython pyx d-objdump d dart delphi pas pascal objectpascal dg diff udiff django jinja dpatch dtd duel Duel Engine Duel View JBST jbst JsonML+BST dylan-console dylan-repl dylan-lid lid dylan ec ecl elixir ex exs erb erl erlang evoque factor fan fancy fy felix flx fortran fsharp gas genshi kid xml+genshi xml+kid genshitext glsl gnuplot go gooddata-cl gosu groff nroff man groovy gst haml HAML haskell hs haxeml hxml html+cheetah html+spitfire html+django html+jinja html+evoque html+genshi html+kid html+lasso html+mako html+myghty html+php html+smarty html+velocity html http hx haXe hybris hy idl iex ini cfg io ioke ik irc jade JADE jags java jlcon js+cheetah javascript+cheetah js+spitfire javascript+spitfire js+django javascript+django js+jinja javascript+jinja js+erb javascript+erb js+ruby javascript+ruby js+genshitext js+genshi javascript+genshitext javascript+genshi js+lasso javascript+lasso js+mako javascript+mako js+myghty javascript+myghty js+php javascript+php js+smarty javascript+smarty js javascript json jsp julia jl kconfig menuconfig linux-config kernel-config koka kotlin lasso lassoscript lhs literate-haskell lighty lighttpd live-script livescript llvm logos logtalk lua make makefile mf bsdmake mako maql mason matlab matlabsession minid modelica modula2 m2 monkey moocode moon moonscript mscgen msc mupad mxml myghty mysql nasm nemerle newlisp newspeak nginx nimrod nim nsis nsi nsh numpy objdump objective-c++ objectivec++ obj-c++ objc++ objective-c objectivec obj-c objc objective-j objectivej obj-j objj ocaml octave ooc opa openedge abl progress perl pl php php3 php4 php5 plpgsql postgresql postgres postscript pot po pov powershell posh ps1 prolog properties protobuf psql postgresql-console postgres-console puppet py3tb pycon pypylog pypy pytb python py sage python3 py3 qml Qt Meta Language Qt modeling Language racket rkt ragel-c ragel-cpp ragel-d ragel-em ragel-java ragel-objc ragel-ruby ragel-rb ragel raw rb ruby duby rbcon irb rconsole rout rd rebol redcode registry rhtml html+erb html+ruby rst rest restructuredtext rust sass SASS scala scaml SCAML scheme scm scilab scss shell-session smali smalltalk squeak smarty sml snobol sourceslist sources.list sp spec splus s r sql sqlite3 squidconf squid.conf squid ssp stan systemverilog sv tcl tcsh csh tea tex latex text trac-wiki moin treetop ts urbiscript vala vapi vb.net vbnet velocity verilog v vgl vhdl vim xml+cheetah xml+spitfire xml+django xml+jinja xml+erb xml+ruby xml+evoque xml+lasso xml+mako xml+myghty xml+php xml+smarty xml+velocity xml xquery xqy xq xql xqm xslt xtend yaml)
312
+ return lexers.include? language.strip
313
+ end
314
+
315
+ def pad_max(block,eol='')
316
+ block.split(/\n/).map { |l|
317
+ new_code_line = l.gsub(/\t/, ' ')
318
+ orig_length = new_code_line.size + 8 + eol.size
319
+ pad_count = [@cols - orig_length, 0].max
320
+
321
+ [
322
+ new_code_line,
323
+ eol,
324
+ ' ' * ([pad_count-1,0].max)
325
+ ].join
326
+ }.join("\n")
327
+ end
315
328
 
329
+ def hiliteCode(language, codeBlock, leader, first_indent, block)
330
+ new_indent = first_indent > 0 ? first_indent + 2 : 0
331
+ last_indent = first_indent == 0 ? 7 : 5
332
+
333
+ if exec_available('pygmentize') && language && valid_lexer?(language)
334
+ lexer = "-l #{language}"
335
+ begin
336
+ hilite, s = Open3.capture2(%Q{pygmentize -f terminal256 -O style=monokai #{lexer} 2> /dev/null}, :stdin_data=>codeBlock)
316
337
  if s.success?
317
- hilite = hilite.split(/\n/).map{|l| "#{c([:x,:black])}~ #{xc}" + l}.join("\n")
338
+
339
+ hilite = xc + hilite.split(/\n/).map{|l|
340
+ new_code_line = l.gsub(/\t/, ' ')
341
+ new_code_line.sub!(/^#{" "*first_indent}/,'')
342
+ [
343
+ c(%i[x intense_black]),
344
+ "> ",
345
+ " "*first_indent,
346
+ "#{c([:on_black])}#{l}"
347
+ ].join
348
+ }.join("\n").blackout + "#{xc}\n"
318
349
  end
319
350
  rescue => e
320
351
  @log.error(e)
@@ -323,20 +354,20 @@ module CLIMarkdown
323
354
  else
324
355
  hilite = codeBlock.split(/\n/).map do |line|
325
356
  new_code_line = line.gsub(/\t/, ' ')
326
- orig_length = new_code_line.size + 3
357
+ new_code_line.sub!(/^#{" "*first_indent}/,'')
327
358
  new_code_line.gsub!(/ /, "#{c(%i[x white on_black])} ")
328
-
329
359
  [
330
- "#{c(%i[x black])} ~#{c(%i[x white on_black])} ",
331
- new_code_line,
360
+ c(%i[x intense_black]),
361
+ "> ",
362
+ " "*first_indent,
332
363
  c(%i[x white on_black]),
333
- ' ' * [@cols - orig_length, 0].max,
364
+ new_code_line,
334
365
  xc
335
366
  ].join
336
- end.join("\n")
367
+ end.join("\n") + "\n"
337
368
  end
338
369
 
339
- "#{c(%i[x blue]) + '--[ '}#{c(%i[x magenta])}#{leader}#{c(%i[x blue]) + ' ]' + '-'*(@cols-6-leader.size) + xc}\n#{hilite}\n#{c(%i[x blue]) + '--[ '}#{c(%i[x magenta])}END #{leader}#{c(%i[x blue]) + ' ]' + '-'*(@cols-10-leader.size) + xc}"
370
+ "#{xc}\n#{" "*first_indent}#{c(%i[x blue]) + '--[ '}#{c(%i[x magenta])}#{leader}#{c(%i[x blue]) + ' ]' + '-'*(@cols-new_indent-leader.size+1) + xc}\n#{hilite}#{" "*(new_indent)}#{c(%i[x blue]) + '-'*(@cols-new_indent) + xc}\n"
340
371
  end
341
372
 
342
373
  def convert_markdown(input)
@@ -350,13 +381,13 @@ module CLIMarkdown
350
381
  input.sub!(/(?i-m)^---[ \t]*\n([\s\S]*?)\n[\-.]{3}[ \t]*\n/) do |yaml|
351
382
  m = Regexp.last_match
352
383
 
353
- @log.warn("Processing YAML Header")
384
+ @log.info("Processing YAML Header")
354
385
  m[0].split(/\n/).map {|line|
355
386
  if line =~ /^[\-.]{3}\s*$/
356
- line = c([:d,:black,:on_black]) + "% " + c([:d,:black,:on_black]) + line
387
+ line = c(%i[d black on_black]) + "% " + c(%i[d black on_black]) + line
357
388
  else
358
389
  line.sub!(/^(.*?:)[ \t]+(\S)/, '\1 \2')
359
- line = c([:d,:black,:on_black]) + "% " + c([:d,:white]) + line
390
+ line = c(%i[d black on_black]) + "% " + c(%i[d white]) + line
360
391
  end
361
392
  if @cols - line.uncolor.size > 0
362
393
  line += " "*(@cols-line.uncolor.size)
@@ -371,7 +402,7 @@ module CLIMarkdown
371
402
  puts mmd
372
403
  mmd.split(/\n/).map {|line|
373
404
  line.sub!(/^(.*?:)[ \t]+(\S)/, '\1 \2')
374
- line = c([:d,:black,:on_black]) + "% " + c([:d,:white,:on_black]) + line
405
+ line = c(%i[d black on_black]) + "% " + c(%i[d white on_black]) + line
375
406
  if @cols - line.uncolor.size > 0
376
407
  line += " "*(@cols - line.uncolor.size)
377
408
  end
@@ -434,40 +465,31 @@ module CLIMarkdown
434
465
  end
435
466
 
436
467
  # code block parsing
437
- input.gsub!(/(?i-m)([`~]{3,})([\s\S]*?)\n([\s\S]*?)\1/) do
468
+ input.gsub!(/(?i-m)(^[ \t]*[`~]{3,})([\s\S]*?)\n([\s\S]*?)\1/m) do
469
+ language = nil
438
470
  m = Regexp.last_match
439
- if m[2].strip !~ /^\s*$/
440
- language = m[2].split(/ /)[0].downcase
441
- code_block = m[3].to_s.strip
442
- leader = language ? language.upcase : 'CODE'
471
+ first_indent = m[1].gsub(/\t/,' ').match(/^ */)[0].size
472
+
473
+ if m[2] && m[2].strip.length > 0
474
+ language = m[2].strip.split(/ /)[0]
475
+ code_block = pad_max(m[3].to_s,'')
476
+ leader = language ? language : 'code'
443
477
  else
444
478
  first_line = m[3].to_s.split(/\n/)[0]
445
479
 
446
- if first_line =~ /^#!/
447
- @log.warn('Code block contains Shebang')
448
- shebang = first_line.match(/^(#!.*\/(?:env )?)([^\/]+)$/)
449
- language = shebang[2]
450
- code_block = m[3].to_s.strip
451
- leader = shebang[2] ? shebang[2].upcase : 'CODE'
480
+ if first_line =~ /^\s*#!/
481
+ shebang = first_line.match(/^\s*#!.*\/(?:env )?([^\/]+)$/)
482
+ language = shebang[1]
483
+ code_block = m[3]
484
+ leader = shebang[1] ? shebang[1] : 'code'
452
485
  else
453
- code_block = m[3].to_s.split(/\n/).map do |l|
454
- new_code_line = l.gsub(/\t/, ' ')
455
- orig_length = new_code_line.size + 4
456
- new_code_line.gsub!(/ /, "#{c(%i[x white on_black])} ")
457
- pad_count = [@cols - orig_length, 0].max
458
- [
459
- "#{c(%i[x black])}~ #{c(%i[x white on_black])} ",
460
- new_code_line,
461
- c(%i[x white on_black]),
462
- ' ' * pad_count,
463
- xc
464
- ].join
465
- end.join("\n")
466
- leader = language ? language.upcase : 'CODE'
486
+ code_block = pad_max(m[3].to_s, "#{c(%i[intense_black on_black])}¬")
487
+ leader = language ? language : 'code'
467
488
  end
468
489
  end
469
490
  leader += xc
470
- hiliteCode(language, code_block, leader, m[0])
491
+
492
+ hiliteCode(language, code_block, leader, first_indent, m[0])
471
493
  end
472
494
 
473
495
  # remove empty links
@@ -504,19 +526,19 @@ module CLIMarkdown
504
526
  ansi = ''
505
527
  case m[1].length
506
528
  when 1
507
- ansi = c([:b, :black, :on_intense_white])
508
- pad = c([:b,:white])
529
+ ansi = c(%i[b black on_intense_white])
530
+ pad = c(%i[b white])
509
531
  pad += m[2].length + 2 > @cols ? "*"*m[2].length : "*"*(@cols - (m[2].length + 2))
510
532
  when 2
511
- ansi = c([:b, :green, :on_black])
512
- pad = c([:b,:black])
533
+ ansi = c(%i[b green on_black])
534
+ pad = c(%i[b black])
513
535
  pad += m[2].length + 2 > @cols ? "-"*m[2].length : "-"*(@cols - (m[2].length + 2))
514
536
  when 3
515
- ansi = c([:u, :b, :yellow])
537
+ ansi = c(%i[u b yellow])
516
538
  when 4
517
- ansi = c([:x, :u, :yellow])
539
+ ansi = c(%i[x u yellow])
518
540
  else
519
- ansi = c([:b, :white])
541
+ ansi = c(%i[b white])
520
542
  end
521
543
 
522
544
  "\n#{xc}#{ansi}#{m[2]} #{pad}#{xc}\n"
@@ -526,7 +548,7 @@ module CLIMarkdown
526
548
  if line =~ /\[(?:\e\[[\d;]+m)*\^(?:\e\[[\d;]+m)*(\S+)(?:\e\[[\d;]+m)*\]/
527
549
  key = $1.uncolor
528
550
  if @footnotes.key? key
529
- line += "\n\n#{c([:b,:black,:on_black])}[#{c([:b,:cyan,:on_black])}^#{c([:x,:yellow,:on_black])}#{key}#{c([:b,:black,:on_black])}]: #{c([:u,:white,:on_black])}#{@footnotes[key]}#{xc}"
551
+ line += "\n\n#{c(%i[b black on_black])}[#{c(%i[b cyan on_black])}^#{c(%i[x yellow on_black])}#{key}#{c(%i[b black on_black])}]: #{c(%i[u white on_black])}#{@footnotes[key]}#{xc}"
530
552
  @footnotes.delete(key)
531
553
  end
532
554
  end
@@ -540,7 +562,7 @@ module CLIMarkdown
540
562
  counter -= 1
541
563
  find_color(lines[counter])
542
564
  end
543
- "#{c([:b,:black])}[#{c([:b,:yellow])}^#{c([:x,:yellow])}#{match[1]}#{c([:b,:black])}]" + (last ? last : xc)
565
+ "#{c(%i[b black])}[#{c(%i[b yellow])}^#{c(%i[x yellow])}#{match[1]}#{c(%i[b black])}]" + (last ? last : xc)
544
566
  end
545
567
 
546
568
  # blockquotes
@@ -552,7 +574,7 @@ module CLIMarkdown
552
574
  counter -= 1
553
575
  find_color(lines[counter])
554
576
  end
555
- "#{c([:b,:black])}#{match[1]}#{c([:x,:magenta])} #{match[2]}" + (last ? last : xc)
577
+ "#{c(%i[b black])}#{match[1]}#{c(%i[x magenta])} #{match[2]}" + (last ? last : xc)
556
578
  end
557
579
 
558
580
  # make reference links inline
@@ -585,12 +607,12 @@ module CLIMarkdown
585
607
  line.gsub!(/`(.*?)`/) do |m|
586
608
  match = Regexp.last_match
587
609
  last = find_color(match.pre_match, true)
588
- "#{c([:b,:black])}`#{c([:b,:white])}#{match[1]}#{c([:b,:black])}`" + (last ? last : xc)
610
+ "#{c(%i[b black])}`#{c(%i[b white])}#{match[1]}#{c(%i[b black])}`" + (last ? last : xc)
589
611
  end
590
612
 
591
613
  # horizontal rules
592
614
  line.gsub!(/^ {,3}([\-*] ?){3,}$/) do |m|
593
- c([:x,:black]) + '_'*@cols + xc
615
+ c(%i[x black]) + '_'*@cols + xc
594
616
  end
595
617
 
596
618
  # bold, bold/italic
@@ -629,7 +651,7 @@ module CLIMarkdown
629
651
  brackets = [match[5], match[7]]
630
652
  equat = match[6]
631
653
  end
632
- "#{c([:b, :black])}#{brackets[0]}#{xc}#{c([:b,:blue])}#{equat}#{c([:b, :black])}#{brackets[1]}" + (last ? last : xc)
654
+ "#{c(%i[b black])}#{brackets[0]}#{xc}#{c(%i[b blue])}#{equat}#{c(%i[b black])}#{brackets[1]}" + (last ? last : xc)
633
655
  end
634
656
 
635
657
  # list items
@@ -638,13 +660,13 @@ module CLIMarkdown
638
660
  match = Regexp.last_match
639
661
  last = find_color(match.pre_match)
640
662
  indent = match[1] || ''
641
- "#{indent}#{c([:d, :red])}#{match[2]} " + (last ? last : xc)
663
+ "#{indent}#{c(%i[d red])}#{match[2]} " + (last ? last : xc)
642
664
  end
643
665
 
644
666
  # definition lists
645
667
  line.gsub!(/^(:\s*)(.*?)/) do |m|
646
668
  match = Regexp.last_match
647
- "#{c([:d, :red])}#{match[1]} #{c([:b, :white])}#{match[2]}#{xc}"
669
+ "#{c(%i[d red])}#{match[1]} #{c(%i[b white])}#{match[2]}#{xc}"
648
670
  end
649
671
 
650
672
  # misc html
@@ -652,7 +674,7 @@ module CLIMarkdown
652
674
  line.gsub!(/(?i-m)((<\/?)(\w+[\s\S]*?)(>))/) do |tag|
653
675
  match = Regexp.last_match
654
676
  last = find_color(match.pre_match)
655
- "#{c([:d,:yellow,:on_black])}#{match[2]}#{match[3]}#{match[4]}" + (last ? last : xc)
677
+ "#{c(%i[d yellow on_black])}#{match[2]}#{match[3]}#{match[4]}" + (last ? last : xc)
656
678
  end
657
679
  end
658
680
 
@@ -677,8 +699,8 @@ module CLIMarkdown
677
699
  res, s = Open3.capture2(%Q{curl -sS "#{img_path}" 2> /dev/null | imgcat})
678
700
 
679
701
  if s.success?
680
- pre = match[2].size > 0 ? " #{c([:d,:blue])}[#{match[2].strip}]\n" : ''
681
- post = tail.size > 0 ? "\n #{c([:b,:blue])}-- #{tail} --" : ''
702
+ pre = match[2].size > 0 ? " #{c(%i[d blue])}[#{match[2].strip}]\n" : ''
703
+ post = tail.size > 0 ? "\n #{c(%i[b blue])}-- #{tail} --" : ''
682
704
  result = pre + res + post
683
705
  end
684
706
  rescue => e
@@ -692,8 +714,8 @@ module CLIMarkdown
692
714
  img_path = File.join(base,img_path)
693
715
  end
694
716
  if File.exists?(img_path)
695
- pre = match[2].size > 0 ? " #{c([:d,:blue])}[#{match[2].strip}]\n" : ''
696
- post = tail.size > 0 ? "\n #{c([:b,:blue])}-- #{tail} --" : ''
717
+ pre = match[2].size > 0 ? " #{c(%i[d blue])}[#{match[2].strip}]\n" : ''
718
+ post = tail.size > 0 ? "\n #{c(%i[b blue])}-- #{tail} --" : ''
697
719
  img = %x{imgcat "#{img_path}"}
698
720
  result = pre + img + post
699
721
  end
@@ -709,7 +731,7 @@ module CLIMarkdown
709
731
  end
710
732
 
711
733
  @footnotes.each {|t, v|
712
- input += "\n\n#{c([:b,:black,:on_black])}[#{c([:b,:yellow,:on_black])}^#{c([:x,:yellow,:on_black])}#{t}#{c([:b,:black,:on_black])}]: #{c([:u,:white,:on_black])}#{v}#{xc}"
734
+ input += "\n\n#{c(%i[b black on_black])}[#{c(%i[b yellow on_black])}^#{c(%i[x yellow on_black])}#{t}#{c(%i[b black on_black])}]: #{c(%i[u white on_black])}#{v}#{xc}"
713
735
  }
714
736
 
715
737
  @output += input
@@ -761,7 +783,7 @@ module CLIMarkdown
761
783
 
762
784
 
763
785
  unless out && out.size > 0
764
- $stderr.puts "No results"
786
+ @log.warn "No results"
765
787
  Process.exit
766
788
  end
767
789
 
@@ -1,3 +1,3 @@
1
1
  module CLIMarkdown
2
- VERSION = '0.0.13'
2
+ VERSION = '0.0.14'
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: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-11 00:00:00.000000000 Z
11
+ date: 2019-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake