diff --git a/lib/org-ruby/html_output_buffer.rb b/lib/org-ruby/html_output_buffer.rb index 021abfc..d76b746 100644 --- a/lib/org-ruby/html_output_buffer.rb +++ b/lib/org-ruby/html_output_buffer.rb @@ -34,8 +34,10 @@ def initialize(output, opts = {}) @new_paragraph = :start @footnotes = {} @unclosed_tags = [] - @custom_blocktags = {} if @options[:markup_file] - do_custom_markup if @options[:markup_file] + # move from output_buffer + @code_block_indent = nil + + do_custom_markup end def buffer_tag @@ -101,11 +103,11 @@ def skip_css?(mode) # entering this mode. def pop_mode(mode = nil) m = super(mode) - return @list_indent_stack.pop unless html_tags.include?(m) - return @list_indent_stack.pop if skip_css?(m) + return list_indent_stack.pop unless html_tags.include?(m) + return list_indent_stack.pop if skip_css?(m) push_indentation(@new_paragraph) @output.concat("#{HtmlBlockTag[m]}>") - @list_indent_stack.pop + list_indent_stack.pop end def highlight(code, lang) @@ -144,7 +146,7 @@ def flush! else @output << inline_formatting(definition) end - indent = @list_indent_stack.last + indent = list_indent_stack.last pop_mode @new_paragraph = :start @@ -199,13 +201,15 @@ def add_line_attributes headline end end + # Only footnotes defined in the footnote (i.e., [fn:0:this is the footnote definition]) + # will be automatically + # added to a separate Footnotes section at the end of the document. All footnotes that are + # defined separately from their references will be rendered where they appear in the original + # Org document. def output_footnotes! - # Only footnotes defined in the footnote (i.e., [fn:0:this is the footnote definition]) will be automatically - # added to a separate Footnotes section at the end of the document. All footnotes that are defined separately - # from their references will be rendered where they appear in the original Org document. - return false unless @options[:export_footnotes] and not @footnotes.empty? + return false if !options[:export_footnotes] || @footnotes.empty? + @output.concat footnotes_header - @output << "\n
Using letters and not defined in the footnote abc
+Defined in the footnote itself with markup 0
+Some example paragraph 1, with text at the end.
+Some example paragraph 2, with text at the end.
+Some example paragraph 3, with text at the end.
+Some example paragraph 4, with text at the end.
+Some example paragraph 5, with text at the end.
+Some example paragraph 6, with text at the end.
+Some example paragraph 7, with text at the end.
+Some example paragraph 8, with text at the end.
+Some example paragraph 9, with text at the end.
+Some example paragraph 10, with text at the end.
+Some example paragraph 11, with text at the end.
+Some example paragraph 12, with text at the end.
+Some example paragraph 13, with text at the end.
+Some example paragraph 14, with text at the end.
+Some example paragraph 15, with text at the end.
+Some example paragraph 16, with text at the end.
+Some example paragraph 17, with text at the end.
+Some example paragraph 18, with text at the end.
+Some example paragraph 19, with text at the end.
+Some example paragraph 20, with text at the end.
+Some example paragraph 21, with text at the end.
+Some example paragraph 22, with text at the end.
+Some example paragraph 23, with text at the end.
+Some example paragraph 24, with text at the end.
+Some example paragraph 25, with text at the end.
+Some example paragraph 26, with text at the end.
+Some example paragraph 27, with text at the end.
+Some example paragraph 28, with text at the end.
+Some example paragraph 29, with text at the end.
+Some example paragraph 30, with text at the end.
+Some example paragraph 31, with text at the end.
+Some example paragraph 32, with text at the end.
+Some example paragraph 33, with text at the end.
+Some example paragraph 34, with text at the end.
+Some example paragraph 35, with text at the end.
+Some example paragraph 36, with text at the end.
+Some example paragraph 37, with text at the end.
+Some example paragraph 38, with text at the end.
+Some example paragraph 39, with text at the end.
+Some example paragraph 40, with text at the end.
+Some example paragraph 41, with text at the end.
+Some example paragraph 42, with text at the end.
+Some example paragraph 43, with text at the end.
+Some example paragraph 44, with text at the end.
+Some example paragraph 45, with text at the end.
+Some example paragraph 46, with text at the end.
+Some example paragraph 47, with text at the end.
+Some example paragraph 48, with text at the end.
+Some example paragraph 49, with text at the end.
+Some example paragraph 50, with text at the end.
+1 And some example footnote
+2 And some example footnote
+3 And some example footnote
+4 And some example footnote
+5 And some example footnote
+6 And some example footnote
+7 And some example footnote
+8 And some example footnote
+9 And some example footnote
+10 And some example footnote
+11 And some example footnote
+12 And some example footnote
+13 And some example footnote
+14 And some example footnote
+15 And some example footnote
+16 And some example footnote
+17 And some example footnote
+18 And some example footnote
+19 And some example footnote
+20 And some example footnote
+21 And some example footnote
+22 And some example footnote
+23 And some example footnote
+24 And some example footnote
+25 And some example footnote
+26 And some example footnote
+27 And some example footnote
+28 And some example footnote
+29 And some example footnote
+30 And some example footnote
+31 And some example footnote
+32 And some example footnote
+33 And some example footnote
+34 And some example footnote
+35 And some example footnote
+36 And some example footnote
+37 And some example footnote
+38 And some example footnote
+39 And some example footnote
+40 And some example footnote
+41 And some example footnote
+42 And some example footnote
+43 And some example footnote
+44 And some example footnote
+45 And some example footnote
+46 And some example footnote
+47 And some example footnote
+48 And some example footnote
+49 And some example footnote
+50 And some example footnote
+Using letters and defined in the footnote abc
+ diff --git a/spec/org-ruby/html_output_buffer_spec.rb b/spec/org-ruby/html_output_buffer_spec.rb index 445d142..88866d2 100644 --- a/spec/org-ruby/html_output_buffer_spec.rb +++ b/spec/org-ruby/html_output_buffer_spec.rb @@ -1,4 +1,3 @@ -# coding: utf-8 require 'spec_helper' require_relative '../../lib/org-ruby/html_output_buffer' diff --git a/spec/org-ruby/output_buffer_spec.rb b/spec/org-ruby/output_buffer_spec.rb index 6dcafe1..ea81f29 100644 --- a/spec/org-ruby/output_buffer_spec.rb +++ b/spec/org-ruby/output_buffer_spec.rb @@ -3,8 +3,36 @@ require_relative '../../lib/org-ruby/output_buffer' module Orgmode RSpec.describe OutputBuffer do + let(:output) { 'Output' } + let(:buffer) { Orgmode::OutputBuffer.new(output) } + describe '.new' do + it 'receives and has an output' do + expect(buffer.output).to eq output + end + end + + describe 'get_next_headline_number' do + let(:level) { 1 } + context 'when @headline_number_stack is empty' do + it 'returns 1' do + headline_number = buffer.get_next_headline_number(level) + expect(headline_number).to eq '1' + end + end + + context 'when @headline_number_stack has numbers' do + let(:level) { 2 } + before(:each) do + buffer.headline_number_stack.push(4) + buffer.headline_number_stack.push(2) + end + it 'returns 4.3' do + headline_number = buffer.get_next_headline_number(level) + expect(headline_number).to eq '4.3' + end + end end end end diff --git a/spec/parser_spec.rb b/spec/parser_spec.rb index 55aeb20..af2207e 100644 --- a/spec/parser_spec.rb +++ b/spec/parser_spec.rb @@ -329,6 +329,19 @@ end end + describe "Footnotes title" do + base_dir = File.join(File.dirname(__FILE__), "html_examples") + org_file = File.join(base_dir, "footnotes.org") + html_file = File.join(base_dir, "footnotes_title.html") + it 'accept footnotes_title option' do + expected = IO.read(html_file) + parser = Orgmode::Parser.new(IO.read(org_file), :footnotes_title => "Footnotes Title") + actual = parser.to_html + expect(actual).to be_kind_of(String) + expect(actual).to eq(expected) + end + end + describe "Export to Markdown test cases" do data_directory = File.join(File.dirname(__FILE__), "markdown_examples") org_files = File.expand_path(File.join(data_directory, "*.org" )) @@ -489,4 +502,3 @@ end end end -