Sha256: 7a37be7725fe443daf83c45912417e0a252a023e5ebb5a710ed4096e9198eb67

Contents?: true

Size: 1.01 KB

Versions: 17

Compression:

Stored size: 1.01 KB

Contents

require 'asciidoctor'
require 'asciidoctor/extensions'

module Asciidoctor::LaTeX


  # Prepend lines (in this case tex macro definitions) to a document


  class MacroInsert < Asciidoctor::Extensions::Preprocessor

    def putline line
      @@line_array += [line, ""]
    end

    def process document, reader

      file_contents = IO.read('macros.tex')
      if file_contents == nil
        file_contents = IO.read('public/macros.tex')
      end
      if file_contents
        warn "In MacroInsert, file_contents: #{file_contents.length} chars read".yellow if $VERBOSE
      else
        warn "In MacroInsert, file_contents: NIL".yellow if $VERBOSE
      end

      @@line_array = []

      return reader if reader.eof?

      putline '++++'
      putline "<div class='hide'>"
      putline '\('
      lines = file_contents.split("\n")
      lines.each do |line|
        putline line
      end

      putline '\)'
      putline '</div>'
      putline '++++'

      reader.unshift_lines @@line_array
      reader
    end

  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
asciidoctor-latex-1.5.0.17.dev lib/asciidoctor/latex/macro_insert.rb
asciidoctor-latex-1.5.0.16.dev lib/asciidoctor/latex/macro_insert.rb
asciidoctor-latex-1.5.0.15.dev lib/asciidoctor/latex/macro_insert.rb
asciidoctor-latex-1.5.0.14.dev lib/asciidoctor/latex/macro_insert.rb
asciidoctor-latex-1.5.0.13.dev lib/asciidoctor/latex/macro_insert.rb
asciidoctor-latex-1.5.0.12.dev lib/asciidoctor/latex/macro_insert.rb
asciidoctor-latex-1.5.0.11.dev lib/asciidoctor/latex/macro_insert.rb
asciidoctor-latex-1.5.0.10.dev lib/asciidoctor/latex/macro_insert.rb
asciidoctor-latex-1.5.0.9.dev lib/asciidoctor/latex/macro_insert.rb
asciidoctor-latex-1.5.0.8b.dev lib/asciidoctor/latex/macro_insert.rb
asciidoctor-latex-1.5.0.7.dev lib/asciidoctor/latex/macro_insert.rb
asciidoctor-latex-1.5.0.5.dev lib/asciidoctor/latex/macro_insert.rb
asciidoctor-latex-1.5.0.4.dev lib/asciidoctor/latex/macro_insert.rb
asciidoctor-latex-1.5.0.3.dev lib/asciidoctor/latex/macro_insert.rb
asciidoctor-latex-1.5.0.2.dev lib/asciidoctor/latex/macro_insert.rb
asciidoctor-latex-1.5.0.1.dev lib/asciidoctor/latex/macro_insert.rb
asciidoctor-latex-1.5.0.dev lib/asciidoctor/latex/macro_insert.rb