Created
June 8, 2017 18:51
-
-
Save gosukiwi/b3a8de145fe495cfda36990f2c91658d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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