mdless 2.1.41 → 2.1.44

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: f1a73a6f53b1069e90cb3c9760f7ec30fa49c7b0bc6583278d85059cadc6558b
4
- data.tar.gz: 934c7ce94e399d4f91bb3c2a6fb53053e3584ff9efba64d83e2e1c2b30430657
3
+ metadata.gz: 7dc43970cd07331cf14e92986ab2a746e346d659c73daa78f78bd9ecb703d87e
4
+ data.tar.gz: 164d0c3bc168dd654c928c0727ddd96e6972098c6a59ba6659a16b14f2fdfd99
5
5
  SHA512:
6
- metadata.gz: 52641ae7aa9bb96488c43df3793eaafd32c21d36e77695ebe5c9aebb085a2b241ffae9a7d1faa1cef40184b3f49e6da0c795ae36176eafe4c24f0339504a1d42
7
- data.tar.gz: 44316ff110310cc9f026d6f21782b64f301e7a3cca99d9171fe34dc2ea2725e6731feafeee39d5cbac98ff782ba4e3548ee91810aaa33e5955a8e7fe46e2ee03
6
+ metadata.gz: 318437aec49a4259d1108bec7fd30dca9429db9ae048c33839da92b0eaaa3eaf733683b1a317bc4e89f3fc7c14b268376130090d0fbe8a9226f9da87c79e67f0
7
+ data.tar.gz: 90f1705e25d710e1e669d68fad39bb573cdedd16c9a10103aa240ffdb84d2af9e0095f1c7131c3fb43b983f0f4ac53a836bef75a4280c473347a2ebbe222efa3
@@ -582,7 +582,7 @@ module Redcarpet
582
582
  notes = line.to_enum(:scan, /\[\^(?<ref>\d+)\]/).map { Regexp.last_match }
583
583
  if notes.count.positive?
584
584
  footnotes = notes.map { |n| color_footnote_def(n['ref'].to_i) }.join("\n")
585
- "#{line}\n\n#{footnotes}\n\n"
585
+ "#{line}\n\n#{footnotes}\n\n\n"
586
586
  else
587
587
  line
588
588
  end
@@ -604,14 +604,12 @@ module Redcarpet
604
604
  end
605
605
  end
606
606
 
607
- def indent_lines(input, spaces)
607
+ def indent_lines(input)
608
608
  return nil if input.nil?
609
609
 
610
- indent = spaces.scan(/ /).count
611
-
612
610
  lines = input.split(/\n/)
613
611
  line1 = lines.shift
614
- pre = spaces + " "
612
+ pre = ' '
615
613
 
616
614
  body = lines.map { |l| "#{pre}#{l.rstrip}" }.join("\n")
617
615
  "#{line1}\n#{body}"
@@ -621,21 +619,21 @@ module Redcarpet
621
619
  out = case type
622
620
  when :unordered
623
621
  [
624
- indent,
622
+ ' ' * indent,
625
623
  color('list bullet'),
626
624
  MDLess.theme['list']['ul_char'].strip,
627
625
  ' ',
628
626
  color('list color'),
629
- indent_lines(content, indent).strip,
627
+ indent_lines(content).strip,
630
628
  xc
631
629
  ].join
632
630
  when :ordered
633
631
  [
634
- indent,
632
+ ' ' * indent,
635
633
  color('list number'),
636
634
  "#{counter}. ",
637
635
  color('list color'),
638
- indent_lines(content, indent).strip,
636
+ indent_lines(content).strip,
639
637
  xc
640
638
  ].join
641
639
  end
@@ -687,21 +685,24 @@ module Redcarpet
687
685
  def fix_items(content, last_indent = 0, levels = [0])
688
686
  content.gsub(%r{^(?<indent> *)<<listitem(?<id>\d+)-(?<type>(?:un)?ordered)>>(?<content>.*?)<</listitem\k<id>>>}m) do
689
687
  m = Regexp.last_match
690
- indent = 0
691
- if indent == last_indent
692
- levels[indent] ||= 0
693
- levels[indent] += 1
694
- elsif indent < last_indent
695
- levels[last_indent] = 0
696
- levels[indent] += 1
697
- last_indent = indent
698
- else
699
- levels[indent] = 1
700
- last_indent = indent
688
+
689
+ indent = m['indent'].length
690
+ if m['type'].to_sym == :ordered
691
+ if indent == last_indent
692
+ levels[indent] ||= 0
693
+ levels[indent] += 1
694
+ elsif indent < last_indent
695
+ levels[last_indent] = 0
696
+ levels[indent] += 1
697
+ last_indent = indent
698
+ else
699
+ levels[indent] = 1
700
+ last_indent = indent
701
+ end
701
702
  end
702
703
 
703
704
  content = m['content'] =~/<<listitem/ ? fix_items(m['content'], indent, levels) : m['content']
704
- color_list_item(" " * indent, uncolor_grafs(content), m['type'].to_sym, levels[indent])
705
+ color_list_item(indent, uncolor_grafs(content), m['type'].to_sym, levels[indent])
705
706
  end
706
707
  end
707
708
 
@@ -832,7 +833,7 @@ module Redcarpet
832
833
  end
833
834
 
834
835
  def fix_image_attributes(input)
835
- input.gsub(/^( {0,3}\[[^^].*?\]: *\S+) +([^"].*?)$/, '\1')
836
+ input.gsub(/^( {0,3}\[[^^*>].*?\]: *\S+) +([^"].*?)$/, '\1')
836
837
  end
837
838
 
838
839
  def preprocess(input)
@@ -1000,7 +1001,7 @@ module Redcarpet
1000
1001
  tmp_img = File.basename(img_path)
1001
1002
  img = `chafa #{term} "#{tmp_img}"`
1002
1003
  pre = alt_text ? " #{c(%i[d blue])}[#{alt_text.strip}]\n" : ''
1003
- post = title ? "\n #{c(%i[b blue])}-- #{tail} --" : ''
1004
+ post = title ? "\n #{c(%i[b blue])}-- #{title} --" : ''
1004
1005
  result = pre + img + post
1005
1006
  Dir.chdir('..')
1006
1007
  FileUtils.rm_r '.mdless_tmp', force: true
@@ -584,13 +584,17 @@ module CLIMarkdown
584
584
  end
585
585
 
586
586
  def printout
587
- if MDLess.options[:taskpaper]
588
- out = @output
589
- else
590
- out = @output.rstrip.split(/\n/).map do |p|
591
- p.wrap(MDLess.cols, color('text'))
592
- end.join("\n")
593
- end
587
+ out = @output
588
+
589
+ # out = if MDLess.options[:taskpaper]
590
+ # @output
591
+ # else
592
+ # # TODO: Figure out a word wrap that accounts for indentation
593
+ # @output
594
+ # # out = @output.rstrip.split(/\n/).map do |p|
595
+ # # p.wrap(MDLess.cols, color('text'))
596
+ # # end.join("\n")
597
+ # end
594
598
 
595
599
  unless out.size&.positive?
596
600
  MDLess.log.warn 'No results'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CLIMarkdown
4
- VERSION = '2.1.41'
4
+ VERSION = '2.1.44'
5
5
  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.1.41
4
+ version: 2.1.44
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-12-21 00:00:00.000000000 Z
11
+ date: 2024-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redcarpet