Class: Orgmode::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/org2slides.rb

Instance Method Summary collapse

Instance Method Details

#to_revealjs_htmlObject



172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/org2slides.rb', line 172

def to_revealjs_html
  mark_trees_for_export
  export_options = {
    :decorate_title        => @in_buffer_settings["TITLE"],
    :export_heading_number => export_heading_number?,
    :export_todo           => export_todo?,
    :use_sub_superscripts  => use_sub_superscripts?,
    :export_footnotes      => export_footnotes?,
    :link_abbrevs          => @link_abbrevs,
    :skip_syntax_highlight => @parser_options[:skip_syntax_highlight],
    :markup_file           => @parser_options[:markup_file]
  }
  export_options[:skip_tables] = true if not export_tables?
  output = ""
  output_buffer = RevealJsHtmlBuffer.new(output, export_options)

  if @in_buffer_settings["TITLE"]

    # If we're given a new title, then just create a new line
    # for that title.
    title = Line.new(@in_buffer_settings["TITLE"], self, :title)
    translate_to_slides([title], output_buffer)
  end
  translate_to_slides(@header_lines, output_buffer) unless skip_header_lines?

  # If we've output anything at all, remove the :decorate_title option.
  export_options.delete(:decorate_title) if (output.length > 0)
  @headlines.each do |headline|
    next if headline.export_state == :exclude
    case headline.export_state
    when :exclude
    # NOTHING
    when :headline_only
      translate_to_slides(headline.body_lines[0, 1], output_buffer)
    when :all
      translate_to_slides(headline.body_lines, output_buffer)
    end
  end
  output << "\n"

  return output if @parser_options[:skip_rubypants_pass]

  rp = RubyPants.new(output)

  unclosed_html = rp.to_html
  closed_html = unclosed_html << "END-SLIDE"
  sectioned_html = closed_html.gsub("START-SLIDE", "\n<section>").gsub("END-SLIDE","\n</section>")
end

#translate_to_slides(lines, output_buffer) ⇒ Object



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/org2slides.rb', line 151

def translate_to_slides(lines, output_buffer)
  output_buffer.output_type = :start
  lines.each do |line|
    if (line.kind_of?(Headline))

      if(!@first_slide_done)
        @first_slide_done = true
      else
        output_buffer.insert_slide_stop
      end

      output_buffer.insert_slide_start
    end
    output_buffer.insert(line)
  end
  output_buffer.flush!
  output_buffer.pop_mode while output_buffer.current_mode
  output_buffer.output_footnotes!
  output_buffer.output
end