Add Formatter.
This commit is contained in:
parent
70024632ba
commit
dcfd494e97
2 changed files with 41 additions and 0 deletions
13
lib/pleroma/formatter.ex
Normal file
13
lib/pleroma/formatter.ex
Normal file
|
|
@ -0,0 +1,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
|
||||
Loading…
Add table
Add a link
Reference in a new issue