blob: 5d989bc8ca1a77d6c0e9732a345a2d7329a51c7e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
defmodule Pleroma.Formatter do
@link_regex ~r/https?:\/\/[\w\.\/?=\-#]+[\w]/
def linkify(text) do
Regex.replace(@link_regex, text, "<a href='\\0'>\\0</a>")
end
@tag_regex ~r/\#\w+/u
def parse_tags(text) do
Regex.scan(@tag_regex, text)
|> Enum.map(fn (["#" <> tag = full_tag]) -> {full_tag, tag} end)
end
end
|