philomena/lib/textile/url_lexer.ex
2019-11-03 18:58:11 -05:00

14 lines
No EOL
338 B
Elixir

defmodule Textile.UrlLexer do
import NimbleParsec
def url_ending_in(ending_sequence) do
protocol =
choice([
string("/"), string("https://"), string("http://"), string("data:image/")
])
protocol
|> repeat(lookahead_not(ending_sequence) |> utf8_char([]))
|> reduce({List, :to_string, []})
end
end