# encoding: UTF-8 module Quesadilla class Extractor # Extract Markdown # # This module has no public methods. module Markdown private # Gruber's regex is recursive, but I can't figure out how to do it in Ruby without the `g` option. # Maybe I should use StringScanner instead. For now, I think it's fine. Everything appears to work # as expected. NESTED_BRACKETS_REGEX = %r{ (?> [^\[\]]+ )* }x.freeze # 2 = Text, 3 = URL, 6 = Title LINK_REGEX = %r{ ( \[ (#{NESTED_BRACKETS_REGEX}) \] \( [ \t]* ? [ \t]* ( (['"]) (.*?) \5 )? \) ) }x.freeze # 1 = URL AUTOLINK_LINK_REGEX = /<((?:https?|ftp):[^'">\s]+)>/i.freeze # 1 = Email AUTOLINK_EMAIL_REGEX = %r{ < (?:mailto:)? ( [-.\w]+ \@ [-a-z0-9]+(?:\.[-a-z0-9]+)*\.[a-z]+ ) > }xi.freeze # 1 = Delimiter, 2 = Text BOLD_ITALIC_REGEX = %r{ (\*\*\*|___) (?=\S) (.+?[*_]*) (?<=\S) \1 }x.freeze # 1 = Delimiter, 2 = Text BOLD_REGEX = %r{ (\*\*|__) (?=\S) (.+?[*_]*) (?<=\S) \1 }x.freeze # 1 = Delimiter, 2 = Text ITALIC_REGEX = %r{ (\*|_) (?=\S) (.+?) (?<=\S) \1 }x.freeze # 1 = Delimiter, 2 = Text STRIKETHROUGH_REGEX = %r{ (~~) (?=\S) (.+?[~]*) (?<=\S) \1 }x.freeze # 1 = Delimiter, 2 = Text CODE_REGEX = %r{ (`+) (.+?) (?