Class: Asciibuild::Extensions::ConcatBlock

Inherits:
Asciidoctor::Extensions::BlockProcessor
  • Object
show all
Defined in:
lib/asciibuild/extensions.rb

Instance Method Summary collapse

Instance Method Details

#process(parent, reader, attrs) ⇒ Object



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/asciibuild/extensions.rb', line 108

def process parent, reader, attrs
  doctitle = parent.document.attributes["doctitle"]
  body = reader.read

  puts ""
  puts "#{doctitle} > #{parent.title} > #{attrs['title']}"
  puts (">" * 80)

  fname = if not include_section?(parent, attrs)
    if parent.document.attributes["error"]
      puts "Section \"#{parent.title}\" skipped due to previous error."
      attrs['title'] = 'icon:pause-circle[role=red] ' + attrs['title'] + " (previous error)"
    else
      sections = parent.document.attributes["sections"].split(/,[ ]*/)
      puts "Section \"#{parent.title}\" skipped. Does not match #{sections}."
      attrs['title'] = 'icon:pause-circle[role=yellow] ' + attrs['title']
    end
    false
  else
    attrs["file"]
  end

  if fname
    if not parent.document.attributes["#{parent.title} #{fname}"]
      open(fname, 'w') do |f|
        f.write("")
      end
      parent.document.attributes["#{parent.title} #{fname}"] = true
    end

    open(fname, 'a') do |f|
      f.write(body + "\n")
    end
    puts body
  end

  puts ("<" * 80)

  create_open_block parent, ["----", body, "----"], attrs
end