techbook_parse (PDF::TechBook)

         # File lib/pdf/techbook.rb, line 517
    517:   def techbook_parse(document, progress = nil)
    518:     @table_of_contents = []
    519:
    520:     @toc_title          = "Table of Contents"
    521:     @gen_toc            = false
    522:     @techbook_code      = ""
    523:     @techbook_para      = ""
    524:     @techbook_fontsize  = 12
    525:     @techbook_textopt   = { :justification => :full }
    526:     @techbook_lastmode  = @techbook_mode = :normal
    527:
    528:     @techbook_textfont  = "Times-Roman"
    529:     @techbook_codefont  = "Courier"
    530:
    531:     @blist_info         = []
    532:
    533:     @techbook_line__    = 0
    534:
    535:     __build_xref_table(document)
    536:
    537:     document.each do |line|
    538:     begin
    539:       progress.inc if progress
    540:       @techbook_line__ += 1
    541:
    542:       next if line =~ %r{^#}o
    543:
    544:       directive, args = techbook_find_directive(line)
    545:       if directive
    546:           # Just try to call the method/directive. It will be far more
    547:           # common to *find* the method than not to.
    548:         res = __send__("techbook_directive_#{directive}", args) rescue nil
    549:         break if :break == res
    550:         next
    551:       end
    552:
    553:       case @techbook_mode
    554:       when :eval
    555:         @techbook_code << line << "\n"
    556:         next
    557:       when :code
    558:         techbook_text(line)
    559:         next
    560:       when :blist
    561:         line = "<C:#{@blist_info[-1][:style]}/>#{line}"
    562:         techbook_text(line)
    563:         next
    564:       end
    565:
    566:       next if techbook_heading(line)
    567:
    568:       if :preserved == @techbook_mode
    569:         techbook_text(line)
    570:         next
    571:       end
    572:
    573:       line.chomp!
    574:
    575:       if line.empty?
    576:         __render_paragraph
    577:         techbook_text("\n")
    578:       else
    579:         @techbook_para << " " unless @techbook_para.empty?
    580:         @techbook_para << line
    581:       end
    582:     rescue Exception => ex
    583:       $stderr.puts PDF::Writer::Lang[:techbook_exception] % [ ex, @techbook_line ]
    584:       raise
    585:     end
    586:     end
    587:   end