Module: Starter::Markdown::Extender

Defined in:
lib/starter/markdown/extender.rb

Overview

) new_string = Extender.process(string)

Class Method Summary collapse

Class Method Details

.process(arg) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/starter/markdown/extender.rb', line 14

def self.process(arg)
  if arg.is_a? String
    string = arg
    options = {}
  else
    options = arg
    string = File.read arg[:file]
  end
  lines = string.split("\n")
  out = FootnoteProcessor.new.process(lines)
  out = CodeEmbedder.new.process(out)

  processed = out.join("\n")
  if path = options[:output]
    File.open path, "w" do |f|
      f.puts processed
    end
  end
  processed
end