class Ulmul

Constants

PARAGRAPH_INITIATOR
PARAGRAPH_TERMINATOR
VERBATIM_INITIATOR
VERBATIM_TERMINATOR
VERSION

Attributes

subs_rules[RW]

Public Class Methods

new() click to toggle source
# File lib/ulmul.rb, line 283
def initialize()
  @toc = Table_of_Contents.new()
  @body = ''
  @level_of_heading = 0
  @i_th_heading     = 0
  @equations       = []
  @figures         = []
  @tables          = []
  @codes           = []
end

Public Instance Methods

cb_env_begin(filename=nil, lnumber=nil, line=nil) click to toggle source
# File lib/ulmul.rb, line 204
def cb_env_begin(filename=nil, lnumber=nil, line=nil)
  @env_label, @env_file = line.split
  @env_label.sub!(/^\\/,'')
  @env_caption =''
  case @env_label
  when /^Fig:/
    @figures << @env_label
  when /^Table:/
    @tables << @env_label
  when /^Code:/
    @codes << @env_label
  end
end
cb_env_continues(filename=nil, lnumber=nil, line=nil) click to toggle source
# File lib/ulmul.rb, line 218
def cb_env_continues(filename=nil, lnumber=nil, line=nil)
  @env_caption << line
end
cb_env_end(filename=nil, lnumber=nil, line=nil) click to toggle source
# File lib/ulmul.rb, line 222
def cb_env_end(filename=nil, lnumber=nil, line=nil)
  if line.chomp.sub(/^\//,'') != @env_label
    STDERR << filename << ":#{lnumber}: Current environment is #{@env_label}, but it is terminated with: #{line}"
    exit 1
  end
  cb_env_end2()
  @env_caption =''
  @env_label =''
end
cb_env_in_env_error(filename=nil, lnumber=nil, line=nil) click to toggle source
# File lib/ulmul.rb, line 232
def cb_env_in_env_error(filename=nil, lnumber=nil, line=nil)
  STDERR << filename << ":#{lnumber}: It is already/still in the environment of #{@env_label}, but you tried: #{line}"
  exit 1
end
cb_env_not_in_env_error(filename=nil, lnumber=nil, line=nil) click to toggle source
# File lib/ulmul.rb, line 237
def cb_env_not_in_env_error(filename=nil, lnumber=nil, line=nil)
  STDERR << filename << ":#{lnumber}: It is not in any environment, but you tried: #{line}"
  exit 1
end
cb_equation_begin(filename=nil, lnumber=nil, line=nil) click to toggle source
# File lib/ulmul.rb, line 242
def cb_equation_begin(filename=nil, lnumber=nil, line=nil)
  @equation_label = line.strip.sub!(/^\\/,'')
  @equations << @equation_label
  @equation_contents = ''
end
cb_equation_continues(filename=nil, lnumber=nil, line=nil) click to toggle source
# File lib/ulmul.rb, line 248
def cb_equation_continues(filename=nil, lnumber=nil, line=nil)
  @equation_contents << line
end
cb_equation_end(filename=nil, lnumber=nil, line=nil) click to toggle source
# File lib/ulmul.rb, line 252
def cb_equation_end(filename=nil, lnumber=nil, line=nil)
  cb_equation_end2()
  @equation_contents =''
  @equation_label =''
end
cb_paragraph_add(filename=nil, lnumber=nil, line=nil) click to toggle source
# File lib/ulmul.rb, line 184
def cb_paragraph_add(filename=nil, lnumber=nil, line=nil)
  @body << @subs_rules.call(line)
end
cb_paragraph_begin(filename=nil, lnumber=nil, line=nil) click to toggle source
# File lib/ulmul.rb, line 180
def cb_paragraph_begin(filename=nil, lnumber=nil, line=nil)
  @body << PARAGRAPH_INITIATOR << "\n"
end
cb_paragraph_end(filename=nil, lnumber=nil, line=nil) click to toggle source
# File lib/ulmul.rb, line 188
def cb_paragraph_end(filename=nil, lnumber=nil, line=nil)
  @body << PARAGRAPH_TERMINATOR << "\n"
end
cb_verbatim_add(filename=nil, lnumber=nil, line=nil) click to toggle source
# File lib/ulmul.rb, line 196
def cb_verbatim_add(filename=nil, lnumber=nil, line=nil)
    @body << line[1..-1].gsub(/&/,'&amp;').gsub(/</,'&lt;').gsub(/>/,'&gt;')
end
cb_verbatim_begin(filename=nil, lnumber=nil, line=nil) click to toggle source
# File lib/ulmul.rb, line 192
def cb_verbatim_begin(filename=nil, lnumber=nil, line=nil)
  @body << VERBATIM_INITIATOR << "\n"
end
cb_verbatim_end(filename=nil, lnumber=nil, line=nil) click to toggle source
# File lib/ulmul.rb, line 200
def cb_verbatim_end(filename=nil, lnumber=nil, line=nil)
  @body << VERBATIM_TERMINATOR << "\n"
end
parse(fd) click to toggle source
# File lib/ulmul.rb, line 258
def parse(fd)
  while true
    if line = fd.gets
      lnumber = ARGF.file.lineno
    else
      line = "=end\n"
    end
    case line
    when /^=begin/,/^#/ then    ev_ignore(nil, $FILENAME, lnumber, line)
    when /^=end/        then   ev_heading(nil, $FILENAME, lnumber, line); break
    when /^=+ /         then   ev_heading(nil, $FILENAME, lnumber, line)
    when /^ +\*/        then  ev_asterisk(nil, $FILENAME, lnumber, line)
    when /^$/           then     ev_empty(nil, $FILENAME, lnumber, line)
    when /^\s+/         then    ev_offset(nil, $FILENAME, lnumber, line)
    when /^\\(Fig|Table|Code):/
                        then ev_env_begin(nil, $FILENAME, lnumber, line)
    when /^\/(Fig|Table|Code):/
                        then   ev_env_end(nil, $FILENAME, lnumber, line)
    when /^\\Eq:/  then ev_equation_begin(nil, $FILENAME, lnumber, line)
    when /^\/Eq:/  then   ev_equation_end(nil, $FILENAME, lnumber, line)
    else                        ev_normal(nil, $FILENAME, lnumber, line)
    end
  end
end