Module: MarkdownRun

Defined in:
lib/markdown_run.rb

Class Method Summary collapse

Class Method Details

.run_code_blocks(input_file_path) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/markdown_run.rb', line 6

def self.run_code_blocks(input_file_path)
  unless File.exist?(input_file_path) && File.readable?(input_file_path)
    abort "Error: Input file '#{input_file_path}' not found or not readable."
  end

  temp_dir = File.dirname(File.expand_path(input_file_path))
  file_enum = File.foreach(input_file_path, chomp: false).to_enum

  processor = MarkdownProcessor.new(temp_dir, input_file_path)
  output_lines = processor.process_file(file_enum)

  # Write the modified content back to the input file
  MarkdownFileWriter.write_output_to_file(output_lines, input_file_path)
end