Skip to content

Instantly share code, notes, and snippets.

@gosukiwi
Created June 8, 2017 18:51
Show Gist options
  • Save gosukiwi/b3a8de145fe495cfda36990f2c91658d to your computer and use it in GitHub Desktop.
Save gosukiwi/b3a8de145fe495cfda36990f2c91658d to your computer and use it in GitHub Desktop.
class TextScanner < SimpleScanner
def self.from_string(plain_markdown)
text = plain_markdown
.each_char
.take_while { |char| SimpleScanner.from_string(char).null? }
.join('')
Token.new(type: 'TEXT', value: text)
rescue InvalidTokenError
Token.null
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment