Class: Orgmode::TextileOutputBuffer
- Inherits:
-
OutputBuffer
- Object
- OutputBuffer
- Orgmode::TextileOutputBuffer
- Defined in:
- lib/org-ruby/textile_output_buffer.rb
Constant Summary collapse
- TextileMap =
Maps org markup to textile markup.
{ "*" => "*", "/" => "_", "_" => "_", "=" => "@", "~" => "@", "+" => "+" }
Constants inherited from OutputBuffer
Instance Attribute Summary
Attributes inherited from OutputBuffer
#buffer, #buffer_mode, #buffered_lines, #headline_number_stack, #output, #output_type
Instance Method Summary collapse
-
#flush! ⇒ Object
Flushes the current buffer.
-
#initialize(output) ⇒ TextileOutputBuffer
constructor
A new instance of TextileOutputBuffer.
-
#inline_formatting(input) ⇒ Object
Handles inline formatting for textile.
- #pop_mode(mode = nil) ⇒ Object
- #push_mode(mode) ⇒ Object
Methods inherited from OutputBuffer
#<<, #clear_accumulation_buffer!, #current_mode, #current_mode_list?, #enter_table?, #exit_table?, #get_next_headline_number, #list_indent_level, #prepare, #preserve_whitespace?
Constructor Details
#initialize(output) ⇒ TextileOutputBuffer
Returns a new instance of TextileOutputBuffer.
7 8 9 10 |
# File 'lib/org-ruby/textile_output_buffer.rb', line 7 def initialize(output) super(output) @add_paragraph = false end |
Instance Method Details
#flush! ⇒ Object
Flushes the current buffer
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/org-ruby/textile_output_buffer.rb', line 48 def flush! @logger.debug "FLUSH ==========> #{@output_type}" if (@output_type == :blank) then @output << "\n" elsif (@buffer.length > 0) then if @add_paragraph then @output << "p. " if @output_type == :paragraph @add_paragraph = false end @output << "bq. " if current_mode == :blockquote @output << "#" * @list_indent_stack.length << " " if @output_type == :ordered_list @output << "*" * @list_indent_stack.length << " " if @output_type == :unordered_list @output << inline_formatting(@buffer) << "\n" end clear_accumulation_buffer! end |
#inline_formatting(input) ⇒ Object
Handles inline formatting for textile.
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/org-ruby/textile_output_buffer.rb', line 34 def inline_formatting(input) input = @re_help.rewrite_emphasis(input) do |marker, body| m = TextileMap[marker] "#{m}#{body}#{m}" end input = @re_help.rewrite_links(input) do |link, text| text ||= link link = link.gsub(/ /, "%20") "\"#{text}\":#{link}" end input end |
#pop_mode(mode = nil) ⇒ Object
17 18 19 20 21 |
# File 'lib/org-ruby/textile_output_buffer.rb', line 17 def pop_mode(mode = nil) m = super(mode) @add_paragraph = (mode_is_code(m)) m end |
#push_mode(mode) ⇒ Object
12 13 14 15 |
# File 'lib/org-ruby/textile_output_buffer.rb', line 12 def push_mode(mode) super(mode) @output << "bc.. " if mode_is_code(mode) end |