Class: MaRuKu::In::Markdown::SpanLevelParser::SpanContext

Inherits:
Object
  • Object
show all
Includes:
Strings
Defined in:
lib/maruku/input/parse_span_better.rb

Constant Summary

Constants included from Strings

Strings::Abbreviation, Strings::AttributeDefinitionList, Strings::Definition, Strings::EMailAddress, Strings::FootnoteText, Strings::HeaderWithAttributes, Strings::HeaderWithId, Strings::IncompleteLink, Strings::InlineAttributeList, Strings::LinkRegex, Strings::MightBeTableHeader, Strings::Sep, Strings::TabSize, Strings::TableSeparator, Strings::URL

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Strings

#add_tabs, #dbg_describe_ary, #force_linebreak?, #line_md_type, #normalize_key_and_value, #num_leading_hashes, #number_of_leading_spaces, #parse_email_headers, #spaces_before_first_char, #split_lines, #strip_hashes, #strip_indent, #unquote

Constructor Details

#initializeSpanContext

Returns a new instance of SpanContext.



630
631
632
633
# File 'lib/maruku/input/parse_span_better.rb', line 630

def initialize
	@elements = []
	@cur_string = ""
end

Instance Attribute Details

#cur_stringObject

Returns the value of attribute cur_string.



628
629
630
# File 'lib/maruku/input/parse_span_better.rb', line 628

def cur_string
  @cur_string
end

#elementsObject

Read elements



627
628
629
# File 'lib/maruku/input/parse_span_better.rb', line 627

def elements
  @elements
end

Instance Method Details

#describeObject



674
675
676
677
678
679
680
681
682
683
# File 'lib/maruku/input/parse_span_better.rb', line 674

def describe
	lines = @elements.map{|x| x.inspect}.join("\n")
	s = "Elements read in span: \n" +
	add_tabs(lines,1, ' -')+"\n"

	if @cur_string.size > 0
	s += "Current string: \n  #{@cur_string.inspect}\n" 
	end
	s
end

#push_char(c) ⇒ Object



662
663
664
665
# File 'lib/maruku/input/parse_span_better.rb', line 662

def push_char(c)
	@cur_string << c 
	nil
end

#push_element(e) ⇒ Object Also known as: push



635
636
637
638
639
640
641
642
# File 'lib/maruku/input/parse_span_better.rb', line 635

def push_element(e)
	raise "Only MDElement and String, please. You pushed #{e.class}: #{e.inspect} " if
	 not (e.kind_of?(String) or e.kind_of?(MDElement))

	push_string_if_present
	@elements << e
	nil
end

#push_elements(a) ⇒ Object



645
646
647
648
649
650
651
652
653
# File 'lib/maruku/input/parse_span_better.rb', line 645

def push_elements(a)
	for e in a 
		if e.kind_of? String
			e.each_byte do |b| push_char b end
		else
			push_element e
		end
	end
end

#push_spaceObject

push space into current string if there isn’t one



669
670
671
672
# File 'lib/maruku/input/parse_span_better.rb', line 669

def push_space
	last = @cur_string[@cur_string.size-1]
	@cur_string << ?\  if last != ?\ 
end

#push_string_if_presentObject



654
655
656
657
658
659
660
# File 'lib/maruku/input/parse_span_better.rb', line 654

def push_string_if_present
	if @cur_string.size > 0
		@elements << @cur_string
		@cur_string = ""
	end
	nil
end