@@ -582,7 +582,7 @@ def insert_footnotes(input)
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 @@ def list_item(text, list_type)
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 @@ def color_list_item(indent, content, type, counter)
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 @@ def normalize_indentation(line)
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 @@ def mmd_metadata_replace(input)
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 )
0 commit comments