Class: Orgmode::HtmlOutputBuffer
- Inherits:
-
OutputBuffer
- Object
- OutputBuffer
- Orgmode::HtmlOutputBuffer
- Defined in:
- lib/org-ruby/html_output_buffer.rb
Constant Summary collapse
- HtmlBlockTag =
{ :paragraph => "p", :ordered_list => "li", :unordered_list => "li", :table_row => "tr", :table_header => "tr", :heading1 => "h1", :heading2 => "h2", :heading3 => "h3", :heading4 => "h4", :heading5 => "h5", :heading6 => "h6" }
- ModeTag =
{ :unordered_list => "ul", :ordered_list => "ol", :table => "table", :blockquote => "blockquote", :example => "pre", :src => "pre", :inline_example => "pre" }
Constants inherited from OutputBuffer
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Attributes inherited from OutputBuffer
#buffer, #buffer_mode, #buffered_lines, #headline_number_stack, #output, #output_type
Instance Method Summary collapse
- #flush! ⇒ Object
-
#initialize(output, opts = {}) ⇒ HtmlOutputBuffer
constructor
A new instance of HtmlOutputBuffer.
-
#pop_mode(mode = nil) ⇒ Object
We are leaving a mode.
-
#push_mode(mode) ⇒ Object
Output buffer is entering a new mode.
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, opts = {}) ⇒ HtmlOutputBuffer
Returns a new instance of HtmlOutputBuffer.
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/org-ruby/html_output_buffer.rb', line 33 def initialize(output, opts = {}) super(output) if opts[:decorate_title] then @title_decoration = " class=\"title\"" else @title_decoration = "" end @options = opts @logger.debug "HTML export options: #{@options.inspect}" end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
31 32 33 |
# File 'lib/org-ruby/html_output_buffer.rb', line 31 def @options end |
Instance Method Details
#flush! ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/org-ruby/html_output_buffer.rb', line 72 def flush! escape_buffer! if mode_is_code(@buffer_mode) then # Whitespace is significant in :code mode. Always output the buffer # and do not do any additional translation. @logger.debug "FLUSH CODE ==========> #{@buffer.inspect}" @output << @buffer << "\n" else if (@buffer.length > 0) then unless buffer_mode_is_table? and skip_tables? @logger.debug "FLUSH ==========> #{@buffer_mode}" output_indentation @output << "<#{HtmlBlockTag[@output_type]}#{@title_decoration}>" if (@buffered_lines[0].kind_of?(Headline)) then headline = @buffered_lines[0] raise "Cannot be more than one headline!" if @buffered_lines.length > 1 if @options[:export_heading_number] then level = headline.level heading_number = get_next_headline_number(level) output << "<span class=\"heading-number heading-number-#{level}\">#{heading_number} </span>" end if @options[:export_todo] and headline.keyword then keyword = headline.keyword output << "<span class=\"todo-keyword #{keyword}\">#{keyword} </span>" end end @output << inline_formatting(@buffer) @output << "</#{HtmlBlockTag[@output_type]}>\n" @title_decoration = "" else @logger.debug "SKIP ==========> #{@buffer_mode}" end end end clear_accumulation_buffer! end |
#pop_mode(mode = nil) ⇒ Object
We are leaving a mode. Close any tags that were opened when entering this mode.
63 64 65 66 67 68 69 70 |
# File 'lib/org-ruby/html_output_buffer.rb', line 63 def pop_mode(mode = nil) m = super(mode) if ModeTag[m] then output_indentation @logger.debug "</#{ModeTag[m]}>\n" @output << "</#{ModeTag[m]}>\n" unless mode == :table and skip_tables? end end |
#push_mode(mode) ⇒ Object
Output buffer is entering a new mode. Use this opportunity to write out one of the block tags in the ModeTag constant to put this information in the HTML stream.
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/org-ruby/html_output_buffer.rb', line 47 def push_mode(mode) if ModeTag[mode] then output_indentation css_class = "" css_class = " class=\"src\"" if mode == :src css_class = " class=\"example\"" if (mode == :example || mode == :inline_example) @logger.debug "#{mode}: <#{ModeTag[mode]}#{css_class}>\n" @output << "<#{ModeTag[mode]}#{css_class}>\n" unless mode == :table and skip_tables? # Entering a new mode obliterates the title decoration @title_decoration = "" end super(mode) end |