Class: MarkdownCodeBlockParser
- Inherits:
-
Object
- Object
- MarkdownCodeBlockParser
- Defined in:
- lib/markdown_code_block_parser.rb
Instance Attribute Summary collapse
-
#blocks ⇒ Object
readonly
Returns the value of attribute blocks.
-
#markdown ⇒ Object
readonly
Returns the value of attribute markdown.
-
#matches ⇒ Object
readonly
Returns the value of attribute matches.
-
#pairs ⇒ Object
readonly
Returns the value of attribute pairs.
Instance Method Summary collapse
- #display_analysis ⇒ Object
-
#initialize(markdown) ⇒ MarkdownCodeBlockParser
constructor
A new instance of MarkdownCodeBlockParser.
- #parse ⇒ Object
Constructor Details
#initialize(markdown) ⇒ MarkdownCodeBlockParser
Returns a new instance of MarkdownCodeBlockParser.
4 5 6 7 8 9 |
# File 'lib/markdown_code_block_parser.rb', line 4 def initialize(markdown) @markdown = markdown @matches = [] @pairs = [] @blocks = [] end |
Instance Attribute Details
#blocks ⇒ Object (readonly)
Returns the value of attribute blocks.
2 3 4 |
# File 'lib/markdown_code_block_parser.rb', line 2 def blocks @blocks end |
#markdown ⇒ Object (readonly)
Returns the value of attribute markdown.
2 3 4 |
# File 'lib/markdown_code_block_parser.rb', line 2 def markdown @markdown end |
#matches ⇒ Object (readonly)
Returns the value of attribute matches.
2 3 4 |
# File 'lib/markdown_code_block_parser.rb', line 2 def matches @matches end |
#pairs ⇒ Object (readonly)
Returns the value of attribute pairs.
2 3 4 |
# File 'lib/markdown_code_block_parser.rb', line 2 def pairs @pairs end |
Instance Method Details
#display_analysis ⇒ Object
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/markdown_code_block_parser.rb', line 194 def display_analysis puts "Detected #{@matches.length} code block delimiters" puts "Formed #{@pairs.length} pairs" puts "\nCode blocks found:" @blocks.each_with_index do |block, i| puts "\nBlock #{i}:" puts " Language: #{block[:language] || 'none'}" puts " Position: #{block[:start_pos]}-#{block[:end_pos]}" puts " Tick count: #{block[:tick_count]}" puts " Nesting depth: #{block[:depth]}" puts " Contains blocks: #{block[:nested_blocks].join(', ')}" unless block[:nested_blocks].empty? content_preview = block[:content][0..80].gsub(/\n/, ' ') puts " Content preview: #{content_preview}..." end end |
#parse ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/markdown_code_block_parser.rb', line 11 def parse find_all_code_blocks pair_code_blocks build_block_structures detect_nesting self end |