# Principia Mathemematica Mapper # By Dennis J. Darland # Copyright (c) 2017 Dennis J. Dearland # This file is part of Dennis J. Darland's PM Mapper for PM # # It is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # It is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with it. If not, see . class Proposition attr_accessor :number # a string attr_accessor :polish attr_accessor :wh_russ attr_accessor :polish_proof attr_accessor :wh_russ_proof def initialize(line) @number = line.strip # will eventually do more - just have numbers now end def main_no # number before '.' it = @number.match(/[\d*]+/)[0] end def sub_number @number[main_no.size + 1 , @number.size] end end class PmMap attr_accessor :i def initialize() $last_main_no = "0" $last_sub = "0" @pm_in = File.new("in.txt","r") @map_fd = File.new("pm.html","w") @level = 0 header() add_main() trailer() end def header() @map_fd.puts '' @map_fd.puts '' @map_fd.puts '' @map_fd.puts '' @map_fd.puts 'Map of Principia Mathematica Numbering' @map_fd.puts '' @map_fd.puts 'Map of Principia Mathematica Numbering' end def trailer() @map_fd.puts '' @map_fd.puts '' end def add_main() while line = @pm_in.gets + ' ' if line.strip == 'EOF' exit(0) end prop = Proposition.new(line) $i = 0 $last_main_no = "1" add_sub(prop) end end def add_sub(prop) @map_fd.puts '' if ($i <= prop.sub_number.size) and (prop.main_no == $last_main_no) while ($i < prop.sub_number.size) and (prop.main_no == $last_main_no) @map_fd.puts '' $i -= 1 end @map_fd.puts '
  • ' + prop.main_no + '.' + prop.sub_number + '
  • ' $last_main_no = prop.main_no $last_sub = prop.sub_number else while ($i > prop.sub_number.size) @map_fd.puts '' $i -= 1 end # @map_fd.puts '' @map_fd.puts '
  • ' + prop.main_no + '.' + prop.sub_number + '
  • ' $last_main_no = prop.main_no $last_sub = prop.sub_number end line = @pm_in.gets + " " if line.strip == 'EOF' exit(0) end prop = Proposition.new(line) add_sub(prop) end end # & prop.sub_b=number[i] == $last_sub_i puts "TEST STDOUT" $stderr.puts "TEST STDERR" PmMap.new