class MaRuKu::MDLine
Represents a single line in a Markdown source file, as produced by LineSource.
Public Instance Methods
Source
# File lib/maruku/input/mdline.rb, line 25 def gsub!(*args) # Any in-place-modification method should reset the md_type @md_type = nil super end
Calls superclass method
Source
# File lib/maruku/input/mdline.rb, line 7 def md_type @md_type ||= line_md_type end
Source
# File lib/maruku/input/mdline.rb, line 16 def number_of_leading_spaces if self =~ /\A\s+/ spaces = $& spaces.count(" ") + spaces.count("\t") * MaRuKu::Strings::TAB_SIZE else 0 end end
Returns the number of leading spaces on this string, considering that a tab counts as {MaRuKu::Strings::TAB_SIZE} spaces.
@param s [String] @return [Fixnum]
Private Instance Methods
Source
# File lib/maruku/input/mdline.rb, line 33 def line_md_type # The order of evaluation is important (:text is a catch-all) return :text if self =~ /\A[a-zA-Z]/ return :empty if self =~ /\A\s*\z/ return :footnote_text if self =~ FootnoteText return :ref_definition if self =~ LinkRegex || self =~ IncompleteLink return :abbreviation if self =~ Abbreviation return :definition if self =~ Definition # I had a bug with emails and urls at the beginning of the # line that were mistaken for raw_html return :text if self =~ /\A[ ]{0,3}#{EMailAddress}/ return :text if self =~ /\A[ ]{0,3}<\w+:\/\// # raw html is like PHP Markdown Extra: at most three spaces before return :xml_instr if self =~ /\A\s*<\?/ return :raw_html if self =~ %r{\A[ ]{0,3}</?\s*\w+} return :raw_html if self =~ /\A[ ]{0,3}<\!\-\-/ return :header1 if self =~ /\A(=)+/ return :header2 if self =~ /\A([-\s])+\z/ return :header3 if self =~ /\A(#)+\s*\S+/ # at least three asterisks/hyphens/underscores on a line, and only whitespace return :hrule if self =~ /\A(\s*[\*\-_]\s*){3,}\z/ return :ulist if self =~ /\A[ ]{0,3}([\*\-\+])\s+.*/ return :olist if self =~ /\A[ ]{0,3}\d+\.\s+.*/ return :code if number_of_leading_spaces >= 4 return :quote if self =~ /\A>/ return :ald if self =~ AttributeDefinitionList return :ial if self =~ InlineAttributeList return :text # else, it's just text end