class Rabbit::Parser::Wiki::RabbitOutput
Attributes
canvas[R]
Public Class Methods
new(canvas)
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 40 def initialize(canvas) @canvas = canvas end
Public Instance Methods
block_plugin(src)
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 310 def block_plugin(src) return unless @parent result = evaluate_block_plugin(src) return if result == :no_element @parent << (result || text("{{#{src}}}")) end
block_preformatted(contents, info)
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 279 def block_preformatted(contents, info) return unless @parent lang = info ? info.downcase : nil result = nil if lang result = Ext::Rouge.highlight(lang, contents, @canvas.logger) end if result @parent << result else preformatted(text(contents)) end end
blockquote_close()
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 273 def blockquote_close return unless @parent @parent = @parent.parent end
blockquote_open()
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 265 def blockquote_open return unless @parent block_quote = BlockQuote.new @parent << block_quote @parent = block_quote end
container(_for=nil)
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 67 def container(_for=nil) [] end
current_body()
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 71 def current_body @slides.last.body end
del(item)
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 342 def del(item) DeletedText.new(item) end
dlist_close()
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 187 def dlist_close return unless @parent list = @parent @parent = list.parent @parent << list end
dlist_item(dt, dd)
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 195 def dlist_item(dt, dd) if @slide_property_mode and @target_slide name = dt.collect {|element| element.text}.join value = dd.collect {|element| element.text}.join @target_slide[Parser.normalize_property_name(name)] = value.strip else return unless @parent desc_term = DescriptionTerm.new(Paragraph.new(dt.flatten)) desc_content = DescriptionContent.new(Paragraph.new(dd.flatten)) @parent << DescriptionListItem.new(desc_term, desc_content) end end
dlist_open()
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 179 def dlist_open return unless @parent list = DescriptionList.new list.parent = @parent @parent = list end
em(item)
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 338 def em(item) Emphasis.new(item) end
finish()
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 60 def finish @slides.each do |slide| @canvas << slide end burn_out_pause_targets end
headline(level, title)
click to toggle source
Procedures
# File lib/rabbit/parser/wiki/output.rb, line 79 def headline(level, title) @slide_property_mode = false case level when 1 slide = nil if @slides.empty? @title_slide = true slide = TitleSlide.new(Title.new(title)) @parent = slide else @title_slide = false slide = Element::Slide.new(HeadLine.new(title)) body = Body.new slide << body @parent = body end @foot_texts << [] @slides << slide when 2 @slide_property_mode = true @parent, @target_slide = nil, @slides.last else @parent = nil end end
hrule()
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 105 def hrule @canvas.logger.warn(_("horizontal rule is unsupported")) if @parent end
hyperlink(uri, title)
click to toggle source
Functions
# File lib/rabbit/parser/wiki/output.rb, line 323 def hyperlink(uri, title) ref = ReferText.new(title) ref.to = uri ref end
image_hyperlink(uri, alt=nil)
click to toggle source
inline image is not supported yet…
# File lib/rabbit/parser/wiki/output.rb, line 330 def image_hyperlink(uri, alt=nil) Ext::Image.make_image(@canvas, uri, "caption" => alt) || Text.new(uri) end
inline_plugin(src)
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 350 def inline_plugin(src) evaluate_inline_plugin(src) || text("{{#{src}}}") end
list_begin()
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 109 def list_begin end
list_close(type)
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 137 def list_close(type) @enum_order_stack.pop if type == "ol" @list_type_stack.pop return unless @parent @parent = @parent.parent @parent = @parent.parent unless @list_type_stack.empty? end
list_end()
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 112 def list_end end
list_open(type)
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 115 def list_open(type) @enum_order_stack << 1 if type == "ol" @list_type_stack << type return unless @parent case type when "ul" list = ItemList.new when "ol" list = EnumList.new else unsupported_list_type(type) end if @list_type_stack.size > 1 @parent.elements.last << list else @parent << list end @parent = list end
listitem(item)
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 152 def listitem(item) return unless @parent list_item = nil item = item.flatten paragraph = Paragraph.new(item) type = @list_type_stack.last case type when "ul" list_item = ItemListItem.new(paragraph) @parent << list_item when "ol" list_item = EnumListItem.new(paragraph) list_item.order = @enum_order_stack.last @enum_order_stack[-1] += 1 @parent << list_item else unsupported_list_type end return unless paragraph.have_wait_tag? paragraph.default_visible = true paragraph.clear_theme register_pause(list_item) end
listitem_close()
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 149 def listitem_close end
listitem_open()
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 146 def listitem_open end
paragraph(contents)
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 302 def paragraph(contents) return unless @parent paragraph = Paragraph.new(contents.flatten) register_pause(paragraph) if paragraph.have_wait_tag? @parent << paragraph end
preformatted(contents)
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 296 def preformatted(contents) return unless @parent @parent << PreformattedBlock.new(PreformattedText.new(contents)) end
reset()
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 44 def reset @title_slide = false @slides = [] @parent = nil @index = {} @slide_property_mode = false @target_slide = nil @enum_order_stack = [] @list_type_stack = [] @foot_texts = [] end
strong(item)
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 334 def strong(item) Emphasis.new(Emphasis.new(item)) end
table_close()
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 223 def table_close return unless @parent @table << @table_head if @have_table_header @table << @table_body if @have_table_body @parent = @table.parent end
table_data(item, rs, cs)
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 257 def table_data(item, rs, cs) return unless @parent @have_table_body = true @table_body << @parent if @parent.parent.nil? @parent << TableCell.new(item) end
table_head(item, rs, cs)
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 245 def table_head(item, rs, cs) return unless @parent @have_table_header = true @table_head << @parent if @parent.parent.nil? header = TableHeader.new(item) def header.default_align Pango::Alignment::CENTER end @parent << header end
table_open()
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 209 def table_open return unless @parent @table = Table.new @parent << @table @parent = @table @table_head = TableHead.new @table_body = TableBody.new @have_table_header = false @have_table_body = false end
table_record_close()
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 239 def table_record_close return unless @parent @parent = @parent.parent end
table_record_open()
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 232 def table_record_open return unless @parent @parent = TableRow.new @table_record_type = nil end
text(str)
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 346 def text(str) Text.new(Ext::Escape.escape_meta_character(str)) end
Private Instance Methods
evaluate_block_plugin(src)
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 368 def evaluate_block_plugin(src) BlockPlugin.new(self).instance_eval(src, "(block plugin)") rescue ParseError raise rescue @canvas.logger.warn($!) nil end
evaluate_inline_plugin(src)
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 359 def evaluate_inline_plugin(src) InlinePlugin.new(self).instance_eval(src, "(inline plugin)") rescue ParseError raise rescue @canvas.logger.warn($!) nil end
unsupported_list_type(type)
click to toggle source
# File lib/rabbit/parser/wiki/output.rb, line 355 def unsupported_list_type(type) @canvas.logger.warn(_("unsupported list type: %s") % type) end