Class: MarkdownMetrics::Elements::Block::Pre
Instance Attribute Summary
#skip_lines_until
Class Method Summary
collapse
Instance Method Summary
collapse
#initialize
Class Method Details
.match_element(line, next_line) ⇒ Object
7
8
9
|
# File 'lib/markdown_metrics/elements/block/pre.rb', line 7
def self.match_element(line, next_line)
line.to_s.match(/^```(?<language>.*)/)
end
|
Instance Method Details
#attributes ⇒ Object
35
36
37
38
39
|
# File 'lib/markdown_metrics/elements/block/pre.rb', line 35
def attributes
language_name = current_line.match(/^```(?<language>.*)/)['language']
{ language: language_name }
end
|
#name ⇒ Object
11
12
13
|
# File 'lib/markdown_metrics/elements/block/pre.rb', line 11
def name
:pre
end
|
#value ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/markdown_metrics/elements/block/pre.rb', line 15
def value
end_line = nil
next_line = @start_at
@lines[(@start_at + 1)..-1].each do |code_line|
next_line += 1
if code_line == '```'
end_line = next_line
break
end
end_line = @lines.size - 1 if end_line.nil?
end
if !end_line.nil?
@skip_lines_until = end_line
@lines[(@start_at + 1)..(end_line - 1)].join("\n")
end
end
|