module Markdown

Public Instance Methods

author(text) click to toggle source
# File lib/code_writer/rbmarkdown.rb, line 82
def author(text)
  print "Author: #{text}\n\n"
end
body(text) click to toggle source
# File lib/code_writer/rbmarkdown.rb, line 138
def body(text)
  print "#{text.align_left}\n\n"
end
chapter(text) click to toggle source
# File lib/code_writer/rbmarkdown.rb, line 90
def chapter(text)
  print "# #{text}\n\n"
end
code(script) click to toggle source
# File lib/code_writer/rbmarkdown.rb, line 146
def code(script)

  # Let's capture the output of Renjin script in our own string.
  $output.set_std_out(String.new)

  puts script.align_left
  puts
  
  begin
    # eval(script, TOPLEVEL_BINDING)
    eval(script, $binding)
  rescue Exception => e
    puts "#{e.class}: #{e.message}"
  end

  $output.set_default_std_out
  puts $output.alternate_out.align_left.indent(4)
  
end
comment_code(text) click to toggle source
# File lib/code_writer/rbmarkdown.rb, line 196
def comment_code(text)
  puts text.align_left.indent(4)
  puts
end
console(script) click to toggle source
# File lib/code_writer/rbmarkdown.rb, line 170
def console(script)
  
  print(script.align_left.prefix("+ ", "> ").indent(4))
  
  # Let's capture the output of Renjin script in our own string.
  $output.set_std_out(String.new)
  
  begin
    print("\n\n")
    # eval(script, TOPLEVEL_BINDING)
    eval(script, $binding)
  rescue Exception => e
    puts "#{e.class}: #{e.message}"
  end
  
  $output.set_default_std_out
  puts
  puts $output.alternate_out.align_left.indent(4)
  puts
  
end
italic(text) click to toggle source
# File lib/code_writer/rbmarkdown.rb, line 222
def italic(text)
  print "*#{text}*"
end
list(text) click to toggle source
# File lib/code_writer/rbmarkdown.rb, line 213
def list(text)
  puts text.align_left.prefix("* ", paragraph: true).indent(2)
  puts
end
paragraph(text) click to toggle source
# File lib/code_writer/rbmarkdown.rb, line 122
def paragraph(text)
  puts text
end
ref(title, publication) click to toggle source
# File lib/code_writer/rbmarkdown.rb, line 205
def ref(title, publication)
  "*#{title}*, #{publication}"
end
section(text) click to toggle source
# File lib/code_writer/rbmarkdown.rb, line 98
def section(text)
  print "## #{text}\n\n"
end
set_output(output = StIO.new) click to toggle source
# File lib/code_writer/rbmarkdown.rb, line 66
def set_output(output = StIO.new)
  $output = output
end
subparagraph(text) click to toggle source
# File lib/code_writer/rbmarkdown.rb, line 130
def subparagraph(text)
  puts text
end
subsection(text) click to toggle source
# File lib/code_writer/rbmarkdown.rb, line 106
def subsection(text)
  print "### #{text}\n\n"
end
subsubsection(text) click to toggle source
# File lib/code_writer/rbmarkdown.rb, line 114
def subsubsection(text)
  print "#### #{text}\n\n"
end
title(text) click to toggle source
# File lib/code_writer/rbmarkdown.rb, line 74
def title(text)
  print "# #{text}\n\n"
end