class Opmac2html::Converter

Converter from OPmac to html markup

Public Class Methods

new(input_file, output_file) click to toggle source
# File lib/opmac2html/converter.rb, line 17
def initialize(input_file, output_file)
  @input = read_input input_file
  @preproc = Preprocessor.new
  @input = @preproc.run @input
  @builder = HtmlBuilder.new
  @output_file = output_file
  @ttchar = '"'
end

Public Instance Methods

convert() click to toggle source
# File lib/opmac2html/converter.rb, line 34
def convert
  until @input.empty?
    if @input.start_with? '%', "\n"
      cut_at "\n"
    else
      parse
    end
    @input.lstrip!
  end
  write_output @builder.to_s
end
err(text) click to toggle source
# File lib/opmac2html/converter.rb, line 54
def err(text)
  puts "Unsupported control sequence: #{text}"
end
parse() click to toggle source
# File lib/opmac2html/converter.rb, line 46
def parse
  if @input.start_with? '\\'
    parse_macro
  else
    parse_par
  end
end
read_input(filename) click to toggle source
# File lib/opmac2html/converter.rb, line 26
def read_input(filename)
  File.open(filename, 'r') { |input| input.readlines.join }
end
write_output(output) click to toggle source
# File lib/opmac2html/converter.rb, line 30
def write_output(output)
  File.open(@output_file, 'w') { |file| file << output }
end