Module MaRuKu::In::Markdown::SpanLevelParser
In: lib/maruku/attributes.rb
lib/maruku/input/charsource.rb
lib/maruku/input/html_helper.rb
lib/maruku/input/parse_span_better.rb
lib/maruku/input/rubypants.rb
lib/maruku.rb

Methods

Included Modules

MaRuKu::Helpers

Classes and Modules

Class MaRuKu::In::Markdown::SpanLevelParser::CharSourceDebug
Class MaRuKu::In::Markdown::SpanLevelParser::CharSourceManual
Class MaRuKu::In::Markdown::SpanLevelParser::CharSourceStrscan
Class MaRuKu::In::Markdown::SpanLevelParser::HTMLHelper
Class MaRuKu::In::Markdown::SpanLevelParser::SpanContext

Constants

CharSource = CharSourceManual # faster! 58ms vs. 65ms   Choose!
EscapedCharInText = Set.new [?\\,?`,?*,?_,?{,?},?[,?],?(,?),?#,?.,?!,?|,?:,?+,?-,?>]
EscapedCharInQuotes = Set.new [?\\,?`,?*,?_,?{,?},?[,?],?(,?),?#,?.,?!,?|,?:,?+,?-,?>,?',?"]
EscapedCharInInlineCode = [?\\,?`]
SPACE = ?\
R_REF_ID = Regexp.compile(/([^\]]*)\]/)   R_REF_ID = Regexp.compile(/([^\]\s]*)(\s*\])/) R_REF_ID = Regexp.compile(/([^\]\s]*)(\s*\])/)
Punct_class = '[!"#\$\%\'()*+,\-.\/:;<=>?\@\[\\\\\]\^_`{|}~]'
Close_class = %![^\ \t\r\n\\[\{\(\-]!
Rules = [ [/---/, :mdash ], [/--/, :ndash ], ['...', :hellip ], ['. . .', :hellip ], ["``", :ldquo ], ["''", :rdquo ], [/<<\s/, [:laquo, :nbsp] ], [/\s>>/, [:nbsp, :raquo] ], [/<</, :laquo ], [/>>/, :raquo ], # def educate_single_backticks(str) # ["`", :lsquo] # ["'", :rsquo] # Special case if the very first character is a quote followed by # punctuation at a non-word-break. Close the quotes by brute # force: [/^'(?=#{Punct_class}\B)/, :rsquo], [/^"(?=#{Punct_class}\B)/, :rdquo], # Special case for double sets of quotes, e.g.: # <p>He said, "'Quoted' words in a larger quote."</p> [/"'(?=\w)/, [:ldquo, :lsquo] ], [/'"(?=\w)/, [:lsquo, :ldquo] ], # Special case for decade abbreviations (the '80s): [/'(?=\d\ds)/, :rsquo ], # Get most opening single quotes: [/(\s)'(?=\w)/, [:one, :lsquo] ], # Single closing quotes: [/(#{Close_class})'/, [:one, :rsquo]], [/'(\s|s\b|$)/, [:rsquo, :one]], # Any remaining single quotes should be opening ones: [/'/, :lsquo], # Get most opening double quotes: [/(\s)"(?=\w)/, [:one, :ldquo]], # Double closing quotes: [/(#{Close_class})"/, [:one, :rdquo]], [/"(\s|s\b|$)/, [:rdquo, :one]], # Any remaining quotes should be opening ones: [/"/, :ldquo]

Public Instance methods

note: input will be destroyed

Start: cursor on character *after* ’{’ End: curson on ’}’ or EOF

We need a helper

Tries to read a quoted value. If stream does not start with ’ or ", returns nil.

Reads a bracketed id "[refid]". Consumes also both brackets.

Reads a simple string (no formatting) until one of break_on_chars, while escaping the escaped. If the string is empty, it returns nil. Raises on error if the string terminates unexpectedly.

      # If eat_delim is true, and if the delim is not the EOF, then the delim
      # gets eaten from the stream.

This is the main loop for reading span elements

It‘s long, but not complex or difficult to understand.

[Validate]