Class: MaRuKu::In::Markdown::SpanLevelParser::SpanContext
- Inherits:
-
Object
- Object
- MaRuKu::In::Markdown::SpanLevelParser::SpanContext
- Includes:
- Strings
- Defined in:
- lib/maruku/input/parse_span_better.rb
Constant Summary
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
Instance Attribute Summary (collapse)
-
- (Object) cur_string
Returns the value of attribute cur_string.
-
- (Object) elements
Read elements.
Instance Method Summary (collapse)
- - (Object) describe
-
- (SpanContext) initialize
constructor
A new instance of SpanContext.
- - (Object) push_char(c)
- - (Object) push_element(e) (also: #push)
- - (Object) push_elements(a)
-
- (Object) push_space
push space into current string if there isn't one.
- - (Object) push_string_if_present
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, #sanitize_ref_id, #spaces_before_first_char, #split_lines, #strip_hashes, #strip_indent, #unquote
Constructor Details
- (SpanContext) initialize
A new instance of SpanContext
688 689 690 691 |
# File 'lib/maruku/input/parse_span_better.rb', line 688 def initialize @elements = [] @cur_string = "" end |
Instance Attribute Details
- (Object) cur_string
Returns the value of attribute cur_string
686 687 688 |
# File 'lib/maruku/input/parse_span_better.rb', line 686 def cur_string @cur_string end |
- (Object) elements
Read elements
685 686 687 |
# File 'lib/maruku/input/parse_span_better.rb', line 685 def elements @elements end |
Instance Method Details
- (Object) describe
733 734 735 736 737 738 739 740 741 742 |
# File 'lib/maruku/input/parse_span_better.rb', line 733 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 |
- (Object) push_char(c)
721 722 723 724 |
# File 'lib/maruku/input/parse_span_better.rb', line 721 def push_char(c) @cur_string << c nil end |
- (Object) push_element(e) Also known as: push
693 694 695 696 697 698 699 700 |
# File 'lib/maruku/input/parse_span_better.rb', line 693 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 |
- (Object) push_elements(a)
703 704 705 706 707 708 709 710 711 |
# File 'lib/maruku/input/parse_span_better.rb', line 703 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 |
- (Object) push_space
push space into current string if there isn't one
728 729 730 731 |
# File 'lib/maruku/input/parse_span_better.rb', line 728 def push_space last = @cur_string[@cur_string.size-1] @cur_string << ?\ if last != ?\ end |
- (Object) push_string_if_present
713 714 715 716 717 718 719 |
# File 'lib/maruku/input/parse_span_better.rb', line 713 def push_string_if_present if @cur_string.size > 0 @elements << @cur_string @cur_string = "" end nil end |